You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a new issue in beta.53 as a result of c810713
With this code:
typePolicies: {
Query: {
fields: {
pokemon(existingData, { args, toReference }) {
return existingData || toReference({ __typename: 'Pokemon', id: args?.id });
}
}
},
...
const PokemonFields = `
fragment PokemonFields on Pokemon {
id
number
name
classification
types
resistant
weaknesses
fleeRate
maxCP
maxHP
image
}`
// FRAGMENT BASED QUERY
let FRAGMENT_POKEMON_QUERY = gql`
${PokemonFields}
query pokemon($id: String) {
pokemon(id: $id) {
...PokemonFields
}
}
`;
Intended outcome:
When using a read type policy and a query containing a fragment with a cache* fetchPolicy, when the cache misses, return null for the result instead of an empty object.
most likely directly related to 1, cache-first needs to make a network call to fetch the data if the initial cache search missed.
Actual outcome:
If cache-only, or cache-and-network, the returned pokemon is an empty object on renders until the cache hits.
If cache-first and the cache missed, the returned pokemon is an empty object on all renders, and a network call never gets made.
If the query does not use a fragment, or the fetchPolicy is network-only, the returned pokemon will be null on all renders until the cache hits or the network call returns with data. I believe this is the expected behavior.
As a result of the above behavior, depending on the fetchPolicy and whether a fragment is embedded, the result object can now be either null, or an empty object.
…cts"
This reverts commit c810713, introduced
recently in PR #6365. My optimism that #6365 was an improvement seems to
have been misplaced, since it caused the regression reported in #6368.
We're too close to the AC3 RC/release to be floating risky changes like
these without compelling justifications.
…cts" (#6371)
This reverts commit c810713, introduced
recently in PR #6365. My optimism that #6365 was an improvement seems to
have been misplaced, since it caused the regression reported in #6368.
We're too close to the AC3 RC/release to be floating risky changes like
these without compelling justifications.
@jebonfig This should be fixed in the latest beta (-bets.54). Thanks for catching this regression so quickly, and sorry for any inconvenience it caused.
This is a new issue in beta.53 as a result of c810713
With this code:
Intended outcome:
When using a read type policy and a query containing a fragment with a
cache*
fetchPolicy, when the cache misses, returnnull
for the result instead of an empty object.most likely directly related to 1,
cache-first
needs to make a network call to fetch the data if the initial cache search missed.Actual outcome:
If
cache-only
, orcache-and-network
, the returnedpokemon
is an empty object on renders until the cache hits.If
cache-first
and the cache missed, the returnedpokemon
is an empty object on all renders, and a network call never gets made.If the query does not use a fragment, or the fetchPolicy is
network-only
, the returnedpokemon
will benull
on all renders until the cache hits or the network call returns with data. I believe this is the expected behavior.As a result of the above behavior, depending on the
fetchPolicy
and whether a fragment is embedded, the result object can now be eithernull
, or an empty object.How to reproduce the issue:
Repro here: https://github.com/jebonfig/react-apollo-error-pokemon
Versions
The text was updated successfully, but these errors were encountered: