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

Removes special case to type explosion with fed1 supergraphs #1994

Merged

Conversation

pcmanus
Copy link
Contributor

@pcmanus pcmanus commented Jul 19, 2022

We usually avoid type-exploding the fetching of interface fields when we
can avoid to, but we were avoiding this optimization where the input
was a fed1-generated supergraph (essentially always type-exploding all
interfaces).

The initial reason for that avoidance was a combination of 2 things:

  1. going too fast over this, I though this was what the fed1 query
    planning was doing, which is actually not 100% accurate.
  2. fed1-generated supergraph have incomplete information when it
    goes to interface (really, all non-entity types), in that it
    does not record when those interfaces/values types are actually
    defined. This lead to known issues (in both fed1 and
    fed2-with-fed1-supergraph) and I took this as additional motivation
    to avoid relying on interface as much as possible (which type
    explosion kind of achieve).

However, regarding the 1st point, fed1 happens to avoid type explosion
when all the implementations of an interface are a value type, so not
doing so is a sort of regression. And while we could mimick that fed1
behaviour, upon further reflexion, the rule we use for fed2 for this
(which only type-explode specific fields where one of the implementation
is either external or has as @requires) is actually fine with fed1
supergraphs. More precisely, the issues due to the incompletness of
fed1 supergraph could be a problem with that rule if an interface
had different fieds defined in different subgraphs, but that's actually
not allowed by fed1.

@netlify
Copy link

netlify bot commented Jul 19, 2022

👷 Deploy request for apollo-federation-docs pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 6511ded

We usually avoid type-exploding the fetching of interface fields when we
can avoid to, but we were avoiding this optimization where the input
was a fed1-generated supergraph (essentially always type-exploding all
interfaces).

The initial reason for that avoidance was a combination of 2 things:
1. going too fast over this, I though this was what the fed1 query
   planning was doing, which is actually not 100% accurate.
2. fed1-generated supergraph have incomplete information when it
  goes to interface (really, all non-entity types), in that it
  does not record when those interfaces/values types are actually
  defined. This lead to known issues (in both fed1 and
  fed2-with-fed1-supergraph) and I took this as additional motivation
  to avoid relying on interface as much as possible (which type
  explosion kind of achieve).

However, regarding the 1st point, fed1 happens to avoid type explosion
when all the implementations of an interface are a value type, so not
doing so is a sort of regression. And while we could mimick that fed1
behaviour, upon further reflexion, the rule we use for fed2 for this
(which only type-explode specific fields where one of the implementation
is either external or has as `@requires`) is actually fine with fed1
supergraphs. More precisely, the issues due to the incompletness of
fed1 supergraph could be a problem with that rule _if_ an interface
had different fieds defined in different subgraphs, but that's actually
not allowed by fed1.

Fixes apollographql#1988.
@pcmanus pcmanus force-pushed the 1988-type-explosion-fed1-supergraph branch from 9c2761d to e021efd Compare July 19, 2022 08:52
@pcmanus pcmanus linked an issue Jul 19, 2022 that may be closed by this pull request
@pcmanus pcmanus self-assigned this Jul 19, 2022
@codesandbox-ci
Copy link

codesandbox-ci bot commented Jul 19, 2022

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
Contributor

@benweatherman benweatherman left a comment

Choose a reason for hiding this comment

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

🐐

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.

Interface explosion issue with Fed1 supergraph/Fed2 query planner
2 participants