update logger

This commit is contained in:
Barry Low committed 2018-10-30 21:34:00 -07:00
1 parent 2449c642d2
commit 94c962cd44
12 files changed
+46 -29

No files matched your search

+1 -1
View File
@@ -1,4 +1,4 @@
const gql = require('graphql-tag')
import gql from 'graphql-tag'
const TEAM_FB_FRAGMENT = gql`{
id
@@ -1,4 +1,4 @@
const gql = require('graphql-tag')
import gql from 'graphql-tag'
const TEAMS_CONNECTIONS_FRAGMENT = gql`{
edges {
+1 -1
View File
@@ -1,4 +1,4 @@
const gql = require('graphql-tag')
import gql from 'graphql-tag'
const TEAMS_FRAGMENT = gql`{
id
+5 -2
View File
@@ -1,6 +1,6 @@
import { getUser } from '../../../middleware/getMember'
import { sendTeamMemberInvite, sendTeamCreateConfirmation, verifyInviteToken } from '../../..//email/sendgrid'
import { sendTeamMemberInvite, sendTeamCreateConfirmation, verifyInviteToken } from '../../../email/sendgrid'
import TEAM_FB_FRAGMENT from '../../fragments/TeamFBFragment'
@@ -40,7 +40,10 @@ export const resolvers = {
logger.info('createTeam ctx.request.user:')
logger.info(ctx.request.user)
const authId = ctx.userId
const authId = ctx.request.headers.userid
if (!authId) {
throw new AuthenticationError()
}
return getUser(authId)
.then(async result => {
+7 -6
View File
@@ -1,12 +1,13 @@
import { logger, AuthentificationError, DatabaseError } from '../../../logger'
import { logger, AuthenticationError, DatabaseError } from '../../../logger'
export const member = async (parent, arg, ctx, info) => {
logger.info(ctx.request.userId, ' --> resolver.member')
const authId = ctx.request.userId
logger.info(' --> resolver.member')
logger.info(ctx.request)
const authId = ctx.request.headers.userid
if (!authId) {
throw new AuthentificationError()
throw new AuthenticationError()
}
return ctx.db.query.member({ where: { authId: arg.authId } }, info)
return ctx.db.query.member({ where: { authId } }, info)
.catch(err => {
logger.debug('resolver.member error: ')
logger.debug(err)
@@ -18,7 +19,7 @@ export const owner = async (parent, args, ctx, info) => {
logger.info('resolver.query.owner ctx: ')
const authId = ctx.request.userId
if (!authId) {
return throw new AuthentificationError()
throw new AuthenticationError()
}
return ctx.db.query.member({ where: { authId: authId } }, info)
.catch(err => {
+12 -6
View File
@@ -4,7 +4,8 @@ import TEAMS_CONNECTIONS_FRAGMENT from '../../fragments/TeamsConnectionsFragment
import TEAMS_FRAGMENT from '../../fragments/TeamsFragment'
export const teams = async (parent, args, ctx, info) => {
logger.info('teams: ', ctx.request.res)
logger.info('teams')
console.log('teams')
return ctx.db.query.teamsConnection({}, TEAMS_CONNECTIONS_FRAGMENT)
}
@@ -20,15 +21,20 @@ export const teamWithRole = async (parent, { teamId, role }, ctx, info) => {
return ctx.db.query.teamsConnection({where: {AND: [{id: teamId},{members_some:{role: role}}]}, first:1}, info)
}
export const teamsByOwner = async (parent, { ownerId }, ctx, info) => {
export const teamsByOwner = async (parent, args, ctx, info) => {
logger.info('teamsByOwner')
logger.info(ctx.req.headers)
logger.info(ctx.req.token)
return ctx.db.query.teams({where: { owner: ownerId }, orderBy:'updatedAt_DESC'}, TEAMS_FRAGMENT)
const authId = ctx.request.headers.userid
if (!authId) {
throw new AuthenticationError()
}
return ctx.db.query.teams({where: { owner: authId }, orderBy:'updatedAt_DESC'}, TEAMS_FRAGMENT)
}
export const teamsByRole = async (parent, args, ctx, info) => {
const authId = ctx.request.userId
const authId = ctx.request.headers.userid
if (!authId) {
throw new AuthenticationError()
}
let teamAdmin
try {
teamAdmin= await ctx.db.query.teams({where: {members_some: {AND: [{member: {authId: authId}, role_not:'MEMBER'}]}}}, TEAMS_FRAGMENT)
@@ -2,7 +2,10 @@ import { logger } from '../../../logger'
export const fbByTeamMember = async (parent, args, ctx, info) => {
logger.info('fbByTeamMember: ', args, ctx.request, ctx.request.res.req.user)
const authId = ctx.request.userId
const authId = ctx.request.headers.userid
if (!authId) {
throw new AuthenticationError()
}
let teamMemberFB = await ctx.db.query.teams({where: {members_some: {AND: [{member: {authId: authId}}]}}, orderBy: 'updatedAt_DESC'}, TEAM_FB_FRAGMENT)
logger.info('fbByTeamMember response: ', await teamMemberFB[0])
return teamMemberFB[0]
+1 -1
View File
@@ -3,4 +3,4 @@ import merge from 'lodash.merge'
import { resolvers as queryResolvers } from './Query'
import { resolvers as mutationResolvers } from './Mutation'
const resolvers = merge(queryResolvers, mutationResolvers)
export const resolvers = merge(queryResolvers, mutationResolvers)
+1 -1
View File
@@ -11,7 +11,7 @@ type Query {
teamByName(name: String!): Team
teamById(teamId: String!): Team
teamWithRole(teamId: String!, role: String!): Team
teamsByOwner(ownerId: String!): [Team!]! @isAuthenticated
teamsByOwner: [Team!]! @isAuthenticated
teamsByRole: [Team!]! @isAuthenticated
fbByTeamMember: Team @isAuthenticated
owner: Member @isAuthenticated