-
Notifications
You must be signed in to change notification settings - Fork 2k
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
fix(gateway): maintain immutability when merging selection sets #4239
fix(gateway): maintain immutability when merging selection sets #4239
Conversation
@trevor-scheer Please take a look at this ASAP. This solves a bug in my previous PR that can lead to data corruption. I discovered this bug when I noticed that cached queryplan data was changing, causing subsequent calls of the same query to fail. I figured this doesn't need a test case since it merely updates the code to follow the design principles. The slight change in the queryplan snapshot also reflects this update, so it implicitly tests that immutability is followed. If you'd like me to write a new explicit test case, however, please let me know. Thanks! |
@trevor-scheer do you have some time to look at this? It's a pretty short change, but it fixes a critical issue where cached data can become corrupted. Please let me know if you have any questions or comments, and I'll be happy to help. |
Hey @jakeblaxon, sorry for the delay on this. A couple questions for you:
Thanks for your vigilance on this! |
Hey @trevor-scheer, I can justify the change to the test as follows: In the query plan, we first fetch all fields that we'll ever need from service A, which includes the animal and color, so that's correct. However, in the Flatten node, we only need the fields from service A that are required by service B. Since we're only querying for I can definitely write a test for this! Will it be adequate to just write multiple Also, I noticed that this PR was just closed out. Can I repoen it, or should I open a new one? Thanks for the help! |
@jakeblaxon This was closed inadvertently and we intend on re-opening it; See #4304 for details. We're waiting for a response from GitHub Support, but we'll take care of re-opening it if they can't trigger something on their end after diagnosing what happened. |
…-when-merging-selection-sets
@trevor-scheer I've added a regression test as you requested. This new test fails for the current main branch but succeeds with this new fix. Please take a look. Thanks! |
This is all wonderful @jakeblaxon. Thank you for additional explanation, and the test case looks great! Would you say this test belongs in the I should be able to land and release this on Monday (tomorrow)! cc @abernix |
@trevor-scheer I put it in the requires test suite because the nested requires logic was the source of the problem, but I'm fine with moving it to the query plan cache as well. I'll let you move to wherever you see fit. Thank you for your help with this! |
This PR fixes an issue with my previous PR that was merged in recently (#4064). In the previous PR, the merging method was updating original FieldNode objects that tied back to the schema, corrupting data across requests. This PR fixes that issue, so that the method now creates a copy of the FieldNode object so as to preserve immutability.