Infinite recursion possible with defer? #29
-
{
...Frag
}
fragment Frag on Type {
field
...Frag @defer
} I'm probable also missing something in terms of the use case. Why the exception for when defer is true? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
I guess we have a validation rule to prevent fragment cycles, so relaxing this within execution is an easy way to ensure that separately deferred named fragments are deferred/sent the actual requested number of times |
Beta Was this translation helpful? Give feedback.
-
Yes, the idea is to make sure all the deferred fragments get executed and non-deferred fragments don't get de-duped by deferred ones. I think the check needs to be modified so we also don't add deferred fragments to If you skip validation, it is possible for {
hero {
...PersonFragment
}
}
fragment PersonFragment on Person {
friends {
...PersonFragment
}
} I'm not sure how important it is to guard against the additional scenario that defer introduces. It probably could be avoided with more complex logic. |
Beta Was this translation helpful? Give feedback.
Yes, the idea is to make sure all the deferred fragments get executed and non-deferred fragments don't get de-duped by deferred ones. I think the check needs to be modified so we also don't add deferred fragments to
visitedFragments
. I'm going to make this change now.If you skip validation, it is possible for
execute
to recurse infinitely today without defer with a query like this:I'm not sure how important it is to guard against the additional scenario that defer introduces. It probably could be avoided with more complex logic.