graphql-mesh icon indicating copy to clipboard operation
graphql-mesh copied to clipboard

GraphQL SDL file loading broken in versions @graphql-mesh/cli >0.91.2

Open ejkg opened this issue 5 months ago • 0 comments

Issue workflow progress

Progress of the issue based on the Contributor Workflow

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

Please make sure Mesh 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

I am unable to run mesh dev or mesh start on any build.

The result of either command creates this output:

[2024-08-27T13:09:38.485Z] ERROR 🕸️  Mesh /Users/path/to/project/src/graphql/modules/data-source-a/file.ts
extend type TypeFromSomeDataSource {
       ^^^^

SyntaxError: Unexpected identifier 'type'
    at wrapSafe (node:internal/modules/cjs/loader:1281:20)
    at Module._compile (node:internal/modules/cjs/loader:1321:27)
    at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)
    at Module.load (node:internal/modules/cjs/loader:1208:32)
    at Module._load (node:internal/modules/cjs/loader:1024:12)
    at Module.require (node:internal/modules/cjs/loader:1233:19)
    at require (node:internal/modules/helpers:179:18)
    at jiti (/Users/path/to/project/node_modules/@graphql-mesh/include/node_modules/jiti/dist/jiti.js:1:244799)
    at /Users/path/to/project/src/graphql/modules/barcode-scanner/index.ts:2:46
    at evalModule (/Users/path/to/project/node_modules/@graphql-mesh/include/node_modules/jiti/dist/jiti.js:1:247
    at jiti (/Users/path/to/project/node_modules/@graphql-mesh/include/node_modules/jiti/dist/jiti.js:1:245241)
    at /Users/path/to/project/src/graphql/additionalResolvers.ts:5:23
    at evalModule (/Users/path/to/project/node_modules/@graphql-mesh/include/node_modules/jiti/dist/jiti.js:1:247
    at jiti (/Users/path/to/project/node_modules/@graphql-mesh/include/node_modules/jiti/dist/jiti.js:1:245241)
    at /Users/path/to/project/.mesh/index.ts:41654:32
    at async Promise.all (index 0)
    at async Object.getMeshOptions (/Users/path/to/project/.mesh/index.ts:41653:31)
    at async Object.handler (/Users/path/to/project/node_modules/@graphql-mesh/cli/cjs/index.js:194:33)

scrubbed for PII.

To Reproduce Steps to reproduce the behavior:

You will need the following components to test this:

  • at least one configured mesh data source.
  • extend type <some type build from that data source>
  • run mesh dev or try to run in prod mode mesh build && mesh start

Expected behavior

Expect to properly load GraphQL schema files from .graphql files, which unfortunately doesn't happen. Mesh appears to treat the file as a typescript file because the module system doesn't recognize the import as a non-TS(JS) file.

Environment:

  • OS: Sonoma 14.6.1 (23G93 - Apple Silion M1)
  • @graphql-mesh/0.95.2:
  • NodeJS: 20.17

Additional context

It's worth mentioning that this is also happening in integration environments that we have to run E2E tests as well.

ejkg avatar Aug 27 '24 15:08 ejkg