Skip to content

Cryptic runtime error when running hive-gateway supergraph  #8267

@ejkg

Description

@ejkg

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'm having trouble replicating this bug in a smaller context. I've got a very cryptic error from sucrase being thrown when I run hive-gateway supergraph. This command produces a runtime error which doesn't seem to be caught by typescript - yet the errors suggest this is a typescript issue.

[2025-01-13T21:54:27.638Z] ERROR  SyntaxError [Error]: Unexpected token (10891:37)
    at unexpected (/Users/ekjg/project/node_modules/.pnpm/sucrase@3.35.0/node_modules/sucrase/dist/parser/traverser/util.js:99:15)
    at tsParseNonArrayType (/Users/ekjg/project/node_modules/.pnpm/sucrase@3.35.0/node_modules/sucrase/dist/parser/plugins/typescript.js:542:20)
    at tsParseArrayTypeOrHigher (/Users/ekjg/project/node_modules/.pnpm/sucrase@3.35.0/node_modules/sucrase/dist/parser/plugins/typescript.js:546:3)
    at tsParseTypeOperatorOrHigher (/Users/ekjg/project/node_modules/.pnpm/sucrase@3.35.0/node_modules/sucrase/dist/parser/plugins/typescript.js:587:5)
    at tsParseIntersectionTypeOrHigher (/Users/ekjg/project/node_modules/.pnpm/sucrase@3.35.0/node_modules/sucrase/dist/parser/plugins/typescript.js:594:3)
    at tsParseUnionTypeOrHigher (/Users/ekjg/project/node_modules/.pnpm/sucrase@3.35.0/node_modules/sucrase/dist/parser/plugins/typescript.js:604:3)
    at tsParseNonConditionalType (/Users/ekjg/project/node_modules/.pnpm/sucrase@3.35.0/node_modules/sucrase/dist/parser/plugins/typescript.js:793:3)
    at tsParseType (/Users/ekjg/project/node_modules/.pnpm/sucrase@3.35.0/node_modules/sucrase/dist/parser/plugins/typescript.js:756:3)
    at tsParseTypeArguments (/Users/ekjg/project/node_modules/.pnpm/sucrase@3.35.0/node_modules/sucrase/dist/parser/plugins/typescript.js:1160:5)
    at tsParseTypeReference (/Users/ekjg/project/node_modules/.pnpm/sucrase@3.35.0/node_modules/sucrase/dist/parser/plugins/typescript.js:162:5) {
  pos: 593782,
  loc: { line: 10891, column: 37 }
} 

I can "fix" the issue by omitting a particular resolver file from the gateway config. However something strange. If I comment all of the code from the file it still doesn't resolve the issue, only if I remove the reference from my additionalResolvers in gateway.config does it work

// customer-resolvers.ts
export const customResolvers: Resolvers<GraphQLContext> = {
    // ...Resolvers
}
// gateway.config.ts

import { customResolvers } from "./src/custom-resolvers.ts";

export const gatewayConfig = defineConfig({
  supergraph: "./src/supergraph/schema.graphql",
  additionalResolvers: [ 
        customResolvers,
        // ... other custom resolvers
    ],
  plugins: (gatewayContext) => {
        // ... plugins
    }
});

When I comment out custom resolvers like this:

// gateway.config.ts

import { customResolvers } from "./src/custom-resolvers.ts";

export const gatewayConfig = defineConfig({
  supergraph: "./src/supergraph/schema.graphql",
  additionalResolvers: [ 
        // customResolvers,
        // ... other custom resolvers
    ],
  plugins: (gatewayContext) => {
        // ... plugins
    }
});

The gateway builds and executes the supergraph as expected.

Just to summarize. I believe the issue has to do with custom resolvers in the hive gateway because that appears to be the trigger for causing the cryptic error.

To Reproduce Steps to reproduce the behavior:

Still working on isolating the actual issue.

Expected behavior

Mesh composes the supergraph properly, but the gateway is unable to run our custom resolvers.

Environment:

  • OS: macos 15.2
  • "@graphql-hive/gateway": "^1.7.8":
  • NodeJS: v22.9.0

Additional context

Other relevant packages and their versions:

// dependencies
    "@graphql-hive/core": "^0.8.3",
    "@graphql-hive/envelop": "^0.33.11",
    "@graphql-hive/gateway": "^1.7.8",
    "@graphql-hive/gateway-runtime": "^1.4.7",
    "@graphql-tools/utils": "^10.6.2",

// dev dependencies
    "@graphql-codegen/add": "^5.0.3",
    "@graphql-codegen/cli": "^5.0.3",
    "@graphql-codegen/typescript": "^4.1.2",
    "@graphql-codegen/typescript-resolvers": "^4.4.1",
    "@graphql-mesh/compose-cli": "^1.3.5",
    "@graphql-mesh/types": "^0.103.11",

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions