-
Notifications
You must be signed in to change notification settings - Fork 257
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix potential issue with nested
@defer
in non-deferrable case (#2312)
The code handling `@defer` works roughly like this: 1. as we cross a query element (field or spread) with a `@defer`, we remember that we just "entered" a deferred section. 2. as we handle the initial elements within that `@defer`, we notice that we just entered a `@defer`, ignore in which subgraph we were, and instead attempt to "re-enter" subgraphs using a key. 3. if that work, we continue from whichever possible subgraphs we just re-entered. 4. Otherwise, if we can't handle the new element by re-entering a subgraph, then we fall back to "normal" operation and try to handle the element from the original subgraph in which we were before entering the @defer: this correspond to case where we cannot do a router-based-defer due to not having proper @key to do it. The issue however is that we were trying to re-enter subgraphs even when the next element was a fragment. This meant that we re-entered any subgraphs that had a key, but that may exclude the one subgraph in which we previously were. If we get a new `@defer` followed by a field that was only in the "original" subgraph, then we could end up not being able to find that field _even_ when falling back to step 4 above, because we had already re-entered different subgraphs due to the 1st `@defer`. The solution implemented by this commit consists in delaying the subgraph re-entry until we actually get to a field, since this is where we _have_ to re-enter.
- Loading branch information
Sylvain Lebresne
committed
Jan 9, 2023
1 parent
3ba83aa
commit dd641f2
Showing
5 changed files
with
123 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters