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

fetchMore with fetchPolicy: "no-cache" makes two requests #11965

Closed
username14415 opened this issue Jul 20, 2024 · 6 comments · Fixed by #11974
Closed

fetchMore with fetchPolicy: "no-cache" makes two requests #11965

username14415 opened this issue Jul 20, 2024 · 6 comments · Fixed by #11974
Assignees
Labels

Comments

@username14415
Copy link

username14415 commented Jul 20, 2024

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 version

3.10.8

@alessbell
Copy link
Contributor

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 alessbell added the 🏓 awaiting-contributor-response requires input from a contributor label Jul 23, 2024
@username14415
Copy link
Author

@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).

@github-actions github-actions bot removed the 🏓 awaiting-contributor-response requires input from a contributor label Jul 24, 2024
@jerelmiller
Copy link
Member

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.

@jerelmiller
Copy link
Member

I've got a failing test written for this in #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!

Copy link
Contributor

github-actions bot commented Aug 1, 2024

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.

Copy link
Contributor

github-actions bot commented Sep 1, 2024

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants