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

useSuspenseQuery defaultOptions errorPolicy ignored #107

Closed
tombryden opened this issue Oct 2, 2023 · 1 comment
Closed

useSuspenseQuery defaultOptions errorPolicy ignored #107

tombryden opened this issue Oct 2, 2023 · 1 comment

Comments

@tombryden
Copy link

Hi,

Setting defaultOptions errorPolicy to "all" in NextSSRApolloClient seems to be ignored.

See demo: https://codesandbox.io/p/github/tombryden/experimental-apollo-suspense-bug

Comment out the error policy in useSuspenseQuery hook, you will see runtime error thrown despite the same error policy being declared in default options in src/apollo/apollo-wrapper.tsx

@jerelmiller
Copy link
Member

Hey @tombryden 👋

useSuspenseQuery uses the watchQuery default options, which is why the behavior you're seeing seems ignored. Try changing query to watchQuery and it will work.

new NextSSRApolloClient({
  // use the `NextSSRInMemoryCache`, not the normal `InMemoryCache`
  cache: new NextSSRInMemoryCache(),
  defaultOptions: {
    watchQuery: {
      errorPolicy: "all",
    },
  },
  // ...
})

I've tested this on a fork of your reproduction and everything works as expected. Hope this helps!

Please reopen this issue or open a new issue if you need anything else!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants