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

Added 'Customizing Type Policies' Segment in cache-configuration.mdx #10933 #10967

Merged
merged 9 commits into from
Sep 14, 2023

Conversation

sahilmanchanda1999
Copy link
Contributor

Changes are implemented in the following doc.
https://github.com/apollographql/apollo-client/blob/main/docs/source/caching/cache-configuration.mdx

Checklist:

  • If this PR contains changes to the library itself (not necessary for e.g. docs updates), please include a changeset (see CONTRIBUTING.md)
  • If this PR is a new feature, please reference an issue where a consensus about the design was reached (not necessary for small changes)
  • Make sure all of the significant new logic is covered by tests

@apollo-cla
Copy link

@sahilmanchanda1999: 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/

@netlify
Copy link

netlify bot commented Jun 12, 2023

👷 Deploy request for apollo-client-docs pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 23aac85

@changeset-bot
Copy link

changeset-bot bot commented Jun 12, 2023

⚠️ No Changeset found

Latest commit: 23aac85

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

@jerelmiller jerelmiller linked an issue Jun 12, 2023 that may be closed by this pull request
@jerelmiller jerelmiller self-assigned this Jun 12, 2023
Copy link
Member

@jerelmiller jerelmiller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @sahilmanchanda1999 👋

Thanks so much for the PR! I've included some suggestions for you. Would you mind taking a look? We'd love to get this merged. Thanks so much!!!

docs/source/caching/cache-configuration.mdx Outdated Show resolved Hide resolved
docs/source/caching/cache-configuration.mdx Outdated Show resolved Hide resolved
docs/source/caching/cache-configuration.mdx Outdated Show resolved Hide resolved
docs/source/caching/cache-configuration.mdx Outdated Show resolved Hide resolved
docs/source/caching/cache-configuration.mdx Outdated Show resolved Hide resolved
Comment on lines +253 to +257
The code creates an `InMemoryCache` with a custom type policy for the `Person` type. The type policy specifies that if the `name` field is not available in the cache, it should return a default value of "UNKNOWN NAME" and converts it to uppercase.

Then, the code adds an additional type policy to the cache using `cache.policies.addTypePolicies`. This new type policy is related to the `Person` type and its `email` field. The custom read function specifies that if the email field is not available in the cache, it should return a default value of "[email protected]".

Overall, the code sets up caching behaviors for the `Person` type, ensuring that default values are provided for the `name` and `email` fields if they are not present in the cache.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@StephenBarlow would you mind taking a look at this section and provide any suggestions you may have?

@phryneas phryneas requested a review from a team as a code owner September 14, 2023 13:32
@phryneas
Copy link
Member

Since we got another question for this in #11218, I'm going to merge this now - thanks a lot for the PR!

@Meschreiber It would be great if you could take a look at this anyways - if you have wording suggestions, we can still do another PR to get those in :)

@phryneas phryneas merged commit ae2651a into apollographql:main Sep 14, 2023
4 checks passed
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

document addTypePolicy
4 participants