Packages

@graphql-tools/delegate

12.3.4 · 12 Nov 2026MIT15.8M / weekRepositorynpmAtom feed

Your version

219 stable releases, newest first, by release line. Notes are quoted as the maintainers published them.

  1. 10.x
  2. 10.2.12

    13 Feb 2025
    • Dependencies updates:

  3. 10.2.11

    29 Jan 2025
    • Security

      Add isPrototypePollutingKey to prevent accidential prototype pollution, whenever object manipulation happens with the keys based on the user input, it is validated to prevent prototype pollution.

      For example, WrapQuery takes path which is used to manipulate the object returned to the client. If the user input is __proto__, it will throw an error from now on but previously it would have polluted the prototype.

  4. 10.2.10

    20 Jan 2025
    • While creating a delegation request for the subschema, an selection set should be spreaded on the union type field correctly.

      In case of the following schema;

      type Query {
        foo: Foo
      }
      
      union Foo = Bar | Baz
      
      type Bar {
        id: ID!
        name: String
        age: Age
      }
      
      type Age {
        years: Int
        months: Int
      }
      
      type Baz {
        id: ID!
        name: Name
        age: Int
      }
      
      type Name {
        first: String
        last: String
      }

      If the operation is generated as following;

      query {
        foo {
          id
          name
          age {
            years
            months
          }
        }
      }

      It should be spreaded on the union type field correctly as following;

      query {
        foo {
          ... on Bar {
            id
            age {
              years
              months
            }
          }
          ... on Baz {
            id
            name {
              first
              last
            }
          }
        }
      }
  5. 10.2.9

    24 Dec 2024
    • Dependencies updates:

  6. 10.2.8

    13 Dec 2024
    • Dependencies updates:

  7. 10.2.7

    6 Dec 2024
    • Dependencies updates:

  8. 10.2.6

    4 Dec 2024
    • Dependencies updates:

    • Dependencies updates:

  9. 10.2.5

    3 Dec 2024
    • Do not show internal non-nullability errors in the gateway

  10. 10.2.4

    2 Dec 2024

    Only updates a dependency:@graphql-tools/batch-execute 9.0.8

  11. 10.2.3

    2 Dec 2024
    • Avoid extensions and use `stitchingInfo` for provided fields

  12. 10.2.2

    29 Nov 2024
    • Fix missing key fields in the nested queries

  13. 10.2.1

    27 Nov 2024
    • Dependencies updates:

  14. 10.2.0

    20 Nov 2024
    • Introduce `onDelegationPlan` and `onDelegationStageExecuteDone` hooks

  15. 10.1.3

    19 Nov 2024
    • Thanks @{! - Do not ignore request selection set when overriding the fields

      import { buildSchema, graphql } from 'graphql';
      import { addResolversToSchema } from '@graphql-tools/schema';
      import { stitchSchemas } from '@graphql-tools/stitch';
      import { delegateToSchema } from '@graphql-tools/delegate';
      
      const sub_schema = addResolversToSchema({
        schema: buildSchema(`
        type Query {
          current_user: User
        }
      
        type User {
          id: ID!
          name: String!
          age: Int!
        }
      `),
        resolvers: {
          Query: {
            current_user: () => ({ id: '5', name: 'John Doe', age: 10 }),
          },
        },
      });
      
      const stitched_schema = stitchSchemas({
        subschemas: [
          {
            schema: sub_schema,
            createProxyingResolver: (options) => {
              return (_parent, _args, context, info) => {
                const operationName = info.operation.name ? info.operation.name.value : undefined;
                return delegateToSchema({
                  schema: options.subschemaConfig,
                  operation: options.operation,
                  context,
                  info,
                  operationName,
                });
              };
            },
          },
        ],
        resolvers: {
      
            name: {
              selectionSet: '{ age }',
              resolve: (parent) => `${parent.name}(${parent.age})`, // Age should be here
            },
          },
        },
      });
  16. 10.1.1 – 10.1.22 releases without a noteShow each
  17. 10.1.0

    31 Oct 2024
  18. 10.0.29

    31 Oct 2024
    • #6620 da1de08 Thanks @kroupacz! - - fix subtractSelectionSets() method - find field by its path correctly

  19. 10.0.27 – 10.0.282 releases without a noteShow each
  20. 10.0.26

    17 Oct 2024
  21. 10.0.25

    16 Oct 2024
  22. 10.0.24

    16 Oct 2024
  23. 10.0.23

    16 Oct 2024
    • #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
      }
  24. 10.0.21

    26 Aug 2024
  25. 10.0.20

    26 Aug 2024
    • #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!
      }
  26. 10.0.19

    14 Aug 2024
    • #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,
              },
            },
          });
  27. 10.0.18

    7 Aug 2024
    • #6420 a867bbc Thanks @ardatan! - dependencies updates:

    • #6420 a867bbc Thanks @ardatan! - Pass operation directives correctly to the subschema;

      query {
        hello @someDir
      }
    • #6418 da93c08 Thanks @ardatan! - Fix extra inline fragments for all abstract types in the upstream schema call

      If there are two subschemas like below, the final Node interface is implemented by both Oven and Toaster while they are not implemented in both schemas. In this case the query { products { id ... on Node { id } } } will need to be transformed to { products { id ... on Oven { id } ... on Node { id } } } for the first subschema. But previously the query planner was automatically creating inline fragments for all possible types which was not optimal. Now it adds inline fragments only if this case is seen.

      type Query {
        products: [Product]
      }
      
      union Product = Oven | Toaster
      
      interface Node {
        id: ID!
      }
      
      type Oven {
        id: ID!
      }
      
      type Toaster implements Node {
        id: ID!
        warranty: Int
      }

      And another one like below;

      interface Node {
        id: ID!
      }
      
      type Oven implements Node {
        id: ID!
        warranty: Int
      }
  28. 10.0.17

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

  29. 10.0.15 – 10.0.162 releases with no change for you1 dependency update, 1 without a note@graphql-tools/executor 1.3.0Show each
  30. 10.0.14

    18 Jul 2024
    • #6356 8094c37 Thanks @enisdenjo! - AggregateError errors are GraphQL located errors

      Instead of transforming the AggregateError itself to a GraphQL located error.

      This is because of two reasons:

  31. 10.0.13

    3 Jul 2024
  32. 10.0.12

    1 Jul 2024
  33. 10.0.11

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

    • #6188 e10c13a Thanks @ardatan! - Add subtractSelectionSets to get the diff of two selection sets

    • #6187 dfccfbf Thanks @ardatan! - Do not merge errors and regular resolved objects

      If a subschema returns an error for specific field that is already resolved by another subschema, the error should not be merged with the resolved object.

  34. 10.0.10

    8 May 2024
    • Breaking

      #5274 944a68e8 Thanks @ardatan! - Drop Node 14 support. Require Node.js >= 16

    • Breaking

      #4566 d8dc67aa Thanks @ardatan! - ## Breaking changes

      Schema generation optimization by removing transfomedSchema parameter

      Previously we were applying the transforms multiple times. We needed to introduced some breaking changes to improve the initial wrapped/stitched schema generation performance;

      stitchSchemas doesn't take nested arrays of subschemas

      stitchSchemas no longer accepts an array of arrays of subschema configuration objects. Instead, it accepts an array of subschema configuration objects or schema objects directly.

      stitchSchemas no longer prunes the schema with pruningOptions

      You can use pruneSchema from @graphql-tools/utils to prune the schema instead.

      stitchSchemas no longer respect "@computed" directive if stitchingDirectivesTransformer isn't applied

      Also @graphql-tools/stitch no longer exports computedDirectiveTransformer and defaultSubschemaConfigTransforms. Instead, use @graphql-tools/stitching-directives package for @computed directive. Learn more about setting it up

      computedFields has been removed from the merged type configuration

      MergeTypeConfig.computedFields setting has been removed in favor of new computed field configuration written as:

      merge: {
        MyType: {
          fields: {
            myComputedField: {
              selectionSet: '{ weight }',
              computed: true,
            }
          }
        }
      }

      A field-level selectionSet specifies field dependencies while the computed setting structures the field in a way that assures it is always selected with this data provided. The selectionSet is intentionally generic to support possible future uses. This new pattern organizes all field-level configuration (including canonical) into a single structure.

    • Breaking

      BREAKING CHANGE

  35. 10.0.0 – 10.0.910 releases without a noteShow each
  36. 9.x
  37. 9.0.33 – 9.0.353 releases without a noteShow each

A whole project to check? Paste its package.json in the dependency check: every deprecated, outdated or vulnerable dependency, with what to upgrade to. Free, no account.