Packages

@graphql-tools/delegate

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

Your version

10.1.3

19 Nov 2024Where it was published

10.2.23 is the newest release of 10.x.

In short

1 fixed

Release note

The section about @graphql-tools/delegate of a note shared by several packages.

Patch Changes

  • 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
          },
        },
      },
    });

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.