mercurius-js / mercurius-typescript

TypeScript usage examples and "mercurius-codegen" for Mercurius

Home Page:https://mercurius.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

api-haus opened this issue · comments

package.json

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

Steps to reproduce:

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.

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

export {};

declare global {
  type _Service = any;
}
commented

as a workaround, you can define new scalar

scalar _Service