Skip to content
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

Avoid incomplete subgraph when extracting from supergraph #1511

Merged
merged 1 commit into from
Feb 14, 2022

Conversation

pcmanus
Copy link
Contributor

@pcmanus pcmanus commented Feb 11, 2022

This is a small followup to #1351: the patch removed object/interface types recursively as it should, but typo-ed union types only calling remove instead of removeRecursive.
I didn't notice it at the time because while I added a union type test, it wasn't actually exercise the part of the code I though it was.
This PR fixes that problem and adds a proper test (keeping the other union test because while it didn't test what I though it was, it still tests something useful (namely that the removeRecursive on object types correctly recurse to unions)).

Due to imprecisions of the fed1 join spec, the code handling supergraph
sometimes initially assume a type is in all subgraph to remove that type
later from some subgraphs as it realises it cannot have been in that
subgraph. As we remove types that way, we have to remove references to
it as well, and this was done correctly for object types through
`removeRecursive`, but for union types, `remove` was used instead. This
fix imply ensure `removeRecursive` is used there as well.
@codesandbox-ci
Copy link

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.

Copy link
Member

@abernix abernix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The justification here makes sense to me and this commit is also on #1510 which has been reviewed separately. Landing this will unblock a use-case in the Router and we're going to try to cut a release of that soon-ish (today?).

I will follow-up this with a release myself. (And add a CHANGELOG there)


test('handles unions types having no members in a subgraph correctly', () => {
/*
* The following supergraph has been generated on version-0.x from:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this have a different comment if it were generated by main?

@abernix abernix merged commit 5fbbf85 into main Feb 14, 2022
@abernix abernix deleted the fix-fed1-supergraph branch February 14, 2022 08:45
abernix added a commit to apollographql/federation-rs that referenced this pull request Feb 14, 2022
abernix added a commit to apollographql/federation-rs that referenced this pull request Feb 14, 2022
* router-bridge: Update to `@apollo/[email protected]`

Most notably to bring in apollographql/federation#1511

Ref: apollographql/federation@ee84b3fd9df161c3a94

* tests: update snapshots to include `operationKind`

This is expected since the [Ref]erenced PR introduced it!

Ref: apollographql/federation#1427
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants