You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi there, Just passing through, I'm not a maintainer of gqlgen, but I know a thing or two about Federation.
You need to invert your type extension. If I understand correctly, the end goal is to add Author to Review?
Adding a field to a type always needs to be done by the service that knows about the data that is to be added.
So, in this case, Service B is presumably the one that provides all the Author data, it needs to be the Service that adds the field to Review, not Service A, which knows nothing about authors.
In your gqlgen entity resolver, you should be able to pass the autherId or slug or whatever your using to resolve the author field.
@farawaysouthwest Hi! Thanks for your answer. Yep, this approach should work.
But resolving entity directly by ID (Not by attaching field to the parent entity "Review") also should be available in such federations.
I already had experience with such approach but now it doesn't work for some reason
What happened?
I’m trying to setup communication via GQL federation between two services.
Service A
serves reviews andservice B
resolves review's author by ID.Getting an error when trying to resolve
nil
extended entityAuthor
For some reason, federation (or gqlgen?) trying to resolve a
nil
valueAuthor
What did you expect?
When I return
nil
Author
(in service A), resolverFindAuthorBySlug
(in service B) ignores it and doesn't try to resolve thenil
value.Minimal graphql.schema and models to reproduce
GraphQL schema (Service A)
GraphQL schema(Service B)
FindAuthorBySlug resolver (generated by gqlgen in Service B)
Reviews resolver (generated by gqlgen in Service A)
Code, where error happened
versions
The text was updated successfully, but these errors were encountered: