relay: V11 fetchPolicy are ignored on useLazyLoadQuery no request fired always cached data used...

Behaviour

On new V11 the behavior of fetchPolicy is different compared to prev. relay experimental mode… Looks like it always used cached data…

For example with policy fetchPolicy: "store-and-network" or fetchPolicy: "network-only" data gets loaded from cache and no network request is fired and that is compared to experimental mode wrong…

tested with useLazyLoadQuery

  const data = useLazyLoadQuery<AssignedDetailUserEventsQuery>(
    AssignedDetailUserEventsQueryTag,
    {
      gql_id: initialAssignedId,
    },
    {
      fetchPolicy: "network-only"
    }
  );

More info:

  • There is no network layer cache (only Relay store cache) !
  • Working with experimental : 0.0.0-experimental-4c4107dd ( last half year I had no problems with any version)

Versions

Relay 11.0.0 React": “0.0.0-experimental-8af27aeed”,

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Reactions: 12
  • Comments: 17 (4 by maintainers)

Most upvoted comments

Any news on this ?

useLazyLoadQuery is one of the most used hook in relay and it isn’t working.

Same issue here

@jstejada I have a kind of similar situation, using fetchKey with network-only triggers a fetch as you mention above. BUT it is returning cached data if the query contains a @defer, it seems like running store-and-network. For example, the server will send data in the @defer after 5 seconds but the component receives the cache in the meantime.

This effect is not visible if the store has not cache, for example using gcReleaseBufferSize: 0. Then a call is trigger in each re-mount and fetchKey change, and deferred data is pending until send by the server. Therefore, I guess that it might be related to a broken fetchPolicy handling.

Relay v12

query dummyQuery {
  metasyntactic {
    foo
    ...dummyFragment @defer
  }
}

fragment dummyFragment on Metasyntactic {
  bar
  baz
}