graphql-code-generator-community icon indicating copy to clipboard operation
graphql-code-generator-community copied to clipboard

Unable to use generic-sdk example with ApolloClient v3.7.6

Open christian-englert-etecture opened this issue 2 years ago • 3 comments

Is your feature request related to a problem? Please describe.

First of, thanks for the generator! :)

I'm having a Problem now upgrading ApolloClient to v3.7.6 which introduced this TypeScript feature of "Unconstrained Generics No Longer Assignable to {}" https://devblogs.microsoft.com/typescript/announcing-typescript-4-8/#unconstrained-generics-no-longer-assignable-to

Even tho it's a minor Version bump by ApolloClient it breaks the generic-sdk CodeGenerator with the example for me.

The Example you're suggesting with ApolloClient: https://gist.github.com/akozhemiakin/731b0c1e99eb89b01f80f08f9146b6b6 Does not work anymore as the Generated SDK Requester export type Requester<C = {}, E = unknown> = <R, V> ... is not compatible with the new ApolloClient contstraints on generic types ( ... extends OperationVariables)

Currently I'm using ApolloClient v3.7.5 which works fine. I think moving forward the generated SDK or example should work with ApolloClient v3.7.6 ...

Thank you very much!

Describe the solution you'd like

Maybe the generator could support making the generated

export type Requester ... compatible with ApolloClient's generic type constraints

or there could be an updated example working with ApolloClient v3.7.6+

Describe alternatives you've considered

Trying to fix the code I'm using from the example I'm unable to make it work adding

  • V extends OperationVariables
  • V extends OperationVariables | undefined

constraints :(

Is your feature request related to a problem? Please describe.

No response

Seeing something similar after bumping apollo and codegen versions...

Error: src/generated/graphql.ts:52743:45 - error TS2344: Type 'V' does not satisfy the constraint 'OperationVariables'.

52743 extends Omit<ApolloCore.WatchQueryOptions<V>, 'query' | 'variables'> {} ~

src/generated/graphql.ts:52742:34 52742 interface WatchQueryOptionsAlone<V> ~ This type parameter might need an extends ApolloCore.OperationVariables constraint.

jefbarn avatar Feb 09 '23 16:02 jefbarn

any update on this we also face this type problem.

zeemyself avatar Feb 17 '23 08:02 zeemyself

Any updates on this?

coltenkrauter avatar Jan 18 '25 19:01 coltenkrauter