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.61k stars 449 forks source link

TS Error when trying to use the next-urql default exchanges #3219

Closed seanparmelee closed 1 year ago

seanparmelee commented 1 year ago

Describe the bug

Hello! 👋 I noticed the Next.js docs mentions:

One added caveat is that these options may not include the exchanges option because next-urql injects the ssrExchange automatically at the right location. If you're setting up custom exchanges you'll need to instead provide them in the exchanges property of the returned client object.

I also see where this is handled in the code.

However, when I try to forgo passing exchanges:

export default withUrqlClient(() => ({
  url: 'http://localhost:3000/graphql',
}))(App);

I receive the following TS error:

Property 'exchanges' is missing in type '{ url: string; }' but required in type 'ClientOptions'.ts(2741)

To reproduce this, please see the reproduction link. You'll need to open a terminal and run yarn tsc to see the error.

Reproduction

https://codesandbox.io/s/vibrant-wozniak-7lhu9m

Urql version

urql v4.0.2 next-urql 5.0.1

Validations

kitten commented 1 year ago

This option is now required, just like with createClient's options and other similar APIs. We may not have caught all places in the docs that need changing since there's many mentioning the client options overall ✌️

seanparmelee commented 1 year ago

Thanks @kitten.

I'm happy to open a PR that corrects the docs. As for the code that's currently defaulting the exchanges, I'm guessing that'll get removed in the next major release of next-urql?

kitten commented 1 year ago

@seanparmelee: I don't think a PR will be needed as the new PR should already be erasing this :v: I've marked it as resolving this issue