Similarly to #562, when we activate batching with shouldBatch, variables only used in directives are not injected correctly in the merged query.
For instance, let's say I'm performing the following query:
query SomeQuery($assertion: Boolean!) {
fieldTrue @include(if: $assertion)
fieldFalse @skip(if: $assertion)
}
it will be rendered in the batch query the following way:
query ___composed($___SomeQuery___requestIndex_1___assertion: Boolean!) {
___SomeQuery___requestIndex_0___fieldIndex_0: fieldTrue @include(if: $assertion)
___SomeQuery___requestIndex_0___fieldIndex_1: fieldFalse @skip(if: $assertion)
}
Resulting in the following error:
Variable "$assertion" is not defined by operation "___composed".
I'll try to take a look at it, if I find something, let's do a PR!
But believe me, once I'm able to activate batching in my codebase, trust me, that means the feature is really stable, I have all of the twisted scenarios you can expect! 馃槅
Yeah, this can be fixed pretty easily by looking into directives within renameVariables inside queries/queryMerging.ts. The number of edge cases on this query merging thing is pretty staggering.
@Poincare pretty busy right now but will do when I have time, thanks for the pointers!
@Poincare patch in #584
Most helpful comment
Yeah, this can be fixed pretty easily by looking into directives within
renameVariablesinsidequeries/queryMerging.ts. The number of edge cases on this query merging thing is pretty staggering.