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

Typescript compilation failures after upgrading GraphQL Zeus 5.3.3 -> 5.4.4

Open jeenkhoorn opened this issue 1 year ago • 1 comments

Hi, after upgrading to Graphql Zeus 5.4.4, my Jest tests based on GraphQL Zeus queries fail due to a new Typescript compilation error.

// Errors when running Jest:
src/lib/generated/zeus/typedDocumentNode.ts:25:33 - error TS2345: Argument of type 'Z & { [P in keyof Z]: P extends keyof ValueTypes[R] ? Z[P] : never; }' is not assignable to parameter of type 'ValueTypes[GenericOperation<O>]'.
      Type 'Z & { [P in keyof Z]: P extends keyof ValueTypes[R] ? Z[P] : never; }' has no properties in common with type '{ items?: [{ params?: Variable<any, string> | { name?: string[] | Variable<any, string>; id?: string[] | Variable<any, string>; kind?: string[] | Variable<any, string>;...'.

    25     const str = Zeus(operation, o, {

src/lib/generated/zeus/index.ts:220:23 - error TS2345: Argument of type 'Z & { [P in keyof Z]: P extends keyof ValueTypes[R] ? Z[P] : never; }' is not assignable to parameter of type 'ValueTypes[GenericOperation<O>]'.
      Type 'Z & { [P in keyof Z]: P extends keyof ValueTypes[R] ? Z[P] : never; }' has no properties in common with type '{ items?: [{ params?: Variable<any, string> | { name?: string[] | Variable<any, string>; id?: string[] | Variable<any, string>; kind?: string[] | Variable<any, string>;...'.

    220       Zeus(operation, o, {

The (re)generation of the code with zeus --typedDocumentNode schema.graphql src/lib/generated is part of the build process, so the generated code is not outdated.

I'm in the dark here. What could be the cause of these Typescript issues?

jeenkhoorn avatar Aug 14 '24 09:08 jeenkhoorn

check the ts version on workspace and used in jest. Also your tsconfig if it has changed. Can you also post the code part that is triggering the error?

aexol avatar Aug 23 '24 10:08 aexol

@jeenkhoorn how did you fix this? I have the same issue

emmmarosewalker avatar Oct 15 '24 16:10 emmmarosewalker

For any future readers - graphql-zeus has graphql-zeus-core: "*" in package.json. This seemingly was causing this issue. I fixed it by adding a resolution in our project's main package.json, i.e.

"resolutions": {
	"graphql-zeus-core": "5.2.9"
}

emmmarosewalker avatar Oct 15 '24 17:10 emmmarosewalker