wasyl
10/26/2023, 11:47 AM@include
directive is handled: when I have two fragments on the same type, and I @include(if: false)
one of them, then the whole query doesn't return from the cache. Quick outline:
query Foo(doInclude: Boolean!) {
foo {
bar {
...firstFragmentOnBar
...secondFragmentOnBar
...thirdFragmentOnBar@include(if: doInclude)
}
}
}
fragment firstFragmentOnBar on Bar {
fieldforFirstFragment { ... }
}
fragment secondFragmentOnBar on Bar {
fieldforSecondFragment { ... }
}
fragment thirdFragmentOnBar on Bar {
fieldforThirdFragment { ... }
}
with the above when I observe Foo(false)
from the cache, and another query refreshes it, then the first cache-only query doesn't emit proper data. I was pretty confused since I did see data in the normalized cache, there was no error or anything. I feel it's a bug because when I move the @include
inside the fragment, it works as expected
query Foo(doInclude: Boolean!) {
foo {
bar {
...firstFragmentOnBar
...secondFragmentOnBar
...thirdFragmentOnBar
}
}
}
fragment firstFragmentOnBar on Bar {
fieldforFirstFragment { ... }
}
fragment secondFragmentOnBar on Bar {
fieldforSecondFragment { ... }
}
fragment thirdFragmentOnBar on Bar {
fieldforThirdFragment@include(if: doInclude) { ... }
}
Am I wrong assuming the first variant is correct and should work? Or perhaps there's a subtle difference that makes the two not equivalent? Please let me know if you need more details and I'll try making a self-contained repro πbod
10/26/2023, 11:55 AMwasyl
10/26/2023, 12:16 PMbod
10/26/2023, 12:17 PMbod
10/26/2023, 12:18 PMwasyl
10/26/2023, 12:28 PMbod
10/26/2023, 12:29 PMwasyl
10/26/2023, 12:29 PMApolloCall
π€wasyl
10/26/2023, 12:30 PMbod
10/26/2023, 12:31 PMAnd beta.1 failsOk thanks for confirming π
bod
10/26/2023, 12:31 PMApolloCall
why do you now need the apply?bod
10/26/2023, 12:34 PMstorePartialResponses
isn't generic, I guess we changed thatwasyl
10/26/2023, 12:35 PMwasyl
10/26/2023, 12:36 PMemitCacheMisses
that causes the failurewasyl
10/26/2023, 12:36 PMwasyl
10/26/2023, 12:37 PMaddExecutionContext
so it doesn't return T
πStylianos Gakis
10/26/2023, 12:39 PMbod
10/26/2023, 12:40 PMwasyl
10/26/2023, 12:41 PMapolloClient.query(operation)
. In any case I was confused with wrapper types and thought they changed in v4 but I was looking at old code π It's just the emitCacheMisses
inferred type in the endwasyl
10/26/2023, 12:42 PMbod
10/26/2023, 12:42 PMbod
10/26/2023, 12:43 PM