Detalhes do pacote

@graphql-tools/federation

graphql-hive172.1kMIT3.2.4

Useful tools to create and manipulate GraphQL schemas.

readme (leia-me)

Hive GraphQL Platform

Hive Gateway

A fully open-source MIT-licensed GraphQL API gateway that can act as a GraphQL federation Gateway or a Proxy Gateway for any GraphQL services.

It can be run as a standalone binary, a Docker Image, or as a JavaScript package (e.g. within Node.js, Bun, Deno, Google Cloud Functions, Azure Functions or Cloudflare Workers)

changelog (log de mudanças)

@graphql-tools/federation

3.2.4

Patch Changes

  • Updated dependencies [ed323fa]:
    • @graphql-tools/executor-http@2.0.3

3.2.3

Patch Changes

3.2.2

Patch Changes

  • #1117 0512be3 Thanks @ardatan! - Optimizes @provides handling by avoiding the generation of new query plans when a parent subgraph already supplies the requested fields.
    • Refactors and inlines subtractSelectionSets to compute leftover selections.
    • Threads a providedSelectionNode through planning to subtract out provided fields early.
    • Updates stitching and federation logic to conditionally skip planning when selections are already available.
  • Updated dependencies [b7627d3, ef0e24c, 0512be3, b7627d3]:
    • @graphql-tools/executor-http@2.0.1
    • @graphql-tools/delegate@10.2.18
    • @graphql-tools/stitch@9.4.23
    • @graphql-tools/wrap@10.0.36

3.2.1

Patch Changes

  • #1045 da47a0e Thanks @enisdenjo! - dependencies updates:

  • #1045 da47a0e Thanks @enisdenjo! - Update graphql-yoga and whatwg-node packages

    In light of https://github.com/ardatan/whatwg-node/pull/2305. Please upgrade as soon as possible!

  • #997 4cf75cb Thanks @ardatan! - - BREAKING: HTTP Executor no longer takes serviceName as an option.

    • Both HTTP executor and @graphql-mesh/transport-http-callback no longer handle DOWNSTREAM_SERVICE_ERROR error code with serviceName.
    • Gateway runtime handles subgraph errors on its own with DOWNSTREAM_SERVICE_ERROR error code and serviceName as a property. This behavior can be configured with subgraphErrors option of the createGatewayRuntime function or CLI config.
    subgraphError: {
       errorCode: 'DOWNSTREAM_SERVICE_ERROR', // or `false` to remove this code completely
       subgraphNameProp: 'serviceName' // or `false` to remove this prop completely
    }
    
  • Updated dependencies [da47a0e, da47a0e, 9a120c8, 4cf75cb]:

    • @graphql-tools/executor-http@2.0.0

3.2.0

Minor Changes

  • #946 7d771d8 Thanks @ardatan! - As Apollo suggests and uses in their implementation, we set the request timeout to 30 seconds for GraphOS uplinks

Patch Changes

3.1.7

Patch Changes

3.1.6

Patch Changes

3.1.5

Patch Changes

3.1.4

Patch Changes

3.1.3

Patch Changes

  • Updated dependencies [2318393]:
    • @graphql-tools/delegate@10.2.13
    • @graphql-tools/stitch@9.4.18
    • @graphql-tools/wrap@10.0.31

3.1.2

Patch Changes

3.1.1

Patch Changes

  • Updated dependencies [8c80ac9, 8c80ac9]:
    • @graphql-tools/executor-http@1.2.6

3.1.0

Minor Changes

  • #444 b52c9ba Thanks @ardatan! - Now SupergraphSchemaManager can be used in ApolloServer as gateway;

    import { ApolloServer } from '@apollo/server';
    import { SupergraphSchemaManager } from '@graphql-tools/federation';
    
    const gateway = new SupergraphSchemaManager();
    const apolloServer = new ApolloServer({
      gateway,
    });
    

    And with the new onStitchedSchema option, you can manipulate the executable schema created from the supergraph. The following example demonstrates how to use onStitchedSchema with applyMiddleware from graphql-middleware:

    import { SupergraphSchemaManager } from '@graphql-tools/federation';
    import { applyMiddleware } from 'graphql-middleware';
    
    const logInput = async (resolve, root, args, context, info) => {
      console.log(`1. logInput: ${JSON.stringify(args)}`);
      const result = await resolve(root, args, context, info);
      console.log(`5. logInput`);
      return result;
    };
    
    const logResult = async (resolve, root, args, context, info) => {
      console.log(`2. logResult`);
      const result = await resolve(root, args, context, info);
      console.log(`4. logResult: ${JSON.stringify(result)}`);
      return result;
    };
    
    const gateway = new SupergraphSchemaManager({
      onStitchedSchema: async (schema) => {
        // Manipulate the schema
        return applyMiddleware(schema, logInput, logResult);
      },
    });
    

Patch Changes

  • #552 b0bc26b Thanks @ardatan! - Handle shared subscription root fields correctly

    In case of conflicting subscription root fields coming from different subgraphs or different entry points(multiple keys), subscription was failing.

  • Updated dependencies [9144222]:

    • @graphql-tools/delegate@10.2.11
    • @graphql-tools/stitch@9.4.16
    • @graphql-tools/wrap@10.0.29

3.0.10

Patch Changes

  • Updated dependencies [18682e6, e9f78cd]:
    • @graphql-tools/delegate@10.2.10
    • @graphql-tools/wrap@10.0.28
    • @graphql-tools/stitch@9.4.15

3.0.9

Patch Changes

  • #443 a625269 Thanks @ardatan! - In case of shared Mutation field in different subgraphs, choose the best option instead of choosing the last option just like we do in Query root fields

  • Updated dependencies [a625269, 14152f7]:

    • @graphql-tools/stitch@9.4.14
    • @graphql-tools/executor-http@1.2.5

3.0.8

Patch Changes

  • #351 0591aa9 Thanks @ardatan! - Keep the custom directives(using @composeDirective) from the supergraph, in the unified schema served by the gateway should keep it.

3.0.7

Patch Changes

  • #387 3571399 Thanks @ardatan! - In case of shared root field on Mutation, it was batched incorrectly across subgraphs. But instead only one mutation should be called as mutations should not be parallel

  • Updated dependencies []:

    • @graphql-tools/executor-http@1.2.4
    • @graphql-tools/stitch@9.4.13

3.0.6

Patch Changes

  • Updated dependencies []:
    • @graphql-tools/stitch@9.4.12

3.0.5

Patch Changes

  • Updated dependencies [55eb1b4, 55eb1b4]:
    • @graphql-tools/executor-http@1.2.3

3.0.4

Patch Changes

3.0.3

Patch Changes

3.0.2

Patch Changes

  • Updated dependencies [23b8987, 23b8987]:
    • @graphql-tools/delegate@10.2.8
    • @graphql-tools/executor-http@1.2.1
    • @graphql-tools/stitch@9.4.10
    • @graphql-tools/wrap@10.0.26

3.0.1

Patch Changes

  • Updated dependencies [367b359]:
    • @graphql-tools/executor-http@1.2.0

3.0.0

Major Changes

  • #308 d747d4c Thanks @ardatan! - BREAKING CHANGES;

    • Removed buildSubgraphSchema, use @apollo/subgraph instead.
    • Removed the following gateway related functions, and prefer using Supergraph approach instead
      • getSubschemaForFederationWithURL
      • getSubschemaForFederationWithTypeDefs
      • getSubschemaForFederationWithExecutor
      • getSubschemaForFederationWithSchema
      • federationSubschemaTransformer
    • SupergraphSchemaManager is no longer an EventEmitter but EventTarget instead, and it emits a real Event object.
    • SupergraphSchemaManager is now Disposable and it no longer stops based on Nodejs terminate events, so you should use using syntax.
    using manager = new SupergraphSchemaManager({ ... });
    
    manager.addEventListener('error', (event: SupergraphSchemaManagerErrorEvent) => {
      console.error(event.detail.error);
    });
    
    let schema: GraphQLSchema | null = null;
    manager.addEventListener('schema', (event: SupergraphSchemaManagerSchemaEvent) => {
        schema = event.detail.schema;
    });
    

Patch Changes

2.2.40

Patch Changes

2.2.39

Patch Changes

  • Updated dependencies [3f1a0fa]:
    • @graphql-tools/executor-http@1.1.13

2.2.38

Patch Changes

2.2.37

Patch Changes

  • Updated dependencies [9ce705c]:
    • @graphql-tools/delegate@10.2.5
    • @graphql-tools/stitch@9.4.7
    • @graphql-tools/wrap@10.0.23

2.2.36

Patch Changes

  • Updated dependencies [76642d8]:
    • @graphql-tools/stitch@9.4.6

2.2.35

Patch Changes

  • Updated dependencies []:
    • @graphql-tools/delegate@10.2.4
    • @graphql-tools/stitch@9.4.5
    • @graphql-tools/wrap@10.0.22

2.2.34

Patch Changes

2.2.33

Patch Changes

  • #231 7ca0ff3 Thanks @ardatan! - Avoid extensions and use `stitchingInfo` for provided fields

  • Updated dependencies [7ca0ff3]:

    • @graphql-tools/delegate@10.2.3
    • @graphql-tools/stitch@9.4.4
    • @graphql-tools/wrap@10.0.21

2.2.32

Patch Changes

2.2.31

Patch Changes

2.2.30

Patch Changes

  • 725d5b7 Thanks @ardatan! - Fix regression on override type interface

  • Updated dependencies [725d5b7]:

    • @graphql-tools/stitch@9.4.1

2.2.29

Patch Changes

  • Updated dependencies [f32cb2a]:
    • @graphql-tools/delegate@10.2.0
    • @graphql-tools/stitch@9.4.0
    • @graphql-tools/wrap@10.0.18

2.2.28

Patch Changes

  • Updated dependencies [73c621d, 19bc6a4]:
    • @graphql-tools/delegate@10.1.3
    • @graphql-tools/wrap@10.0.17
    • @graphql-tools/stitch@9.3.5

2.2.26

Patch Changes

2.2.25

Patch Changes

  • 342e044 Thanks @ardatan! - Prevent extra queries to the same subgraph multiple times on the same plan, and merge iterables correctly
  • Updated dependencies [342e044]:
    • @graphql-tools/delegate@10.1.1
    • @graphql-tools/stitch@9.3.3
    • @graphql-tools/wrap@10.0.15

2.2.24

Patch Changes

  • #6619 e9906eb Thanks @kroupacz! - Handle shared root field queries with aliases

  • Updated dependencies [e9906eb]:

    • @graphql-tools/delegate@10.1.0
    • @graphql-tools/stitch@9.3.2
    • @graphql-tools/wrap@10.0.14

2.2.23

Patch Changes

  • Updated dependencies [da1de08]:
    • @graphql-tools/delegate@10.0.29
    • @graphql-tools/stitch@9.3.1
    • @graphql-tools/wrap@10.0.13

2.2.22

Patch Changes

  • Updated dependencies [2bb2adb]:
    • @graphql-tools/stitch@9.3.0

2.2.21

Patch Changes

2.2.20

Patch Changes

  • Updated dependencies [f470f49]:
    • @graphql-tools/delegate@10.0.28
    • @graphql-tools/stitch@9.2.17
    • @graphql-tools/wrap@10.0.12

2.2.19

Patch Changes

  • 180f3f0 Thanks @ardatan! - Avoid extra calls if the keys are already resolved

  • Updated dependencies [180f3f0]:

    • @graphql-tools/delegate@10.0.27
    • @graphql-tools/stitch@9.2.16
    • @graphql-tools/wrap@10.0.11

2.2.18

Patch Changes

  • #6598 4deac7f Thanks @kroupacz! - If currentUnavailableSelectionSet.selections is empty array then "query planning" will fail.

2.2.17

Patch Changes

  • b1e002f Thanks @ardatan! - If required non-nullable key is null, do not send it to the subgraph;

    See optimizations.test.ts for more details.

2.2.16

Patch Changes

  • #6586 8effad4 Thanks @ardatan! - Performance improvements on upstream request execution

  • Updated dependencies [8effad4]:

    • @graphql-tools/delegate@10.0.26
    • @graphql-tools/stitch@9.2.15
    • @graphql-tools/wrap@10.0.10

2.2.15

Patch Changes

  • Updated dependencies [8a16b01]:
    • @graphql-tools/delegate@10.0.25
    • @graphql-tools/stitch@9.2.14
    • @graphql-tools/wrap@10.0.9

2.2.14

Patch Changes

2.2.13

Patch Changes

  • Updated dependencies [4cdb462]:
    • @graphql-tools/delegate@10.0.24
    • @graphql-tools/stitch@9.2.13
    • @graphql-tools/wrap@10.0.8

2.2.12

Patch Changes

  • #6573 7e2938d Thanks @ardatan! - When there are two services like below then the following query senty, the gateway tries to fetch id as an extra field because it considers id might be needed while this is not correct. This patch avoids any extra calls, and forwards the query as is to the 2nd service.

    query {
      viewer {
        booksContainer(input: $input) {
          edges {
            cursor
            node {
              source {
                # Book(upc=)
                upc
              }
            }
          }
          pageInfo {
            endCursor
          }
        }
      }
    }
    
    type Book @key(fields: "id") @key(fields: "upc") {
      id: ID!
      upc: ID!
    }
    
    type BookContainer { # the type that is used in a collection
      id: ID!
      # ... other stuff here
      source: Book!
    }
    
    type Book @key(fields: "upc") {
      upc: ID!
    }
    
    type Query {
      viewer: Viewer
    }
    
    type Viewer {
      booksContainer: BooksContainerResult
    }
    
    type BooksContainerResult {
      edges: [BooksContainerEdge!]!
      pageInfo: PageInfo!
    }
    
    type BooksContainerEdge {
      node: BookContainer!
      cursor: String!
    }
    
    type PageInfo {
      endCursor: String
    }
    
  • Updated dependencies [7e2938d]:

    • @graphql-tools/delegate@10.0.23
    • @graphql-tools/stitch@9.2.12
    • @graphql-tools/wrap@10.0.7

2.2.11

Patch Changes

  • Updated dependencies [dcb3e27, cf2ce5e]:
    • @graphql-tools/stitch@9.2.11
    • @graphql-tools/utils@10.5.5
    • @graphql-tools/delegate@10.0.22
    • @graphql-tools/executor-http@1.1.7
    • @graphql-tools/merge@9.0.8
    • @graphql-tools/schema@10.0.7
    • @graphql-tools/wrap@10.0.6

2.2.10

Patch Changes

2.2.9

Patch Changes

  • #6469 0e87805 Thanks @User!! - Handle merged selection sets in the computed fields;

    When a selection set for a computed field needs to be merged, resolve that required selection set fully then resolve the computed field. In the following case, the selection set for the author field in the Post type is merged with the selection set for the authorId field in the Comment type.

    type Query {
      feed: [Post!]!
    }
    
    type Post {
      id: ID! @computed(selectionSet: "{ comments { authorId } }")
    }
    
    type Comment {
      id: ID!
      authorId: ID!
    }
    
    type User {
      id: ID!
      name: String!
    }
    
    type Post {
      id: ID!
      comments: [Comment!]!
    }
    
    type Comment {
      id: ID!
    }
    
  • Updated dependencies [0e87805]:

    • @graphql-tools/delegate@10.0.20

2.2.8

Patch Changes

  • #6441 52a69ed Thanks @ardatan! - Filter errors as null in the projected key

    If the key field has Error, do not send them to the subgraphs as objects but null.

2.2.7

Patch Changes

  • #6437 3188051 Thanks @User, @()>), @{, @{, @{, @{, @{! - Fix the bug happens when a merged field is a computed field requires another computed field requires a field from the initial subschema.

    In the following test case, totalOrdersPrices needs userOrders which needs lastName from initial Query.user. So the bug was skipping the dependencies of userOrders because it assumed lastName already there by mistake.

        const schema1 = makeExecutableSchema({
          typeDefs: /* GraphQL */ `
            type User {
              id: ID!
              firstName: String!
              lastName: String!
              address: String
            }
    
            type Query {
    
            }
          `,
          resolvers: {
            Query: {
     => {
                return {
                  id: 1,
                  firstName: 'Jake',
                  lastName: 'Dawkins',
                  address: 'everywhere',
                };
              },
            },
          },
        });
        const schema2 = makeExecutableSchema({
          typeDefs: /* GraphQL */ `
            type UserOrder {
              id: ID!
            }
    
            type User {
              id: ID!
              totalOrdersPrices: Int
              aggregatedOrdersByStatus: Int
            }
    
            type Query {
              userWithOrderDetails(userId: ID!, userOrderIds: [ID]): User
            }
          `,
          resolvers: {
            Query: {
              userWithOrderDetails: (_root, { userId, userOrderIds }) => {
                return {
                  id: userId,
                  userOrders: userOrderIds?.map((userOrderId: string) => ({ id: userOrderId })),
                };
              },
            },
    
              totalOrdersPrices(user) {
                if (user.userOrders instanceof Error) {
                  return user.userOrders;
                }
                if (!user.userOrders) {
                  throw new Error('UserOrders is required');
                }
                return 0;
              },
              aggregatedOrdersByStatus(user) {
                if (user.userOrders instanceof Error) {
                  return user.userOrders;
                }
                if (!user.userOrders) {
                  throw new Error('UserOrders is required');
                }
                return 1;
              },
            },
          },
        });
        const schema3 = makeExecutableSchema({
          typeDefs: /* GraphQL */ `
            type User {
              id: ID!
              userOrders: [UserOrder!]
            }
    
            type UserOrder {
              id: ID!
            }
    
            type Query {
              userWithOrders(id: ID!, lastName: String): User
            }
          `,
          resolvers: {
            Query: {
              userWithOrders: (_root, { id, lastName }) => {
                return {
                  id,
                  lastName,
                };
              },
            },
    
              userOrders(user) {
                if (!user.lastName) {
                  throw new Error('LastName is required');
                }
                return [
                  {
                    id: `${user.lastName}1`,
                  },
                ];
              },
            },
          },
        });
        const stitchedSchema = stitchSchemas({
          subschemas: [
            {
              schema: schema1,
            },
            {
              schema: schema2,
              merge: {
    
                  selectionSet: '{ id }',
                  fieldName: 'userWithOrderDetails',
                  args: ({ id, userOrders }: { id: string; userOrders: any[] }) => ({
                    userId: id,
                    userOrderIds: userOrders?.map?.(({ id }: { id: string }) => id),
                  }),
                  fields: {
                    totalOrdersPrices: {
                      selectionSet: '{ userOrders { id } }',
                      computed: true,
                    },
                    aggregatedOrdersByStatus: {
                      selectionSet: '{ userOrders { id } }',
                      computed: true,
                    },
                  },
                },
              },
            },
            {
              schema: schema3,
              merge: {
    
                  selectionSet: '{ id }',
                  fieldName: 'userWithOrders',
                  args: ({ id, lastName }: { id: string; lastName: string }) => ({
                    id,
                    lastName,
                  }),
                  fields: {
                    userOrders: {
                      selectionSet: '{ lastName }',
                      computed: true,
                    },
                  },
                },
              },
            },
          ],
        });
        const res = await normalizedExecutor({
          schema: stitchedSchema,
          document: parse(/* GraphQL */ `
            query User {
              user {
                aggregatedOrdersByStatus
                totalOrdersPrices
              }
            }
          `),
        });
        expect(res).toEqual({
          data: {
    
              aggregatedOrdersByStatus: 1,
              totalOrdersPrices: 0,
            },
          },
        });
    
  • Updated dependencies [3188051]:

    • @graphql-tools/delegate@10.0.19

2.2.6

Patch Changes

  • b8bf584 Thanks @ardatan! - Introduce `getDirectiveExtensions` and refactor directive handling in the extensions

  • Updated dependencies [b8bf584]:

    • @graphql-tools/utils@10.4.0
    • @graphql-tools/schema@10.0.5
    • @graphql-tools/merge@9.0.5

2.2.5

Patch Changes

  • dbb0516 Thanks @ardatan! - If there are repeated computed fields like below, project the data for the computed fields for each fields and merge them correctly. And if they are array as in userOrders, merge them by respecting the order (the second one can have price maybe).

    type UserOrder @key(fields: "id") {
      id: ID!
      status: String!
      price: Int!
    }
    
    type User @key(fields: "id") {
      id: ID!
      userOrders: [UserOrder!] @external
      totalOrdersPrices: Int @requires(fields: "userOrders { id }")
      aggregatedOrdersByStatus: Int @requires(fields: "userOrders { id }")
    }
    

2.2.4

Patch Changes

  • #6403 3803897 Thanks @ardatan! - Cleanup extra fields, empty inline fragments and duplicate __typename fields

  • Updated dependencies [3803897]:

    • @graphql-tools/delegate@10.0.17

2.2.3

Patch Changes

  • 0d203ab Thanks @ardatan! - Support @requires with arguments like @requires(fields: "price(currency: 'USD')")

2.2.2

Patch Changes

  • 63cab60 Thanks @ardatan! - Use type definition merger instead of `concatAST` to merge type definitions for creating a subschema for Federation

2.2.1

Patch Changes

  • 33e8146 Thanks @ardatan! - Fail on query planning phase if the query plan is not successful before the actual execution

  • Updated dependencies [33e8146]:

    • @graphql-tools/delegate@10.0.16

2.2.0

Minor Changes

2.1.4

Patch Changes

  • 167b47c Thanks @ardatan! - New options to configure query batching and batched delegation

    {
      batchingOptions: {
        dataLoaderOptions: {
          maxBatchSize: 10, // Limits the query batching
        }
      },
      batchDelegateOptions: {
        maxBatchSize: 10, // Limits the batch delegation
      }
    }
    

    Learn more about these here; Batch Delegation Query Batching

2.1.3

Patch Changes

  • d54b21a Thanks @ardatan! - Do not apply type merging for non-resolvable entities

  • Updated dependencies [d54b21a, d54b21a]:

    • @graphql-tools/delegate@10.0.15

2.1.2

Patch Changes

  • #6355 c6d175b Thanks @ardatan! - Handle errors coming from subgraphs correctly when a root field is shared by different subgraphs

    • If subgraph A returns an error for Query.foo, and subgraph B returns the data, ignore the error and keep it for null fields.
    • If both subgraphs return errors, return them as AggregateError then return them to the gateway result.
  • Updated dependencies [8094c37, 97c88a0]:

    • @graphql-tools/delegate@10.0.14
    • @graphql-tools/executor-http@1.1.5

2.1.1

Patch Changes

  • #6293 3f301dc Thanks @ardatan! - Do not use entryPoints for MergedTypeConfig if there is only one

  • #6278 66c99d9 Thanks @ardatan! - Exclude @defer in the subgraph requests

  • Updated dependencies [66c99d9, 3f301dc]:

    • @graphql-tools/delegate@10.0.12
    • @graphql-tools/stitch@9.2.10
    • @graphql-tools/utils@10.2.3

2.1.0

Minor Changes

  • #6267 d5dd794 Thanks @EmrysMyrddin! - Add delayInSeconds to the failure event to give users more control on failure handling.

  • #6267 d5dd794 Thanks @EmrysMyrddin! - Add a the ability to start polling with a delay. This ease the handling of failure handling, allowing to restart the manager and respecting GraphOS minimum retry delay.

Patch Changes

  • #6267 d5dd794 Thanks @EmrysMyrddin! - Fix Supergraph Manager Event Emitter not calling every listener when at least one has been registered using once method.

2.0.1

Patch Changes

  • #6238 0f7059b Thanks @ardatan! - Merge the elements of the lists if the root field is shared across different subgraphs

    type Query {
      products: [Product] # If this field is returned by multiple subgraphs, the elements of the lists will be merged
    }
    
  • Updated dependencies [0f7059b]:

    • @graphql-tools/utils@10.2.2

2.0.0

Major Changes

  • #6227 85c383f Thanks @ardatan! - BREAKING CHANGES:
    • getSubschemasFromSupergraphSdl has been removed in favor of the new getStitchingOptionsFromSupergraphSdl, and it returns the options for stitchSchemas instead of the map of subschemas
    • onExecutor has been removed in favor of onSubschemaConfig
    • To change the default HTTP executor options, use httpExecutorOpts instead of onExecutor

Patch Changes

1.1.36

Patch Changes

  • #6194 7368829 Thanks @ardatan! - Handle interface objects in a different way

  • #6189 0134f7f Thanks @ardatan! - Handle interface types with non-shared implementations;

    For example, you have the following services, where Node is implemented in both services, but Foo and Bar are only implemented in one service. And when the gateway receives the following query, it should be converted to this because Node is not implemented as Bar in Service 1 while implemented in Service 2.

    Query conversion;

    # Gateway request
    query {
      fooBar(id: "1") {
        ... on Node {
          id
        }
      }
    }
    
    # Service 1 Request
    query {
      fooBar(id: "1") {
        ... on Foo {
          id
        }
        ... on Bar {
          id
        }
      }
    }
    

    Services;

    # Service 1
    
    union FooBar = Foo | Bar
    
    interface Node {
      id: ID!
    }
    
    type Foo implements Node {
      id: ID!
    }
    
    type Bar {
      id: ID!
    }
    
    type Query {
      fooBar(id: ID!): FooBar
    }
    
    # Service 2
    interface Node {
      id: ID!
    }
    
    type Foo implements Node {
      id: ID!
    }
    
    type Bar implements Node {
      id: ID!
    }
    
  • #6187 dfccfbf Thanks @ardatan! - Respect @provides to optimize the query plan

  • #6188 e10c13a Thanks @ardatan! - If two different subschemas have the root field, use the same field to resolve missing fields instead of applying a type merging in advance

  • Updated dependencies [7368829, e10c13a, e10c13a, dfccfbf, 0134f7f, eec9d3d, 03a47b1, e10c13a, 0827497]:

    • @graphql-tools/delegate@10.0.11
    • @graphql-tools/schema@10.0.4
    • @graphql-tools/stitch@9.2.9
    • @graphql-tools/utils@10.2.1

1.1.35

Patch Changes

  • #6141 cd962c1 Thanks @ardatan! - When the gateway receives the query, now it chooses the best root field if there is the same root field in different subgraphs. For example, if there is node(id: ID!): Node in all subgraphs but one implements User and the other implements Post, the gateway will choose the subgraph that implements User or Post based on the query.

    If there is a unresolvable interface field, it throws.

    See this supergraph and the test query to see a real-life example

  • #6143 04d5431 Thanks @ardatan! - Implement interface objects support

  • Updated dependencies [a83da08, fc9c71f, cd962c1]:

    • @graphql-tools/delegate@10.0.10
    • @graphql-tools/stitch@9.2.8

1.1.34

Patch Changes

1.1.33

Patch Changes

  • 361052a Thanks @ardatan! - Small fix: check all final types to find orphan interfaces

1.1.32

Patch Changes

  • #6126 680351e Thanks @ardatan! - When there is a Node subschema, and others to resolve the rest of the entities by using a union resolver as in Federation like below, it was failing. This version fixes that issue.

    query {
      node(id: "1") {
        id # Fetches from Node
        ... on User {
          name # Fetches from User
        }
      }
    }
    
    type Query {
      node(id: ID!): Node
    }
    
    interface Node {
      id: ID!
    }
    
    type User implements Node {
      id: ID!
    }
    
    type Post implements Node {
      id: ID!
    }
    
    # User subschema
    scalar _Any
    type Query {
      _entities(representations: [_Any!]!): [_Entity]!
    }
    union _Entity = User
    interface Node {
      id: ID!
    }
    type User implements Node {
      id: ID!
      name: String!
    }
    
    # Post subschema
    scalar _Any
    union _Entity = Post
    type Query {
      _entities(representations: [_Any!]!): [_Entity]!
    }
    interface Node {
      id: ID!
    }
    type Post implements Node {
      id: ID!
      title: String!
    }
    
  • Updated dependencies [680351e]:

    • @graphql-tools/delegate@10.0.9
    • @graphql-tools/stitch@9.2.7

1.1.31

Patch Changes

  • 98b2795 Thanks @ardatan! - Improvements on unavailable field selection, and key object projection

  • Updated dependencies [98b2795]:

    • @graphql-tools/stitch@9.2.6

1.1.30

Patch Changes

  • 9238e14 Thanks @ardatan! - Improvements on field merging and extraction of unavailable fields

  • Updated dependencies [9238e14, 4ce3ffc]:

    • @graphql-tools/stitch@9.2.5
    • @graphql-tools/delegate@10.0.8

1.1.29

Patch Changes

  • #6109 074fad4 Thanks @ardatan! - Show responses in debug logging with DEBUG env var

  • Updated dependencies [074fad4, 074fad4]:

    • @graphql-tools/delegate@10.0.7
    • @graphql-tools/stitch@9.2.3

1.1.28

Patch Changes

  • #6091 9bca9e0 Thanks @User, @User! - If the gateway receives a query with an overlapping fields for the subschema, it uses aliases to resolve it correctly.

    Let's say subschema A has the following schema;

      type Query {
    
      }
    
      interface User {
        id: ID!
        name: String!
      }
    
      type Admin implements User {
        id: ID!
        name: String!
        role: String!
      }
    
      type Customer implements User {
        id: ID!
        name: String
        email: String
      }
    

    And let's say the gateway has the following schema instead;

      type Query {
    
      }
    
      interface User {
        id: ID!
        name: String!
      }
    
      type Admin implements User {
        id: ID!
        name: String!
        role: String!
      }
    
      type Customer implements User {
        id: ID!
        name: String!
        email: String!
      }
    

    In this case, the following query is fine for the gateway but for the subschema, it's not;

    query {
      user {
        ... on Admin {
          id
          name # This is nullable in the subschema
          role
        }
        ... on Customer {
          id
          name # This is non-nullable in the subschema
          email
        }
      }
    }
    

    So the subgraph will throw based on this rule OverlappingFieldsCanBeMerged

    To avoid this, the gateway will use aliases to resolve the query correctly. The query will be transformed to the following;

    query {
      user {
        ... on Admin {
          id
          name # This is nullable in the subschema
          role
        }
        ... on Customer {
          id
          name: _nullable_name # This is non-nullable in the subschema
          email
        }
      }
    }
    
  • Updated dependencies [9bca9e0, 9bca9e0, 243c353]:

    • @graphql-tools/stitch@9.2.0
    • @graphql-tools/delegate@10.0.5

1.1.27

Patch Changes

1.1.26

Patch Changes

1.1.25

Patch Changes

1.1.24

Patch Changes

1.1.23

Patch Changes

1.1.22

Patch Changes

1.1.21

Patch Changes

1.1.20

Patch Changes

1.1.19

Patch Changes

1.1.18

Patch Changes

  • #5946 107c021 Thanks @ardatan! - If an interface or scalar type is not annotated for a subgraph explicitly, consider them as a shared type

1.1.17

Patch Changes

1.1.16

Patch Changes

  • 7583729 Thanks @ardatan! - Fix getSubschemaForFederationWithTypeDefs for non-supergraph merging of subgraphs

1.1.15

Patch Changes

1.1.14

Patch Changes

1.1.13

Patch Changes

  • 974df8a Thanks @ardatan! - Debug logging & expose the subgraph schema

  • Updated dependencies [b798b3b]:

    • @graphql-tools/executor-http@1.0.6

1.1.12

Patch Changes

1.1.11

Patch Changes

1.1.10

Patch Changes

  • cda328c3 Thanks @ardatan! - Support for multiple key entrypoints for an object, and avoid sending whole object if possible

  • Updated dependencies [cda328c3]:

    • @graphql-tools/stitch@9.0.2

1.1.9

Patch Changes

1.1.8

Patch Changes

1.1.7

Patch Changes

1.1.6

Patch Changes

1.1.5

Patch Changes

1.1.4

Patch Changes

1.1.3

Patch Changes

1.1.2

Patch Changes

1.1.1

Patch Changes

1.1.0

Minor Changes

1.0.0

Major Changes

Patch Changes

  • Updated dependencies [944a68e8, 8fba6cc1, 944a68e8, 944a68e8, 944a68e8]:
    • @graphql-tools/executor-http@1.0.0
    • @graphql-tools/delegate@10.0.0
    • @graphql-tools/schema@10.0.0
    • @graphql-tools/stitch@9.0.0
    • @graphql-tools/merge@9.0.0
    • @graphql-tools/utils@10.0.0
    • @graphql-tools/wrap@10.0.0

0.0.3

Patch Changes

0.0.2

Patch Changes

0.0.1

Patch Changes