Merge branch 'feature/fbByOwner' into develop

This commit is contained in:
Barry Low committed 2019-03-26 17:55:57 +01:00
commit 3e5ed50b4b
4 files changed
+48 -2

No files matched your search

@@ -0,0 +1,33 @@
import gql from 'graphql-tag'
const FB_TEAM_FRAGMENT = gql`{
edges{
node{
id
name
slug
avatar
kind
status {
status
reason
createdAt
}
team {
id
name
slug
owner
profile {
avatar
banner
description
motto
updatedAt
}
}
}
}
}`
module.exports = FB_TEAM_FRAGMENT
@@ -1,6 +1,7 @@
import { logger } from '../../../logger'
import FB_FRAGMENT from '../../fragments/FBFragment'
import FB_TEAM_FRAGMENT from '../../fragments/FBTeamFragment'
export const fbByFbId = async (parent, { fbId }, ctx, info) => {
logger.info(`fbByFbId: ${fbId}`)
@@ -15,3 +16,13 @@ export const fbByFbSlug = async (parent, { fbSlug }, ctx, info) => {
logger.info(`fbByFbSlug response: ${JSON.stringify(await FB)}`)
return FB[0]
}
export const fbByOwner = async (parent, { fbId, fbSlug }, ctx, info) => {
logger.info('teamsByOwner')
const authId = ctx.request.headers.userid
if (!authId) {
throw new AuthenticationError()
return
}
return ctx.db.query.financialBeingsesConnection({where: {AND:[{team:{members_some:{member:{authId: authId}}}},{OR:[{slug:fbSlug},{id:fbId}]}]}}, FB_TEAM_FRAGMENT)
}
+2 -1
View File
@@ -3,7 +3,7 @@ import { logger } from '../../../logger'
import { member, owner } from './Member'
import { teams, teamById, teamsByIds, teamByName, teamBySlug, teamWithRole, teamAuthorization, teamsByOwner, teamsByRole } from './Team'
import{ fbByTeamMember } from './TeamMember'
import{ fbByFbId, fbByFbSlug } from './FinancialBeing'
import{ fbByFbId, fbByFbSlug, fbByOwner } from './FinancialBeing'
export const resolvers = {
Query: {
@@ -19,6 +19,7 @@ export const resolvers = {
teamsByRole: (parent, arg, ctx, info) => teamsByRole(parent, arg, ctx, info),
owner: (parent, arg, ctx, info) => owner(parent, arg, ctx, info),
fbByTeamMember: (parent, arg, ctx, info) => fbByTeamMember(parent, arg, ctx, info),
fbByOwner: (parent, arg, ctx, info) => fbByOwner(parent, arg, ctx, info),
fbByFbId: (parent, arg, ctx, info) => fbByFbId(parent, arg, ctx, info),
fbByFbSlug: (parent, arg, ctx, info) => fbByFbSlug(parent, arg, ctx, info)
}
+2 -1
View File
@@ -1,4 +1,4 @@
# import Query.TeamConnection, Team, FinancialBeings from "../generated/prisma.graphql"
# import Query.TeamConnection, Query.FinancialBeingsConnection, Team, FinancialBeings from "../generated/prisma.graphql"
directive @isAuthenticated on QUERY | FIELD | MUTATION | FIELD_DEFINITION
directive @hasRole(roles: [String]) on QUERY | FIELD | MUTATION | FIELD_DEFINITION
@@ -17,6 +17,7 @@ type Query {
teamsByOwner: [Team!]! @isAuthenticated
teamsByRole: [Team!]! @isAuthenticated
fbByTeamMember: Team @isAuthenticated
fbByOwner(fbId: String, fbSlug: String): FinancialBeingsConnection @isAuthenticated
fbByFbId(fbId: String!): FinancialBeings
fbByFbSlug(fbSlug: String!): FinancialBeings
owner: Member @isAuthenticated