Skip to content

Inability to override built-in scalars with mapSchema #7787

Description

@mderriey

Issue workflow progress

Progress of the issue based on the
Contributor Workflow

  • 1. The issue provides a reproduction available on Github, Stackblitz or CodeSandbox

    Make sure to fork this template and run npm run generate in the terminal.

    Please make sure the GraphQL Tools package versions under package.json matches yours.

  • 2. A failing test has been provided
  • 3. A local solution has been provided
  • 4. A pull request is pending review

Describe the bug

@graphql-tools/utils allowed to override built-in scalars with mapSchema until #5294.

We caught that thanks to our tests when we updated to the latest version.

I'm a bit surprised that this behavioural breaking change got flagged as a patch change in the release notes (https://the-guild.dev/graphql/tools/changelogs/utils).

To Reproduce Steps to reproduce the behavior:

export function overrideIDScalar(schema: GraphQLSchema): GraphQLSchema {
  return mapSchema(schema, {
    [MapperKind.SCALAR_TYPE]: (type) => {
      if (type.name === 'ID') {
        return customIDScalar
      }
      return type
    },
  })
}

Expected behavior

The ID built-in scalar in the executable schema points to the custom scalar.

Environment:

  • OS: Windows for local dev, Linux when deployed
  • @graphql-tools/utils: 10.11.0
  • NodeJS: 22.14.0

Additional context

I'm not expecting that the library will revert to the original behaviour, but an issue will hopefully help others in the same situation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions