Closed username14415 closed 3 months ago
Hi there @username14415 👋 Unfortunately, without a reproduction there's not much I do to help. If you're able to create one, I'd be happy to take a look.
@alessbell
const GET_MESSAGES = gql query GetMessages($slug: String!, $offset: Int) { getMessages(slug: $slug, offset: $offset) { id content } }
const { fetchMore } = useQuery(GET_MESSAGES, { fetchPolicy: "no-cache", variables: { slug: "example-slug } });
const fetch = await fetchMore({ variables: { offset: 123 }});
Using fetchMore
with "fetchPolicy: "no-cache"
shows 2 requests. The requests are visible on the backend.
The first request has my own set variables (in this case offset: 123 and default variable slug). The second request has only default variable (slug).
Hey @username14415 👋
I believe I'm able to reproduce this. Check out this reproduction which shows the multiple requests. I see the 2nd request kicked off after the first resolves. It helps to open this up the app in a separate window: https://y37kx4-3000.csb.app/. For whatever reason console logs are duplicated in the split view version giving a false sense of what is happening.
I've got a failing test written for this in https://github.com/apollographql/apollo-client/pull/11974. I've discovered some deeper issues with this as well that I think we need to discuss as a team, so I'm going to leave this in draft for now. Thanks for reporting the issue!
Do you have any feedback for the maintainers? Please tell us by taking a one-minute survey. Your responses will help us understand Apollo Client usage and allow us to serve you better.
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. For general questions, we recommend using StackOverflow or our discord server.
Issue Description
fetchMore useQuery with fetchPolicy: "no-cache" just makes two requests. One with variables and the second request is with default variables. I can't post a link to reproduction, the requests are visible on the backend. NextJS 14.2 dev mode.
Link to Reproduction
-
Reproduction Steps
const { loading, fetchMore } = useQuery(GET_MESSAGES, { fetchPolicy: "no-cache", onCompleted: handleCompleted, onError: handleError, variables: { slug: params.slug, }, });
@apollo/client
version3.10.8