-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Lookahead#selects? not matching fragment/type fields #3007
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?
Lookahead#selects? not matching fragment/type fields #3007
Conversation
73e41a7 to
fdbd505
Compare
while also adding a description of `#selects?` and moving some assertions from `#selections`
fdbd505 to
7597939
Compare
|
Hey, yes, you've understood correctly, it's a bug! Do you want to take a crack at fixing it in this PR? |
|
I believe this is because the way selection is implemented (which is called by selected_type is used to find the corresponding field selections. In the case of queries above the selected_type will be "Node". You can get the behavior desired above via: |
|
Coming from here: https://github.com/DmitryTsepelev/graphql-ruby-fragment_cache#limitations Is there a proposed solution? We'd be willing to work on a PR, but not exactly sure where to start |
|
Hey @gsdean , this branch contains example tests but not a fix. Yes, if you want to open a PR with a fix, that'd be great! |
|
I blew the dust off these tests and got them passing, but I'm not sure it's the right implementation. After my changes, a
But they all seem complicated 😖 |
|
I'm also coming from https://github.com/DmitryTsepelev/graphql-ruby-fragment_cache#limitations. I am using that gem to facilitate caching, but because my schema has unions, some parts of my app can't be cached at the moment.
I'm guessing point 2 or 3 would be better than 1, because with solution 1 the |
|
@gsdean FYI I worked around the issue in my app by not using union types, and using interfaces instead. It seemed to mostly work. Unions and interfaces in GraphQL are very similar, so migrating required minimal effort. No changes were needed for the frontend / API consumer, since the |
There seems to be an issue with fields that are selected through fragments or types of a field. While the
selectionsmethod returns the expected list of field names, callingselects?does not return true.For example (extracted from a spec) I need know if the
namefield was requested on either theBirdSpeciesorBirdGenustype.I've added specs for
Lookahead#selects?to demonstrate this. Am I correct that this is a bug, or am I misusing theselects?method?