-
Notifications
You must be signed in to change notification settings - Fork 55
simplify missingFieldHandlers #589
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
base: master
Are you sure you want to change the base?
Conversation
c3637c1 to
f8c5ac7
Compare
zth
left a comment
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 appreciate the intention here, I really do, but I'm a bit surprised that it fundamentally breaks the missing field handlers. It makes me worried that:
- We apparently don't have tests for it
- There are even comments above each maker fn explaining exactly why it's structured like it is, but they are neither changed (if this is a correct change) nor taken into account in the edits
Here's the Relay docs for missing field handlers: https://relay.dev/docs/next/guided-tour/reusing-cached-data/filling-in-missing-data/
| nullable<'record>, | ||
| 'args, | ||
| ReadOnlyRecordSourceProxy.t, | ||
| ) => option<dataId>, |
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 don't think this is going to work. Unless something has changed, returning Nullable is required here, or you won't be able to distinguish between null (fetched but no data) and undefined (data not fetched). Same for the plural linked field IIRC.
| switch (record, field.name, args["id"]) { | ||
| | (Value(record), "node", argsId) if record->RecordProxy.getType == storeRootType => argsId |
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.
argsId is no longer turned into an option here...?
|
@zth my bad I first thought that |
Awesome, thank you! This is a peculiar part of the API. I guess if you wanted to you could experiment with a nicer API, like: |
yeah that'd be better, the whole null vs undefined API is very confusing! But looking at the actual usage of missingFieldHandlers, it looks like undefined is only tested against with scalars, otherwise they just check with For scalars, I guess undefined is used for data missing and null when the data exists but is actually What do you think @zth ? |
We should go for whatever is in the docs, even if we interpret the code differently, unless it's super clear that the docs are wrong and the code is right. Here I'd like to stick with what the docs say. But maybe it'd be good if you read through the docs for this particular feature once more, and gave your view on how you interpret it? Maybe I'm interpreting it wrong. |
I'm not saying the docs are wrong, the docs just don't talk at all about the return type of the
Plus they only give examples where @zth I'm really not trying to nitpick on this, if you have any information about handle return types that I missed, don't hesitate! I just don't see what returning |
|
So, to sum up, your interpretation after reading both the docs and the code is:
If so we should go for that, then that's fine. But we should also clean up the comments in the code, if they indicate something differently. Agreed? |
f8c5ac7 to
4d894be
Compare
bfc499f to
1016a5b
Compare
No description provided.