I have multiple GraphQL microservices (subgraphs, using ApolloFederationDriver) with a GraphQL gateway (using ApolloGatewayDriver)
I have a really strange bug since I’ve upgraded my GraphQL microservices and gateway to use @apollo/server
(@nestjs/graphql@11
+ @nestjs/apollo@11
) : I have an error when my subgraphs are composed telling me that subgraph A has a non shareable field from an object type subgraph B and so it is not happy with. I would ok with this error, the problem is that subgraph A doesn’t have the mentionned entity from the subgraph B and I don’t know why I got this error.
For information, I have a monorepo, which contains a package where all my object types are defined and exported
I know this is quite strange, let me know if you have any idea where this error could come from.
Thanks 🙂
EDIT 1: So it seems that if one of my ObjectType has a @Field(() => AnotherObjectType
, AnotherObjectType
will be included in every subgraph schemas. Is this behavior expected?
EDIT 2: Here is an example based on a NestJS sample: https://github.com/MrSquaare/31-graphql-federation-code-first. I got errors because posts-application
uses non-sharable fields from User
model (which is normal) But I also got errors because somethings-application
uses non-sharable fields from User
model, which is not normal since somethings-application
doesn’t use the User
model
6
Can you please attach the exact issue or error message if you haven't resolved it yet?
Mar 21 at 16:12
@adarsh Here is the error with the example I provided
Error: A valid schema couldn't be composed. The following composition errors were found: Non-shareable field "User.name" is resolved from multiple subgraphs: it is resolved from subgraphs "posts", "somethings" and "users" and defined as non-shareable in all of them
Mar 22 at 8:02
did you figure this out? Im running into the same issue.
Mar 31 at 0:06
@ChrisPawlukiewicz Hello, sorry for the late reply! No sadly I didn't find a way to resolve this…
Apr 15 at 15:26
I found out that the issue is because in the monorepo because the code is included, the type declarations are added. You can see this in your dist.js. I fixed this by excluding those libraries from my dockerfile.
Apr 23 at 20:15