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

Query results are merged together even when parameters are different #12235

Closed
Tam opened this issue Dec 18, 2024 · 3 comments
Closed

Query results are merged together even when parameters are different #12235

Tam opened this issue Dec 18, 2024 · 3 comments
Labels
🏓 awaiting-contributor-response requires input from a contributor ℹ needs-more-info Needs more information to determine root cause

Comments

@Tam
Copy link

Tam commented Dec 18, 2024

Issue Description

I have two queries that get different data from the same endpoint:

query {
    departments: options(condition: { type: department }) {
        nodes {
            id
            label: name
            value: id
        }
    }
    jobTitles: options(condition: { type: job_title }) {
        nodes {
            id
            label: name
            value: id
        }
    }
}

When I output the data data.departments and data.jobTitles both show the same data, with their results merged.

We're using the InMemoryCache and @apollo/experimental-nextjs-app-support version 0.11.7

Link to Reproduction

N/A

Reproduction Steps

Try to query data from the same endpoint with different parameters in a single query.

@apollo/client version

3.12.2

@jerelmiller
Copy link
Member

Hey @Tam 👋

What do your type policies look like? These should write to separate cache keys as long as you haven't set keyArgs to false, otherwise they will get merged into the same cache key. Can you check the cache and see what it looks like after you execute this? You can either use the devtools browser extension or log it to the console with client.extract()

@jerelmiller jerelmiller added ℹ needs-more-info Needs more information to determine root cause 🏓 awaiting-contributor-response requires input from a contributor labels Dec 18, 2024
@Tam
Copy link
Author

Tam commented Dec 19, 2024

@jerelmiller Ah, yep, we had a pagination function that was setting keyArgs incorrectly. Thanks for your help!

@Tam Tam closed this as completed Dec 19, 2024
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏓 awaiting-contributor-response requires input from a contributor ℹ needs-more-info Needs more information to determine root cause
Projects
None yet
Development

No branches or pull requests

2 participants