-
Notifications
You must be signed in to change notification settings - Fork 2.7k
InMemoryCache
: store fields with an empty object of optional arguments the same as fields without arguments
#12370
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
Conversation
…nts the same as fields without arguments
🦋 Changeset detectedLatest commit: 40599b3 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
❌ Docs preview failedThe preview failed to build. Build ID: da8a08760232a3773e0b2cce Errorsreact/data/subscriptions
|
commit: |
✅ Deploy Preview for apollo-client-docs ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
size-limit report 📦
|
@@ -202,7 +202,8 @@ export abstract class EntityStore implements NormalizedCache { | |||
|
|||
public modify( | |||
dataId: string, | |||
fields: Modifier<any> | Modifiers<Record<string, any>> | |||
fields: Modifier<any> | Modifiers<Record<string, any>>, | |||
exact: boolean |
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.
I've opted to add exact
only to our internal api and not expose it.
Userland code can still compare the storeFieldName
and fieldName
values passed into the modifier function to reach this goal, and we should probably not encourage people to write code like
cache.modify(id, {
fields: {
['myField({"complex":....})']() {
/* ... */
},
},
});
in the first place.
There is would be slightly more sane to use
cache.modify(id, {
fields: {
myField(value, { storeFieldName }) {
if (storeFieldName === 'myField({"complex":....})') {
/* ... */
}
},
},
});
instead.
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.
Looks good to me!
Co-authored-by: Jerel Miller <[email protected]>
3ca1179
to
40599b3
Compare
|
Fixes #12365
Fixes #8853