-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
RANGE_ADD - Better warning messages when new edge is missing #574
Conversation
'update the `RANGE_ADD` mutation config?', | ||
config.edgeName | ||
); | ||
if (operation.getNodeByFieldName(config.edgeName)) { |
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.
use operation.getFieldByStorageKey(config.edgeName)
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.
ah of course. Updated the PR!
db91128
to
e8da871
Compare
Thank you!!! ❤️ |
@josephsavona @kassens any comments on this ? Would be helpful to add that in 👯 |
Thanks for your patience on this. It's taken us a long time to get to it, I know. Here's what we're thinking. To recap, these are two distinct cases.
|
e8da871
to
11b82be
Compare
@steveluscher sorry for the wait, (finals week 😪) I have updated the PR with what you have recommended. I make the check in Should this be an invariant or keep it as a warn ? Let me know if this is what you had in mind! |
@@ -242,6 +243,21 @@ var RelayMutationQuery = { | |||
} | |||
} | |||
} | |||
|
|||
// Warn if the newly created edge was not included in mutatedFields | |||
const edgeField = mutatedFields.find(field => { |
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.
Instead, how about moving this to an else
clause at line 225? Note that mutatedEdgeFields
is only empty if no range behaviors matched and the new edge field would be missing.
Thanks for updating this! We should also remove the warning in |
Shouldn't we keep the current warning in the case where the server is not returning the newEdge ? |
We should keep warning if the server doesn't return the edge, but only if we asked for the edge and didn't get it. The warning currently still occurs even if no range behaviors matched. |
11b82be
to
65d9b78
Compare
Ah you're right! Updated the PR to address your comments. |
65d9b78
to
08300ad
Compare
parentID: '123', | ||
edgeName: 'feedbackCommentEdge', | ||
parentName: 'feedback', | ||
rangeBehaviors, |
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.
nit: i suspect you borrowed this from other test cases in this file, but it would make the test more self-contained and readable if we were explicit about the range behaviors, e.g rangeBehaviors: {}
.
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.
Much clearer that way!
A few more nits, but otherwise this looks great :-) |
08300ad
to
6a5f0c3
Compare
Thanks for your patience, @xuorig. We just went over this internally, and I'd like to share a summary of our discussion. I wrote:
What if we changed the warning to indicate that the entire connection has been refetched and that the developer can't expect optimistic mutations to work, with a little bit about how to write a more efficient and optimism-compatible mutation. Something like:
The only problem here is that there's no way for the developer to squelch this warning if their desired behavior was to refetch the connection. Thoughts, @yuzhi @xuorig @yungsters? |
I discussed with @yuzhi a bit. Currently, setting a range behavior configuration to We can add a |
Correct me if I'm wrong but If the desired behavior was to refetch the connection, why would there be a
That would definitly help remove any ambiguity about the behavior. |
A |
@steveluscher @yungsters I propose that we change the warning message to something like @steveluscher proposed, where we clearly state which connection wasn't found in the rangeBehaviors. In another PR we can address the |
6a5f0c3
to
8cf11df
Compare
…hes no range behavior
8cf11df
to
8a7a26c
Compare
I have modified the PR with the message @steveluscher proposed. I think this might be a good first step to clear up the small confusion people have with |
@facebook-github-bot import |
Thanks for importing. If you are an FB employee go to Phabricator to review. |
cde735b
Summary:As discussed in #574, #542 Introduce 2 new range behaviors: - `REFETCH`: Will refetch the entire connection (to squelch the warning when no `rangeBehavior` matches the tracked connection) - `IGNORE`: Replaces using null, means the range should not be refetched at all. I've deprecated `null`, maybe we don't need to, what do you think ? yungsters steveluscher let me what you think! ? Closes #945 Reviewed By: josephsavona Differential Revision: D3117256 Pulled By: wincent fb-gh-sync-id: e7b5ab2fe6beebcd53f400a62634a7cd5aae383b fbshipit-source-id: e7b5ab2fe6beebcd53f400a62634a7cd5aae383b
Possible improvement for #542
Lot's of issues and misunderstanding with that one, range add mutations can be confusing with the current warning messages.
Better solution as @steveluscher said:
In
handleRangeAdd
, if the edge is missing from the payload, check if the operationRelayQueryMutation
contained the newEdge field. If it didn't, it means the new edge was not included because it wasn't in the intersection of the tracked/fat query. If it did, it means the server should've returned that field and didn't.I've added a function
getNodeByFieldName
to check if the operation contained the field to get the new edge. Not sure if it is the best way to check that, let me know.The actual warning messages probably need some work, let me know what you think would be the best messages for these cases.