[urql@1.10.1] Just broken
See original GitHub issueHi hi, it’s me again.
Maybe it’s just broken in next-urql
.
Default Client: No client has been specified using urql's Provider.This means that urql will befalling back to defaults including making requests to `/graphql`.
If that's not what you want, please create a client and add a Provider.
Reproduction https://codesandbox.io/s/romantic-fast-8sise?file=/pages/index.js
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
Tweets with replies by Sven Tschui (@sventschui) / Twitter
tl;dr: This is a bug-fix only release and safe to upgrade This release contains some ... Fair point about deps being broken when...
Read more >Athletes Book of Home Remedies | PDF | Pitcher | Foot - Scribd
Athletes Book of Home Remedies - Read book online for free.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
For anybody using a workspace/monorepo and still running into this issue:
Make sure that the
createClient()
method is imported from the sameurql
dependency as anyuseQuery
oruseMutation
hook.In my case, I was using a yarn workspace and its Plug’n’Play feature.
urql
was installed in two of the workspace packages. The setup looked something like this:Package 1
package.json
index.ts
Package 2
package.json
pages/_app.tsx
withUrqlClient()
, under the hood, used thecreateClient()
method of theurql
dependency installed inpackage2
.useSomeData()
, on the other hand, used theuseQuery()
hook of theurql
dependency installed inpackage1
.Therefore, the underlying
Context.Provider
andContext.Consumer
didn’t belong to the sameContext
, resulting in the error message.Fixed it by removing
urql
andnext-urql
frompackage2
, installingnext-urql
inpackage1
and re-exportingwithUrqlClient
.@jshxr I know this is an old closed topic, but just in case you haven’t managed to figure out the mysteries of PnP here’s a little bit of help troubleshooting PnP problems.
There are a couple of
yarn
CLI tools we can use to investigate how our dependencies are defined:yarn why <package-name>
yarn info <package-name>
--virtuals
flag.-A/--all
flag to check this from the top level of our monorepo.Here we can see the
urql
package has@urql/core
andwonka
as dependencies, but also@types/graphql
,@types/react
,graphql
andreact
as peer dependencies. In order for an instance to be the same, it’s peer dependencies must also be satisfied.So, in this output, we need to add
@types/graphql
andgraphql
to the peer dependencies of whichever workspace corresponds to the hash [5abd3] (the crosses at the end of the line indicate this).What should you have done in your example?
Instead of removing
next-urql
andurql
from package2, we should instead addurql
to the peer dependencies of package 1 and also ensure both packages have all ofnext-urql
andurql
’s peer dependencies satisfied by usingyarn info urql -A --virtuals
; preferably all with the same versioning.What if I can’t control the dependencies?
If you’re not the package maintainer, you can enforce dependencies using the
.yarnrc.yml
file. Here’s yarn’s docs on that.Yarn should really have a “how to troubleshoot” dependencies section because none of this is obvious…