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

(next-urql) - doing resetUrqlClient doesn't refetch the graphql queries and uses previous client or previous ssr cache #1714

Closed
Biboswan opened this issue Jun 9, 2021 · 0 comments · Fixed by #1715
Labels
bug 🐛 Oh no! A bug or unintented behaviour.

Comments

@Biboswan
Copy link
Contributor

Biboswan commented Jun 9, 2021

import { withUrqlClient, SSRExchange, NextUrqlContext } from 'next-urql'
import { dedupExchange, cacheExchange, fetchExchange, ClientOptions, Client } from 'urql'

withUrqlClient(
    (_ssrExchange: SSRExchange, ctx?: NextUrqlContext): ClientOptions => {
      const user = ctx?.getUserData ? ctx.getUserData() : getUserData()
      const exchanges = [dedupExchange, cacheExchange, _ssrExchange, fetchExchange]

      if (process.env.NODE_ENV !== 'production' && process.browser) {
        exchanges.unshift(require('@urql/devtools').devtoolsExchange)
      }

      return {
        url: "https://graphql.fauna.com/graphql",//meteorBackend.graphql,
        suspense: true,
        exchanges,
        fetchOptions: {
          headers: {
            authorization: "Basic Zm5BRFFVdWNRb0FDQ1VpZDAxeXVIdWt2SnptaVY4STI4a2R6Y0p2UDo=",//user?.token
          },
          credentials: 'same-origin',
        },
      }
    },
    { ssr: true }
  )(UrqlWrapper(Component)

urql version & exchanges:
urql: 2.0.3
next-urql: 3.1.0
exchanges:
production: [dedupExchange, cacheExchange, _ssrExchange, fetchExchange]
development: [devtoolsExchange,dedupExchange, cacheExchange, _ssrExchange, fetchExchange]

Screenshot 2021-06-09 at 7 15 20 PM

Reset calls the resetUrqlClient.

@Biboswan Biboswan added the bug 🐛 Oh no! A bug or unintented behaviour. label Jun 9, 2021
@Biboswan Biboswan changed the title doing resetUrqlClient doesn't refetch the graphql queries and uses previous client or previous ssr cache (next-urql)doing resetUrqlClient doesn't refetch the graphql queries and uses previous client or previous ssr cache Jun 16, 2021
@Biboswan Biboswan changed the title (next-urql)doing resetUrqlClient doesn't refetch the graphql queries and uses previous client or previous ssr cache (next-urql) - doing resetUrqlClient doesn't refetch the graphql queries and uses previous client or previous ssr cache Jun 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Oh no! A bug or unintented behaviour.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant