Returning null for an entity without extensions error property #1171
-
Hi, I'm using entities in my federated graph and I'm trying to return
When I query the subgraph that defines the entity directly (Address subgraph in this example), this is no issue and returns
It's like when going through the externalRef it still tries to resolve the entities fields even though in the referenceResolver I'm returning I thought it was because I didn't have Any suggestions on how to do this without also getting the |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
I can't tell for sure can you share more details of your setup? For the query that fails, what does.the resolver for the address field return, and what does the the resolveEntity in the graph that implements Address get called with, and what does it return? |
Beta Was this translation helpful? Give feedback.
-
Yeah for sure, let me see if I can clarify a bit better. So for this example using User and Address subgraphs, it would look like this: Address subgraph:
User subgraph:
If I run my
And there is no
I just can't seem to figure out how to get that |
Beta Was this translation helpful? Give feedback.
-
In this example, if I were to do the same query to the Address subgraph directly:
And the
That |
Beta Was this translation helpful? Give feedback.
I think this is just how Federation works, your User graph is returning an Address not null, so at that point the router thinks the User has an address, and failing to load it is an Error.
The way to avoid this is to invert the relation and move the User.address field to the Address sub-graph