-
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
Fragment variables fix #4373
Fragment variables fix #4373
Conversation
@GreenGremlin: Thank you for submitting a pull request! Before we can merge it, you'll need to sign the Meteor Contributor Agreement here: https://contribute.meteor.com/ |
3c0d42b
to
c675f7d
Compare
I've signed the contributor agreement. Is there anything else I can do to help get this merged? |
7371fa9
to
bc852c5
Compare
@benjamn how do you feel about catching the "Invalid variable referenced" error and ignoring it, when no variables object has been passed in? |
bc852c5
to
80e5878
Compare
Is there anything I can do to help get this merged? |
It looks like invariant error messages are now stripped in production builds, so this fix will no longer work. |
I updated my change so that it will work without the invariant message. |
1902939
to
f753672
Compare
I refactored my fix so that the functionality of graphql-anywhere's |
It would be great to hear from the Apollo team on this PR. I've invested quite a bit of time to come up with a very backwards compatible fix. |
Thanks for working on this @GreenGremlin. The only test in your PR that fails against fragment foo on Foo {
alias: name
height(unit: METERS)
avatar @include(if: $foo) {
square
}
} is filtered against this data: const data = {
alias: 'Bob',
name: 'Wrong',
height: 1.89,
avatar: {
square: 'abc',
circle: 'def',
triangle: 'qwe',
},
}; it should ignore the {
alias: 'Bob',
height: 1.89,
avatar: {
square: 'abc',
},
} I'm not sure I agree with this. If you try this on Instead of adjusting the code to essentially nullify defined directives, I'm wondering if a better option here would be to adjust filter(fragmentWithAVariable, data, { foo: true }); would bring back the expected filtered data, without an error. Let me know your thoughts. Again I'm just a bit concerned that with your changes we'd be essentially providing a way for |
@hwillson, good call! I've updated |
@hwillson how would you feel about also updating |
I went ahead and made the update to add a Here are some use cases that I'm not quite sure how to handle:
The only option I can think of, for these scenarios, is to pass Also, I'd like to document the |
Sorry to be a pest, but I'd love to see this merged, if possible. Let me know if there's anything else I can do to help move it along. |
9fa012e
to
387347d
Compare
@hwillson could I please get an update on where this PR stands? It's pretty disheartening to put the work in and not hear back. |
…when mapPropsToVariables is not passed
a8e3db7
to
0919eee
Compare
Also shaved a few more bytes in getInclusionDirectives and shouldInclude.
Sorry for the delay here @GreenGremlin, and thanks very much for working on this! We'll have this merged shortly. |
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.
Thanks very much for working on this @GreenGremlin!
Currently, the graphql-anywhere
graphql
function always tries to rectify directives, even when it's being used to walk a fragment to generate propTypes or filter result data. This change updatesfilter
andcheck
(used bypropType
) to pass anull
value for the variable mapping. The change also updates thegraphql
function'svariableValues
argument to default to an empty map, which is how it currently functions, when no value is passed. This allows thegraphql
function to function exactly as it currently does, for pretty much every scenario. Except, if nullvariableValue
is explicitly passed it will not process @include and @Skip directives.I think this is the best possible fix for handling fragments with variable directives.
Checklist:
Fixes #4372