I'm attempting to create a microservice based application that uses two remote Prisma/GraphQL schemas that run in Docker and a gateway that introspects them using schema stitching.
Prisma/GraphQL Schemas:
// Profile Schema service - http:localhost:3000/profile
type Profile {
id: ID!
user_id: ID!
firstName: String!
...
}
type Query {
findProfileById(id: ID!): Profile
findProfileByUserID(user_id: ID!): Profile
}
// User Schema service - http:localhost:5000/user
type User {
id: ID!
profileID: ID!
email: String!
...
}
type Query {
findUserById(id: ID!): User
findUserByProfileID(profileID: ID!): Profile
}
Now in the Gateway server I am able to introspect and mergeSchemas using graphql-tools successfully and I have added extended types to allow for relationships between the two types
// LinkTypeDefs
extend type Profile {
user: User
}
extend type User {
userProfile: Profile
}
I followed Apollo GraphQL documentation for schema stitching with remote schemas and this is the resolver I have for the now merged schemas
app.use('/gateway', bodyParser.json(), graphqlExpress({ schema: mergeSchemas({
schemas: [
profileSchema,
userSchema,
linkTypeDefs
],
resolvers: mergeInfo => ({
User: {
userProfile: {
fragment: `fragment UserFragment on User { id }`,
resolve(user, args, context, info) {
return delegateToSchema({
schema: profileSchema,
operation: 'query',
fieldName: 'findProfileByUserId',
args: {
user_id: user.id
},
context,
info
},
);
},
},
},
Profile: {
user: {
fragment: `fragment ProfileFragment on Profile { id }`,
resolve(profile, args, context, info) {
return delegateToSchema({
schema: authSchema,
operation: 'query',
fieldName: 'findUserByProfileId',
args: {
profileID: profile.id
},
context,
info
})
}
}
}
}),
})
}));
The issue I am having is everytime I query User or Profile for their new extended fields it always returns null. I have made sure that I have created User object with an existing profileId, likewise with Profile object with an existing userId. This is a sample of the query results
I have gone through the docs for about a week now and nothing seems to be working. From my undertstanding everything is plugged in properly. Hopefully someone can help. I have a feeling it has something to do with the fragments. I can provide a screenshot of the user and profile objects for more clarification if need be. Thanks.