Merge branch 'master' of https://github.com/AdvancedAlgos/MasterApp into develop

This commit is contained in:
Barry Low committed 2018-10-29 23:46:42 -07:00
commit a1868906c0
4 files changed
+56 -2

No files matched your search

+1
View File
@@ -1,6 +1,7 @@
GRAPHQL_API_URL=https://app-api.advancedalgos.net/graphql
TEAMS_API_URL=https://teams-api.advancedalgos.net/graphql
USERS_API_URL=https://users-api.advancedalgos.net/graphql
HOSTS_API_URL=https://hosts-api.advancedalgos.net/graphql
KEYVAULT_API_URL=https://keyvault-api.advancedalgos.net/graphql
AUTH0_DOMAIN=auth0-domain
+9 -1
View File
@@ -8,7 +8,7 @@ import jwksRsa from 'jwks-rsa'
import axios from 'axios'
import { createTransformedRemoteSchema } from './createRemoteSchema'
import { teams } from './links'
import { teams, hosts } from './links'
import logger from './logger'
async function getUserId (authId) {
@@ -36,6 +36,7 @@ async function getUserId (authId) {
async function run () {
const transformedTeamsSchema = await createTransformedRemoteSchema('teams_', process.env.TEAMS_API_URL)
const transformedUsersSchema = await createTransformedRemoteSchema('users_', process.env.USERS_API_URL)
const transformedHostsSchema = await createTransformedRemoteSchema('hosts_', process.env.HOSTS_API_URL)
const transformedKeyVaultSchema = await createTransformedRemoteSchema('keyVault_', process.env.KEYVAULT_API_URL)
var schemas = []
@@ -51,6 +52,13 @@ async function run () {
if (transformedUsersSchema) {
schemas.push(transformedUsersSchema)
}
if (transformedHostsSchema) {
schemas.push(transformedHostsSchema)
if (transformedUsersSchema && transformedTeamsSchema) {
schemas.push(hosts.linkSchemaDefs)
resolvers = Object.assign(resolvers, hosts.resolver(transformedUsersSchema, transformedTeamsSchema))
}
}
if (transformedKeyVaultSchema) {
schemas.push(transformedKeyVaultSchema)
}
+44
View File
@@ -0,0 +1,44 @@
export const linkSchemaDefs =
`
extend type hosts_Event {
host: users_User
}
extend type hosts_Participant {
team: teams_Team
}
`
export const resolver = (usersSchema, teamsSchema) => ({
hosts_Event: {
host: {
fragment: `fragment UserFragment on hosts_Event{hostId}`,
resolve (parent, args, context, info) {
return info.mergeInfo.delegateToSchema({
schema: usersSchema,
operation: 'query',
fieldName: 'users_User',
args: { id: parent.hostId },
context,
info
})
}
}
},
hosts_Participant: {
team: {
fragment: `fragment TeamFragment on hosts_Participant{teamId}`,
resolve (parent, args, context, info) {
return info.mergeInfo.delegateToSchema({
schema: teamsSchema,
operation: 'query',
fieldName: 'teams_TeamById',
args: { teamId: parent.teamId },
context,
info
})
}
}
}
})
export default { resolver, linkSchemaDefs }
+2 -1
View File
@@ -1,3 +1,4 @@
import teams from './teams'
import hosts from './hosts'
export { teams }
export { teams, hosts }