urql-graphql / urql

The highly customizable and versatile GraphQL client with which you add on features like normalized caching as you grow.
https://urql.dev/goto/docs
MIT License
8.55k stars 444 forks source link

storage missing in typed graphcache #3455

Closed villesau closed 7 months ago

villesau commented 7 months ago

Describe the bug

When updating to latest urql and codegenerators, I'm getting following type-error:

src/client/graphql/client.ts:78:37 - error TS2345: Argument of type '{ keys: { ...: () => null; }; updates: { Mutation: { ...: (result: { ...: WithTypename<ReviewRequest>[]; }, args: ..., cache: Cache) => void; ... 25 more ...; ......' is not assignable to parameter of type 'GraphCacheConfig'.
  Property 'storage' is missing in type '{ keys: { ... }; updates: { Mutation: { ...: (result: { ...: WithTypename<ReviewRequest>[]; }, args: ..., cache: Cache) => void; ... 25 more ...; ...' but required in type 'OfflineExchangeOpts'.

 78     cacheExchange<GraphCacheConfig>({
                                        ~
 79       keys: {
    ~~~~~~~~~~~~~
... 
435       },
    ~~~~~~~~
436     }),
    ~~~~~

  node_modules/@urql/exchange-graphcache/dist/urql-exchange-graphcache.d.ts:115:5
    115     storage: StorageAdapter;
            ~~~~~~~
    'storage' is declared here.

Is storage now needed or is the type-error a bug?

Reproduction

-

Urql version

"urql": "^4.0.6",  
"@urql/devtools": "^2.0.3",
"@urql/exchange-auth": "^2.1.6",
"@urql/exchange-graphcache": "^6.4.0",
"@urql/exchange-retry": "^1.2.0",

Versions without issues:

"urql": "^4.0.2",
"@urql/devtools": "^2.0.3",
"@urql/exchange-auth": "^2.1.2",
"@urql/exchange-graphcache": "^6.0.4",
"@urql/exchange-retry": "^1.2.0",

Validations

JoviDeCroock commented 7 months ago

That's a bug in latest graphcache codegen, have a PR open there but not much luck 😅

I'll rebase and ping some folks https://github.com/dotansimha/graphql-code-generator-community/pull/476

Workaround is Omit<Graphcacheconfig, 'storage'>

villesau commented 7 months ago

I did everything within my power to move it forward and 👍ed the PR! Thanks for the workaround!

JoviDeCroock commented 7 months ago

Updated my PR going to close this out as it's not in our hands