Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(graphcache): type missmatch between graphql-code-generator and graphcache #2639

Closed
3 tasks done
dargmuesli opened this issue Aug 23, 2022 · 7 comments
Closed
3 tasks done
Labels
needs more info ✋ A question or report that needs more info to be addressable

Comments

@dargmuesli
Copy link
Contributor

Describe the bug

I hit the same issue as in #1654 again.
I use

{
    "@urql/core": "2.6.1",
    "@urql/exchange-graphcache": "4.4.3",
    "@urql/vue": "0.6.4",
    "@graphql-codegen/cli": "2.11.5",
    "@graphql-codegen/typescript": "2.7.3",
    "@graphql-codegen/typescript-operations": "2.5.3",
    "@graphql-codegen/typescript-urql-graphcache": "2.3.3",
    "@graphql-codegen/typescript-vue-urql": "2.3.3",
    "@graphql-codegen/urql-introspection": "2.2.1"
}

The exact error:

plugins/urql.ts:68:31 - error TS2345: Argument of type 'GraphCacheConfig' is not assignable to parameter of type 'Partial<CacheExchangeOpts>'.
  Types of property 'updates' are incompatible.
    Type 'GraphCacheUpdaters | undefined' is not assignable to type 'Partial<UpdatesConfig> | undefined'.
      Type 'GraphCacheUpdaters' is not assignable to type 'Partial<UpdatesConfig>'.
        Types of property 'Mutation' are incompatible.
          Type '{ accountDelete?: ((parent: { accountDelete: Maybe<WithTypename<AccountDeletePayload>>; }, args: MutationAccountDeleteArgs, cache: Cache, info: ResolveInfo) => void) | undefined; ... 66 more ...; uploadCreate?: ((parent: { ...; }, args: MutationUploadCreateArgs, cache: Cache, info: ResolveInfo) => void) | undefined;...' is not assignable to type '{ [fieldName: string]: (parent: DataFields, args: Variables, cache: Cache, info: ResolveInfo) => void; } | undefined'.
            Type '{ accountDelete?: ((parent: { accountDelete: Maybe<WithTypename<AccountDeletePayload>>; }, args: MutationAccountDeleteArgs, cache: Cache, info: ResolveInfo) => void) | undefined; ... 66 more ...; uploadCreate?: ((parent: { ...; }, args: MutationUploadCreateArgs, cache: Cache, info: ResolveInfo) => void) | undefined; }' is not assignable to type '{ [fieldName: string]: (parent: DataFields, args: Variables, cache: Cache, info: ResolveInfo) => void; }'.
              Property 'accountDelete' is incompatible with index signature.
                Type '(parent: { accountDelete: Maybe<WithTypename<AccountDeletePayload>>; }, args: MutationAccountDeleteArgs, cache: Cache, info: ResolveInfo) => void' is not assignable to type '(parent: DataFields, args: Variables, cache: Cache, info: ResolveInfo) => void'.
                  Types of parameters 'parent' and 'parent' are incompatible.
                    Property 'accountDelete' is missing in type 'DataFields' but required in type '{ accountDelete: Maybe<WithTypename<AccountDeletePayload>>; }'.

68   const cache = cacheExchange(cacheConfig)

Should I post more details here or to @graphql-codegen?

Reproduction

https://github.com/maevsi/maevsi/runs/7967037590?check_suite_focus=true#step:5:1647

Urql version

2.6.1 as well as 3.0.1

Validations

  • I can confirm that this is a bug report, and not a feature request, RFC, question, or discussion, for which GitHub Discussions should be used
  • Read the docs.
  • Follow our Code of Conduct
@JoviDeCroock
Copy link
Collaborator

Have you tries running a dedupe command? Sometimes package managers start creating duplicate versions which can lead to this

@dargmuesli
Copy link
Contributor Author

Dedupe command of what? Duplicate versions of what? Shall I reinstall node_modules or recreate the lockfile?

@JoviDeCroock
Copy link
Collaborator

JoviDeCroock commented Aug 23, 2022

Something like https://www.npmjs.com/package/pnpm-deduplicate package has not a lot of downloads for npm and yarn this is built-in 😅

Might be related pnpm/pnpm#3517

@JoviDeCroock
Copy link
Collaborator

JoviDeCroock commented Aug 23, 2022

@kitten looked at your code and pointed rightfully out that you are using the generic wrong here https://github.com/maevsi/maevsi/blob/8f6eedd191ce08a950d92cac1f94c0cebd6d5cb6/nuxt/plugins/urql.ts#L66

  const cache = cacheExchange<GraphCacheConfig>(cacheConfig)

should do the trick

@dargmuesli
Copy link
Contributor Author

Thank you for your suggestions and looking into the code! Sadly, pnpm-deduplicate reports no duplicates and adding the generic just moves eslint's red squiggly line from (cacheConfig) to <GraphCacheConfig>.
Any other ideas? Should I post/link other source files as well?

@JoviDeCroock JoviDeCroock changed the title again: Property is missing in type 'DataFields' but required in type ... (graphcache): type missmatch between graphql-code-generator and graphcache Aug 23, 2022
@JoviDeCroock
Copy link
Collaborator

JoviDeCroock commented Aug 23, 2022

Hmm this is kind off weird, I just tried this config in one of my own projects where we have similar fields where parent resolves to a non-nullable field but for some reason it isn't erroring out there, looking a bit deeper but this could be a TypeScript version/config issue

EDIT: we are using the same typescript version - a minimal reproduction would help here (ts playground/...) 😅 could also be that the gql-codegen folks have experience with this type of issue CC @dotansimha

@JoviDeCroock JoviDeCroock added the needs more info ✋ A question or report that needs more info to be addressable label Sep 3, 2022
@dargmuesli
Copy link
Contributor Author

I do not face this issue anymore currently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs more info ✋ A question or report that needs more info to be addressable
Projects
None yet
Development

No branches or pull requests

2 participants