-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Conversation
@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/ |
👷 Deploy request for apollo-client-docs pending review.Visit the deploys page to approve it
|
|
There was a problem hiding this 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!!!
Modified the changes as per the suggestions
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. |
There was a problem hiding this comment.
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?
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 :) |
Changes are implemented in the following doc.
https://github.com/apollographql/apollo-client/blob/main/docs/source/caching/cache-configuration.mdx
Checklist: