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

Fix merging of Input objects and enum types #1672

Merged
merged 2 commits into from
Apr 5, 2022

Commits on Apr 5, 2022

  1. Fix merging of Input objects and enum types

    At a high level, the merging guiding principle is meant to be:
    - output types are merged by "union": meaning an element of an output
      types can (in general) be in the supergraph as soon as it is in any
      subgraph. The idea being that it's ok (and desirable) that different
      subgraph can return different "sub-parts" of an output type and the
      query planner is here direct queries appropriately. Of course, in
      practice, the "composition validation" algorithm imposes some limits
      to this based on the reachability of the type.
    - input types are merged by "intersection": meaning that an element
      an input type is only in the supergraph if it is in all the subgraph
      defining the type in question. The idea being that the gateway don't
      control the inputs it gets, and so in general, all subgraphs needs
      be able to handle all the inputs exposed by the supergraph API.
    
    This guiding principle was not implemented properly for both Input
    Object types and Enum types and this is fixed by this commit.
    
    Note that:
    - for input object types, this has the consequence of aligning the
      merging of input fields with that of (output) field arguments. Indeed,
      passing multiple arguments is extremely similar semantically to
      passing a single input object having the same fields, so it does not
      make sense for the behiavour of those to differ, and it doesn't
      anymore after this patch.
    - enum types are a special case because they can be use as both output
      types and input types (this is true for scalar too, but scalar merging
      is trivial). The patch makes the behaviour depend on how the enum
      type is used:
      - if it is only ever used as an input type, then we merge it by
        "intersection".
      - if it is only ever used as an output type, then we merge it by
        "union".
      - otherwise, if it used as both, then merging is essentially
        "equality", meaning that we have a composition error unless all
        the subgraphs defined the same values.
    Sylvain Lebresne committed Apr 5, 2022
    Configuration menu
    Copy the full SHA
    0c40f54 View commit details
    Browse the repository at this point in the history
  2. Update changelog and address review comments

    Sylvain Lebresne committed Apr 5, 2022
    Configuration menu
    Copy the full SHA
    54591ad View commit details
    Browse the repository at this point in the history