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

fix(documentation): use correct query names in partial example #11625

Merged
merged 3 commits into from
Feb 27, 2024

Conversation

andreasottosson-polestar
Copy link
Contributor

Correct name of query in example. These are supposed to be the same right?

GET_DOG_QUERY_PARTIAL -> PARTIAL_GET_DOG_QUERY

Correct name of query GET_DOG_QUERY_PARTIAL -> PARTIAL_GET_DOG_QUERY
@apollo-cla
Copy link

@andreasottosson-polestar: Thank you for submitting a pull request! Before we can merge it, you'll need to sign the Apollo Contributor License Agreement here: https://contribute.apollographql.com/

Copy link

netlify bot commented Feb 27, 2024

Deploy Preview for apollo-client-docs ready!

Name Link
🔨 Latest commit a951b41
🔍 Latest deploy log https://app.netlify.com/sites/apollo-client-docs/deploys/65ddc34241b1a8000875d995
😎 Deploy Preview https://deploy-preview-11625--apollo-client-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

changeset-bot bot commented Feb 27, 2024

⚠️ No Changeset found

Latest commit: a951b41

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Update name used in useSuspenseQuery
@andreasottosson-polestar andreasottosson-polestar changed the title Correct partial query names in suspense.mdx fix(documentation): use correct query names in partial example Feb 27, 2024
@phryneas
Copy link
Member

Hi Andreas!

That's actually not the intention behind that example.
GET_DOG_QUERY_PARTIAL is only used to write partial data to the cache.

The point of the example is to show that you can use GET_DOG_QUERY (which is defined further up in the page) in combination with returnPartialData to get something out of the cache, even if not all the necessary data is there yet. (In the example, breed is missing from the cache).

This is GET_DOG_QUERY from further up the page:

export const GET_DOG_QUERY: TypedDocumentNode<
  DogData,
  Variables
> = gql`
  query GetDog($id: String) {
    dog(id: $id) {
      id
      name
      breed
    }
  }
`;

As there is nothing to change here, I'm going to close this PR - thank you for keeping an eye out for possible inconsistencies in the docs and filing a PR, though!

@phryneas phryneas closed this Feb 27, 2024
@andreasottosson-polestar
Copy link
Contributor Author

@phryneas Thanks for clarifying. At first I did not change the GET_DOG_QUERY on line 276, should have left that one. But it was the first two queries in the Partial example code that I noticed at first.

This part, are they not supposed to be the same? PARTIAL_GET_DOG_QUERY vs GET_DOG_QUERY_PARTIAL. GET_DOG_QUERY_PARTIAL is undefined here if i'm not missing something else.

const PARTIAL_GET_DOG_QUERY: TypedDocumentNode<
  PartialData,
  Variables
> = gql`
  query GetDog($id: String) {
    dog(id: $id) {
      id
      name
    }
  }
`;

// Write partial data for Buck to the cache
// so it is available when Dog renders
client.writeQuery({
  query: GET_DOG_QUERY_PARTIAL,
  variables: { id: "1" },
  data: { dog: { id: "1", name: "Buck" } },
});

@phryneas
Copy link
Member

phryneas commented Feb 27, 2024

Ah, good catch - GET_DOG_QUERY_PARTIAL and PARTIAL_GET_DOG_QUERY should be the same there, you're right!

@phryneas phryneas reopened this Feb 27, 2024
@phryneas phryneas merged commit 9dc45bb into apollographql:main Feb 27, 2024
16 of 19 checks passed
@phryneas
Copy link
Member

Thank you again :)

@andreasottosson-polestar
Copy link
Contributor Author

No problem at all :) Thank you!

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

Successfully merging this pull request may close these issues.

None yet

3 participants