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 PMwasyl
10/26/2023, 12:28 PMbod
10/26/2023, 12:29 PMwasyl
10/26/2023, 12:29 PMApolloCall
🤔bod
10/26/2023, 12:31 PMAnd beta.1 failsOk thanks for confirming 🙏
ApolloCall
why do you now need the apply?storePartialResponses
isn't generic, I guess we changed thatwasyl
10/26/2023, 12:35 PMemitCacheMisses
that causes the failureaddExecutionContext
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 endbod
10/26/2023, 12:42 PM