-
Notifications
You must be signed in to change notification settings - Fork 275
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Do not override concrete type names with interface names when merging responses #6250
Conversation
✅ Docs Preview ReadyNo new or changed pages found. |
This comment has been minimized.
This comment has been minimized.
CI performance tests
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this potentially needs to live in the same place as .deep_merge
implementation currently lives.
Do you know whether or not there are any performance implication for this change?
when using interfaceObject, the planner is supposed to provide the input_rewrites and output_rewrites fields in fetch nodes to indicate how the typename field has to change. Before merging this, could it be that you found a case where the planner did not provide it? |
I'm not familiar with the rewriting, would you be able to explain a bit more how this works? I'm not sure it would work in the situation this PR addresses because the type name and the data are being fetched separately in parallel nodes, but the problem only seems to surface when the client explicitly requests the typename for an entity. |
…event interface overwrites
Those query plan fields won't help in this case. To elaborate:
The problem is that we've encountered query plans where, even though the interface- The fix in this PR is to avoid clobbering the correct |
When using
@interfaceObject
, the planner can request an object's concrete__typename
in parallel with its data. If the data comes back with an interface name, and the router receives it after receiving the concrete name, the existing implementation will overwrite the concrete name with the interface name. The downstream result is that the router will nullify any data paths with a__typename
that doesn't correspond to a concrete type in the schema.This fix makes the response merging type-aware. For any field which isn't a type name, we follow the existing deep merge logic for JSON values. If we are merging two instances of
__typename
, this now checks the schema to see if the existing type is an implementer or subtype of the incoming type. If it is, we do not overwrite it with the more generic type. If the existing type is not a descendant of the incoming one, such as when they are unrelated, we overwrite it with the incoming one as usual.Checklist
Complete the checklist (and note appropriate exceptions) before the PR is marked ready-for-review.
Exceptions
Note any exceptions here
Notes
Footnotes
It may be appropriate to bring upcoming changes to the attention of other (impacted) groups. Please endeavour to do this before seeking PR approval. The mechanism for doing this will vary considerably, so use your judgement as to how and when to do this. ↩
Configuration is an important part of many changes. Where applicable please try to document configuration examples. ↩
Tick whichever testing boxes are applicable. If you are adding Manual Tests, please document the manual testing (extensively) in the Exceptions. ↩