mercurius-typescript icon indicating copy to clipboard operation
mercurius-typescript copied to clipboard

Generated TypeScript code contains references to an undefined name '_Service'?

Open api-haus opened this issue 3 years ago • 2 comments

package.json

  "dependencies": {
    "fastify": "^4.3.0",
    "mercurius": "^10.1.0",
    "mercurius-codegen": "^4.0.1",
  }

Steps to reproduce:

  • Clone https://github.com/api-haus/mercurius-codegen-bug
  • Run npm install && npm run codegen to generate code

TypeScript errors in generated code:

src/generated.ts:148:33 - error TS2304: Cannot find name '_Service'.

148   _Service: ResolverTypeWrapper<_Service>;
                                    ~~~~~~~~

This issue is persistent for many months. I wonder why this is happening. Previously we had a working version and just removed broken code from file so the typings would work correctly.

api-haus avatar Aug 04 '22 11:08 api-haus

As a workaround I can create a global definition for _Service.

export {};

declare global {
  type _Service = any;
}

api-haus avatar Aug 04 '22 13:08 api-haus

as a workaround, you can define new scalar

scalar _Service

jedaan avatar Feb 01 '23 15:02 jedaan