-
Notifications
You must be signed in to change notification settings - Fork 645
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
Fix Missing Referenced Fragments in Query Document #2647
Fix Missing Referenced Fragments in Query Document #2647
Conversation
@tylerbwong: Thank you for submitting a pull request! Before we can merge it, you'll need to sign the Apollo Contributor License Agreement here: https://contribute.apollographql.com/ |
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.
Nice catch, Thanks a lot!
@martinbonnin |
Thanks for digging into this! Looking at this code made me realise two things:
Let me know if you want to look into this as part of this PR or I can look into it in a follow up PR. |
I'll look into both issues as part of this PR! |
@@ -188,6 +195,21 @@ class IRBuilder(private val schema: IntrospectionSchema, | |||
return usedTypes | |||
} | |||
|
|||
private fun List<FragmentRef>.referencedRootFragmentNames(operationType: String, fragments: List<Fragment>, filePath: String): Set<String> { |
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.
Mostly nitpicking at this point but it feels a bit "off" that we need a special case for the root fragmentsRefs compared to field.fragmentRefs
. What about moving the schema.rootTypeForOperationType(operationType)
to the call site and re-using List<FragmentRef>.findFragments
?
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 nice catch. A lot of code here ended up being mostly duplicated from List<FragmentRef>.findFragments
and I didn't even realize. Will refactor! I think I'll keep this function here though since we still need to do some extra lookups for all the nested fragments inside the root fragment.
|
||
fragment | ||
} | ||
} | ||
|
||
private fun Fragment.validateTypeCondition(fragmentRef: FragmentRef, typeCondition: String, filePath: String) { |
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.
👍
So after looking into supporting root inline fragments, I was able to add |
That sounds good 👍 , thanks again ! Re: inline fragment, I didn't realise this would require big changes to the codegen. That's an area that's changing considerably in version 3.0.0 so we might want to implement that in the
In all cases, feel free to ignore the java codegen for the time being as it's currently removed from |
Fixes #2644.