react-apollo-hooks icon indicating copy to clipboard operation
react-apollo-hooks copied to clipboard

partialRefetch as an option

Open jfrolich opened this issue 6 years ago • 3 comments

The partialRefetch option is not available at the moment. Would it be possible to make it available?

More information here: https://www.apollographql.com/docs/react/essentials/queries

jfrolich avatar Apr 10 '19 14:04 jfrolich

Actually not having partial refetch enabled will cause issues if you have mutations that return less attributes than a query. The mutation will actually hang the app. I think for useQuery it's probably good to enable partialRefetch by default (it should be default for Query as well, but Apollo didn't enable the default for backwards compatibility reasons).

jfrolich avatar Apr 12 '19 06:04 jfrolich

Hello @trojanowski! This is actually very necessary functionality according to react-apollo docs:

The default value is false for backwards-compatibility's sake, but should be changed to true for most use-cases.

FWIW linking corresponding code and valuable comment: https://github.com/apollographql/react-apollo/blob/22f8ebf52b26b348d6be905d5b7fbbfea51c1541/src/Query.tsx#L461

brabeji avatar Apr 26 '19 10:04 brabeji

This can be a workaround to manually implement the partialRefetch behaviour.

  // workaround for partialRefetch
  useEffect(() => {
    if (loading) return;
    if (data) return;
    if (error) return;
    // if there's no data, no error or loading, it must be stuck at `partial` state.
    refetch();
  }, [!!data, !!loading, !!error]);

layerssss avatar Dec 15 '19 09:12 layerssss