federation icon indicating copy to clipboard operation
federation copied to clipboard

fix: owned types are marked as extension when GraphQL `v16` is used

Open Gamote opened this issue 3 years ago • 10 comments

This PR is meant to fix the issues in which types are wrongly set as extensions when GraphQL v16 is used.

Issue printSubgraphSchema.ts:190 (@apollo/subgraph) checks if the extensionASTNodes field is defined in order to determine if a type should be extended or not. GraphQL v15 sets it as undefined while GraphQL v16 always includes extensionASTNodes in all GraphQLObjectType as [].

Fix I order to fix this we had to also check the length of the array, not only just if it's defined.

This will also fix: #2029.

Let me know if you need more details. We will provide any information in order to speed up the process of releasing the fix as this is a major issue for consumers that are using Federation.

Gamote avatar Feb 24 '22 14:02 Gamote

@Gamote: 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/

apollo-cla avatar Feb 24 '22 14:02 apollo-cla

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

codesandbox-ci[bot] avatar Feb 24 '22 15:02 codesandbox-ci[bot]

On second thought, given that this change is targeting a v15/v16 incompatibility, this PR should be opened against the version-0.x branch. The 0.x versions of federation packages claim support for both v15 and v16 versions of graphql (and also run build and test against v15 as well). The main line (which represents federation 2) of this repo only claims support for v16.

I was pretty curious to see if there were any issues so I cherry-picked your commits over to a branch on top of version-0.x and it all looks good! You're welcome to use it directly or mimic the changes. https://github.com/apollographql/federation/tree/trevor/fix-extensions-v16

trevor-scheer avatar Feb 24 '22 18:02 trevor-scheer

@trevor-scheer Thank you for the insights. I will soon make the requested changes + tests.

Regarding the version-0.x branch, if I understand correctly this PR should target it. But what will happen with the main line as it has the same issue. Should we have a separated PR that mimics this one but with changes/tests that aim just for v16 support?

Gamote avatar Feb 28 '22 11:02 Gamote

@Gamote yep - you're welcome to open both PRs if you like, or leave it to me to port the change over to main. Totally up to you! In any case we'll get this fixed in both places.

trevor-scheer avatar Feb 28 '22 18:02 trevor-scheer

@Gamote can you please continue with your changes? This is blocking at least some of us, who would like to use @apollo/subgraph with graphql v16.

vinaybedre avatar May 13 '22 11:05 vinaybedre

@Gamote Do you think you'll have bandwidth to continue working on this? If not I would be willing to pick this up

kdawgwilk avatar Jun 09 '22 03:06 kdawgwilk

Hi @kdawgwilk, if you can please do. I really can't find the time to allocate to this issue. I appreciate 🙏

Gamote avatar Jun 09 '22 12:06 Gamote

Any update?

SirReiva avatar Jul 08 '22 11:07 SirReiva

Unfortunately had a few changes in priorities and its going to be a month or so until I will have a chance to look at this

kdawgwilk avatar Jul 08 '22 17:07 kdawgwilk

FYI - I was getting this issue on a Federation 1 subgraph and this issue went away completely by upgrading my graphql related packages and switching to @apollo/subgraph from @apollo/federation. Basically upgrade to Federation 2 and this shouldn't be a problem for you.

adamlarsonlee avatar Sep 28 '22 21:09 adamlarsonlee

I'm going to optimistically close this based on @adamlarsonlee 's comment, but I'm happy to reopen if this is still ongoing in latest versions of subgraph/gateway packages.

trevor-scheer avatar Nov 10 '22 01:11 trevor-scheer