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

Core schema support and Typescript query planner redux #622

Merged
merged 51 commits into from
Mar 31, 2021

Commits on Mar 19, 2021

  1. Configuration menu
    Copy the full SHA
    1322e44 View commit details
    Browse the repository at this point in the history
  2. Implement core spec

    trevor-scheer committed Mar 19, 2021
    Configuration menu
    Copy the full SHA
    0aa65fb View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    f1e0a8a View commit details
    Browse the repository at this point in the history
  4. 1 Configuration menu
    Copy the full SHA
    f9f3784 View commit details
    Browse the repository at this point in the history

Commits on Mar 21, 2021

  1. Re-introduce last used TypeScript query planner code

    This re-introduces the TypeScript query planner code as of apollographql/apollo-server@60d9742, which is one of the parents of the commit that deleted that code from the `apollo-server` repository: apollographql/apollo-server@149f78e.
    
    I wanted to start out with this to then re-apply the changes I've made in an experimental repository in a more tractable manner.
    
    On top of that, this commit adds a `composedSchema` directory, which contains code that is used to build a schema with Federation metadata from CSDL (this will be replaced with code that takes a core schema file with join directives as input). That was needed to get things wired up with the current gateway code.
    
     We temporarily export the same API we used for the wasm query planner from `@apollo/query-planner`, but implemented as a facade on top of the TypeScript one. This is ugly and inefficient (we shouldn't be parsing the query again), but the goal is to get things working first without making changes to the gateway code.
    martijnwalraven committed Mar 21, 2021
    Configuration menu
    Copy the full SHA
    06c42ad View commit details
    Browse the repository at this point in the history
  2. Use Federation metadata from composed schema

    The original code used `getFederationMetadata` from `@apollo/federation`, which is a private utility function that works based on the internal metadata added to the `GraphQLSchema` that's being built up during composition.
    
    Since the query planner has its own `buildComposedSchema` now, which uses CSDL as input and builds its own `GraphQLSchema`, we need to switch to its utility functions instead.
    
    (We expose separate `getFederationMetadataForType` and `getFederationMetadataForField` functions because there is no need to support both with the same function and that avoids runtime checks.)
    martijnwalraven committed Mar 21, 2021
    Configuration menu
    Copy the full SHA
    9a1e715 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    9dab51d View commit details
    Browse the repository at this point in the history
  4. Fix discrepancy in schema used for feature test

    The corresponding test in `@apollo/gateway` (`single-service.test.ts`) uses a simple value type, not a union. To make sure we come back to this, I've left the union type in there and introduced an additional failing test.
    martijnwalraven committed Mar 21, 2021
    Configuration menu
    Copy the full SHA
    9af5533 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    ac540d2 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    d2ef7c6 View commit details
    Browse the repository at this point in the history
  7. Treat abstract types as value types to replicate type explosion fix

    This replicates the behavior of the current Rust query planner, because I wanted to get the tests passing before making further changes. But the type explosion fix this depends on is fundamentally flawed and needs to be replaced.
    martijnwalraven committed Mar 21, 2021
    Configuration menu
    Copy the full SHA
    4911364 View commit details
    Browse the repository at this point in the history
  8. Make test pass by removing code that changes field ordering

    This code has more problems and should be replaced by proper recursive selection set merging, but removing the unnecessary distinction between aliased fields and non-aliased fields at least fixes the test.
    martijnwalraven committed Mar 21, 2021
    Configuration menu
    Copy the full SHA
    5b8dc42 View commit details
    Browse the repository at this point in the history
  9. Disable test for propagation of directives on inline fragments

    The disabled test covers code that was added to the Rust query planner to fix #177, but that logic is problematic and we should have a more principled discussion about propagation of executable directives first.
    martijnwalraven committed Mar 21, 2021
    Configuration menu
    Copy the full SHA
    439fad2 View commit details
    Browse the repository at this point in the history
  10. Update ordering of fragments in snapshots for autofragmentization tests

    The order of the generated fragments seems to differ between the Rust query planner and the TypeScript one. Since this shouldn't change the semantics of the query, updating the snapshots to make the tests pass.
    martijnwalraven committed Mar 21, 2021
    Configuration menu
    Copy the full SHA
    6cb2023 View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    b9f3a7c View commit details
    Browse the repository at this point in the history
  12. Print valid core schema and change @http to @join__endpoint

    The generated core schema was invalid because the `@join__type` directive definition should be repeatable and have `key` as its argument (instead of `requires` and `provides`). We would also generate a `@join__field` directive without a graph name in case `serviceName` was undefined, which would lead to a syntax error when parsing.
    
    This commit also renames `@http` to `@join__endpoint` and includes a directive definition for it (which was missing before).
    martijnwalraven committed Mar 21, 2021
    Configuration menu
    Copy the full SHA
    a09e433 View commit details
    Browse the repository at this point in the history
  13. Adapt query planner to core schema input

    The goal here is to get the tests passing first, while making as few changes to the gateway as possible. That means the way the gateway generates composed schemas and service lists performs redundant work and should be cleaned up later.
    martijnwalraven committed Mar 21, 2021
    Configuration menu
    Copy the full SHA
    cbbf8cb View commit details
    Browse the repository at this point in the history
  14. Skip tests that fail because of value type handling in composition

    We should rethink the way we handle value types in composition. Currently, a type is only seen as a value type if it is defined in more than one service. Those aren't the right semantics because a type that is only defined in one service can still be a value type if it doesn't have a `@key`. That wasn't an issue before, but with the join spec that means we end up generating `@join__field` directives on fields of what should be value types.
    
    A particularly thorny issue is the use of `@provides` on fields of value types, which if allowed, should only apply to the subgraph that includes it. We don't currently keep track of `@requires`/`@provides` per subgraph however, plus `join__field` is defined as non repeatable, so there is no easy way to generate the correct metadata.
    martijnwalraven committed Mar 21, 2021
    Configuration menu
    Copy the full SHA
    081c59e View commit details
    Browse the repository at this point in the history

Commits on Mar 22, 2021

  1. Print valid core schema and change @http to @join__endpoint

    The generated core schema was invalid because the `@join__type` directive definition should be repeatable and have `key` as its argument (instead of `requires` and `provides`). We would also generate a `@join__field` directive without a graph name in case `serviceName` was undefined, which would lead to a syntax error when parsing.
    
    This commit also renames `@http` to `@join__endpoint` and includes a directive definition for it (which was missing before).
    martijnwalraven authored and trevor-scheer committed Mar 22, 2021
    Configuration menu
    Copy the full SHA
    1e324f2 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    eadfe94 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    2313d5a View commit details
    Browse the repository at this point in the history
  4. Cleanup test case

    trevor-scheer committed Mar 22, 2021
    Configuration menu
    Copy the full SHA
    37773db View commit details
    Browse the repository at this point in the history

Commits on Mar 23, 2021

  1. Configuration menu
    Copy the full SHA
    166bce7 View commit details
    Browse the repository at this point in the history

Commits on Mar 24, 2021

  1. Filter out core and join elements in buildComposedSchema

    To make the schema returned from `buildComposedSchema` reflect the API schema, we filter out core and join elements. The approach is naive and doesn't follow the Core Schema spec, but it should work for the core SDL currently printed from `printComposedSchema` in `@apollo/federation`.
    martijnwalraven committed Mar 24, 2021
    Configuration menu
    Copy the full SHA
    bf79bec View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    70dce5c View commit details
    Browse the repository at this point in the history
  3. Make @provides on value types work by printing @join__field witho…

    …ut `graph`
    
    Allowing `@join__field` without `graph` gives us the same metadata previously computed from CSDL input, and should keep the query planner behavior the same as before.
    
    In the future, we should probably change composition to keep track of `@provides` on a per subgraph basis, and reflect that in the core schema output by making `@join__field` repeatable and `graph` non-nullable.
    martijnwalraven committed Mar 24, 2021
    Configuration menu
    Copy the full SHA
    80e4431 View commit details
    Browse the repository at this point in the history
  4. Avoid printing @join__field for what should be value types

    We should change the way we detect value types. If a type is defined in only one service, we currently don't consider it a value type even if it doesn't specify any keys.
    
    That resulted in us printing `@join__field`, with the name of the single service that defined the type, even though we didn't add a corresponding `join__type` to the parent type (because that relies on there being keys defined). That is invalid according to the join spec, and also broke the current workaround for avoiding type explosion on value types (which we should replace, but are leaving in for now to first replicate the existing behavior).
    martijnwalraven committed Mar 24, 2021
    Configuration menu
    Copy the full SHA
    63658b8 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    0365de6 View commit details
    Browse the repository at this point in the history
  6. 3 Configuration menu
    Copy the full SHA
    0b133e5 View commit details
    Browse the repository at this point in the history

Commits on Mar 25, 2021

  1. Always invoke GraphQLNonNull as a constructor

    This was always the recommended style, but now that `GraphQLNonNull` and `GraphQLList` have been converted to proper classes in graphql/graphql-js#2906, calling them as functions no longer works.
    martijnwalraven committed Mar 25, 2021
    Configuration menu
    Copy the full SHA
    1b2af2d View commit details
    Browse the repository at this point in the history
  2. Propagate directives on inline fragments to subqueries

    This replicates the behavior added to the Rust query planner in #178.
    
    Unfortunately, the logic in there is seriously flawed, and may lead to unexpected results. The assumption seems to be that fields with the same parent type are always nested in the same inline fragment. That is not necessarily true however, and because we take the directives from the scope of the first field with a particular parent type, those directives will be applied to all other fields that have the same parent type even if the directives aren't meant to apply to them because they were nested in a different inline fragment. (That also means that if the scope of the first field doesn't have directives, directives that would have applied to other fields will be lost.)
    
    (Note that this also applies to `@skip` and `@include`, which could lead to invalid query plans that fail at runtime because expected fields are missing from a subgraph response.)
    martijnwalraven committed Mar 25, 2021
    Configuration menu
    Copy the full SHA
    31a7ba6 View commit details
    Browse the repository at this point in the history

Commits on Mar 28, 2021

  1. Escape string literals when printing core schema

    We need to make sure the string values we print are valid GraphQL string literals. If a value includes a quote or backslash for example, these need to be escaped to avoid parser errors.
    
    We're relying on `JSON.stringify` for this, which the `graphql-js` printer also uses when printing out a `StringValue`: https://github.com/graphql/graphql-js/blob/d4bcde8d3e7a7cb8462044ff21122a3996af8655/src/language/printer.js#L109-L112
    martijnwalraven committed Mar 28, 2021
    Configuration menu
    Copy the full SHA
    88f8c09 View commit details
    Browse the repository at this point in the history

Commits on Mar 29, 2021

  1. Configuration menu
    Copy the full SHA
    3350d86 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    9cb48f1 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    4b7df18 View commit details
    Browse the repository at this point in the history

Commits on Mar 30, 2021

  1. harmonizer: Update to use coreSchema rather than composedSdl.

    Also updates snapshots of command's output.
    abernix committed Mar 30, 2021
    Configuration menu
    Copy the full SHA
    3f860e3 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    da7a186 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    25b5453 View commit details
    Browse the repository at this point in the history
  4. Print @join__type directives on interface types

    This code remains untested since this path is unsupported by
    composition currently. There is a related issue polaris-planning#62
    which should be referenced when building out the rest of this
    functionality.
    trevor-scheer committed Mar 30, 2021
    Configuration menu
    Copy the full SHA
    973db23 View commit details
    Browse the repository at this point in the history
  5. Remove CSDL

    Remove all notions of CSDL in code. Replaced with "Supergraph SDL" or
    its appropriately camelCased counterpart.
    trevor-scheer committed Mar 30, 2021
    Configuration menu
    Copy the full SHA
    22e6e77 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    eb6676b View commit details
    Browse the repository at this point in the history

Commits on Mar 31, 2021

  1. Configuration menu
    Copy the full SHA
    6906a8c View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    247fb10 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    bc31b88 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    19ae2f6 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    36cdac4 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    5b30ba8 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    6abb7d4 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    466c6e1 View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    f9e4cf7 View commit details
    Browse the repository at this point in the history
  10. Update changelogs

    trevor-scheer committed Mar 31, 2021
    Configuration menu
    Copy the full SHA
    9db6aa9 View commit details
    Browse the repository at this point in the history