Skip to content

SyntaxError: Named export 'OperationTypeNode' not found. The requested module 'graphql' is a CommonJS module, which may not support all module.exports as named exports. #7290

@sobolk

Description

@sobolk

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 yarn 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

The release today (https://github.com/ardatan/graphql-tools/releases/tag/release-1752755436363) seems to be regressing ESM based projects.

Our canary tests have started failing at the moment release shipped with the following error:

bcd0740fa72c:testapp110 sobkamil$ npx ampx sandbox --once
file:///Users/sobkamil/playground/testapp110/node_modules/@graphql-codegen/core/node_modules/@graphql-tools/merge/node_modules/@theguild/federation-composition/esm/subgraph/state.js:1
import { Kind, OperationTypeNode, specifiedScalarTypes, DirectiveLocation, } from "graphql";
               ^^^^^^^^^^^^^^^^^
SyntaxError: Named export 'OperationTypeNode' not found. The requested module 'graphql' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:

import pkg from 'graphql';
const { Kind, OperationTypeNode, specifiedScalarTypes, DirectiveLocation, } = pkg;

    at ModuleJob._instantiate (node:internal/modules/esm/module_job:175:21)
    at async ModuleJob.run (node:internal/modules/esm/module_job:258:5)
    at async ModuleLoader.import (node:internal/modules/esm/loader:540:24)
    at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:117:5)

It seems that update of @theguild/federation-composition mentioned in the release might be causing this.

To Reproduce Steps to reproduce the behavior:

I was able to repro this using our product. We depend on you trasitively.

mkdir testapp110
cd testapp110
npm create amplify@latest
npx ampx sandbox --once

I have also created somewhat standalone repro here https://github.com/sobolk/testapp110 . See README.

Expected behavior

The ESM loader error is not present.

Environment:

  • OS: OSX
  • @graphql-tools/...:
  • NodeJS:

Additional context

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions