Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When using useReadQuery directly before useQueryRefHandlers, refetch won't update the useReadQuery result #11772

Open
phryneas opened this issue Apr 9, 2024 · 2 comments

Comments

@phryneas
Copy link
Member

phryneas commented Apr 9, 2024

Issue Description

I encountered this over in apollographql/apollo-client-nextjs#258:

  const { refetch } = useQueryRefHandlers(queryRef);
  const { data } = useReadQuery(queryRef);

works, but

  const { data } = useReadQuery(queryRef);
  const { refetch } = useQueryRefHandlers(queryRef);

fails to rerender the page when the refetch finishes.

Link to Reproduction

apollographql/apollo-client-nextjs@3a014a4

Reproduction Steps

No response

@apollo/client version

3.9.10

@jerelmiller
Copy link
Member

Was able to confirm in useQueryRefHandlers tests as well.

phryneas added a commit to apollographql/apollo-client-nextjs that referenced this issue Apr 10, 2024
phryneas added a commit to apollographql/apollo-client-nextjs that referenced this issue May 15, 2024
* ApolloClient: make browser event-replaying logic available in SSR

* RSC preloading mechanism prototype

* fix build, update expected shape

* remove console.log

* progress

* [WIP] queryRef

* tests for both notations

* fix up import

* different resolutions

* test fixups

* integrate `useQueryRefHandlers`

* typings

* fix up test
see apollographql/apollo-client#11772

* merge fixup

* more fixup

* refactor queryRef handling

* add test about referential assumptions

* schema adjustments

* bind `PreloadQuery` to `registerApolloClient`

* move `getClient` into the promise chain

* trigger CI

* adjust shape

* update AC build

* `gql(print(gql`

* pin types

* tweaks

* udpate lockfile

* forbid `nextFetchPolicy` in `PreloadQuery`

* fix up build, bump dep

* use uuid, not useId

* update urls

* disable all kinds of minification

* change transport to events

* simulate GraphQL error, not network error

* use `query` in a test

* undo disabling minification

* add clarifying comment

* Revert "simulate GraphQL error, not network error"

This reverts commit c8a2ad5.

* prevent unhandled promise rejections

* debugging

* Revert "undo disabling minification"

This reverts commit 00585ea.

* test?

* clean up debugging things

* update dependencies

* more version pinning

* update lockfile even more

* also update `react-server-dom-webpack`

* adjust react version for vite-streaming

* TransportedQueryRef: inherit QueryReferenceBase

* split `TransportedQueryReference` type

* queryOptions as props on `PreloadQuery`

* Update packages/client-react-streaming/src/DataTransportAbstraction/WrappedApolloClient.tsx

Co-authored-by: Jerel Miller <jerelmiller@gmail.com>

* adjust generic name and comment

* change to QueryRef base type

* rename command to match parent project

* update dependency "@apollo/client": "^3.10.4"

---------

Co-authored-by: Jerel Miller <jerelmiller@gmail.com>
@Antti-Kaikkonen
Copy link

I encountered the same bug with the fetchMore function from useQueryRefHandlers.

The difficulty in finding it was that the bug doesn't appear when running the development server from Create React App, but it does occur in the production build.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants