-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Enable __token field based on compiler schema config #4347
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
|
Thanks for the quick PR! A few style suggestions. Other than that, my main concern is that we get this tested. Let's ensure we have tests that cover both cases. You can change https://github.com/facebook/relay/blob/d5d1c07d7a44856f82c9a652697e9662a091d4c6/compiler/crates/relay-transforms/tests/refetchable_fragment/mod.rs#LL18C60-L18C67 to build a custom schema config and then use a pattern like this to make it conditional based on a comment in the fixture file. Then please add tests which ensure we cover both cases. Finally, does this introduce a possibility that a type would have neither a an id field or a token field? Do we have validation anywhere to catch that? |
|
I'll look into adding tests for this using a flag like that, thanks for the pointers! |
We still fetch the |
|
Is there a reason this PR hasn't been accepted yet? I'm running into this problem and without editing the generated files, I can't see another way around this until this PR is merged? |
|
Apologies for loosing track of this. Let me import/rebase this and play around with it a bit. |
|
@captbaritone has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
|
Import failed due to this PR being old and our internal tool getting stuck when trying to rebase. I'm going to take these commits, rebase them myself and open a new PR to import. The author info on the commit should remain |
|
Rebased here: #4889 Going to close this PR. We can continue the conversation on that PR. |
…#4347 (#4889) Summary: #4347 Pull Request resolved: #4889 Test Plan: Ran Relay compiler with this config change D68577067 and saw no generated artifact changes. Reviewed By: lynnshaoyu Differential Revision: D68569712 Pulled By: captbaritone fbshipit-source-id: 42fdd4396963fe964a63c3736c236895b81ffde4
This fixes #3941 so that fetchable directive is usable in OSS.
Why is this needed?
fields starting with
__is reserved in the GraphQL spec and since this field isn't part of the spec any attempt of using the field on a server that is spec compliant will result in an error.What changed?
enableTokenFieldconfig option.__tokenfield in refetchable fragment selections based on the config option.How has this been tested?
One could argue we should add a new test asserting the old behavior, I wasn't too sure how to go about adding a special fixture though.
The tests now assert that
__tokenis not being generated.cc @captbaritone