-
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
[Data masking] Warn when passing object to useFragment
/watchFragment
from
that is not identifiable
#12004
[Data masking] Warn when passing object to useFragment
/watchFragment
from
that is not identifiable
#12004
Changes from 5 commits
52eabeb
0ace369
46fefd5
e1fd169
755827f
885be47
fd66d42
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -245,10 +245,17 @@ export abstract class ApolloCache<TSerialized> implements DataProxy { | |
): Observable<WatchFragmentResult<TData>> { | ||
const { fragment, fragmentName, from, optimistic = true } = options; | ||
const query = this.getFragmentDoc(fragment, fragmentName); | ||
const id = typeof from === "string" ? from : this.identify(from); | ||
|
||
if (!id) { | ||
invariant.warn( | ||
"Could not identify object passed to `from` either because the object is non-normalized or the key fields are missing. If you are masking this object, please ensure the key fields are requested by the parent object." | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looking at this, this might be a bit too generic and be hard to find what is triggering this warning. Perhaps we add the fragment name in here as well? Should we also try and differentiate between There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fragment name added in fd66d42 |
||
); | ||
} | ||
|
||
const diffOptions: Cache.DiffOptions<TData, TVars> = { | ||
returnPartialData: true, | ||
id: typeof from === "string" ? from : this.identify(from), | ||
id, | ||
query, | ||
optimistic, | ||
}; | ||
|
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.
This might make sense as a dev-only warning
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.
Dev-only warning added in 885be47