Open Cretezy opened 3 years ago
@Cretezy Can you run npm ls react react-dom
and share the output?
Alternatively/additionally, Apollo Client v3.4 is very close to release, and some aspects of importing/exporting React stuff have changed internally, so there's always a chance updating with
npm i @apollo/client@beta
could solve some problems.
@benjamn
➜ yarn why react
yarn why v1.22.10
[1/4] Why do we have the module "react"...?
[2/4] Initialising dependency graph...
[3/4] Finding dependency...
[4/4] Calculating file sizes...
=> Found "react@17.0.2"
info Reasons this module exists
- "_project_#@propty#frontends-mobile" depends on it
- Hoisted from "_project_#@propty#frontends-mobile#react"
- Hoisted from "_project_#@propty#frontends-web#react"
- Hoisted from "_project_#@propty#frontends-storybook#react"
info Disk size without dependencies: "356KB"
info Disk size with unique dependencies: "404KB"
info Disk size with transitive dependencies: "432KB"
info Number of shared dependencies: 3
Done in 0.98s.
➜ yarn why react-dom
yarn why v1.22.10
[1/4] Why do we have the module "react-dom"...?
[2/4] Initialising dependency graph...
[3/4] Finding dependency...
[4/4] Calculating file sizes...
=> Found "react-dom@17.0.2"
info Reasons this module exists
- "_project_#@propty#frontends-web" depends on it
- Hoisted from "_project_#@propty#frontends-web#react-dom"
- Hoisted from "_project_#@propty#frontends-storybook#react-dom"
info Disk size without dependencies: "2.93MB"
info Disk size with unique dependencies: "3.18MB"
info Disk size with transitive dependencies: "3.21MB"
info Number of shared dependencies: 4
Done in 0.72s.
➜ npm ls react react-dom
@propty/frontends-mobile@1.0.0 /.../frontends/mobile
└── (empty)
@benjamn No luck with @apollo/client@3.4.0-rc.21
either
Okay narrowed it down a little.
My original code of using the following works:
useQuery(gql`
query {
me {
id
}
}
`);
However, using a generated hook from the GraphQL code gen, imported from a package in the workspace, does not. We have a package (@propty/core
) in the workspace where the .graphql
files are, and where the code gen happens. We import this package on our web/mobile packages. I've updated the OP with the "real" example (importing a generated hook)
I've tried unhoisting @apollo/client
with no success.
Any ideas?
having the same issue
I've found the source of the problem.
My current yarn workspace looks like:
/
: The root
core
: Where the Apollo Hooks are generatedmobile
: The React Native applications that's problematicweb
Inside mobile/package.json
, I have:
"workspaces": {
"nohoist": [
"**/*"
]
},
And in /package.json
, I have:
"workspaces": {
"packages": [
"web",
"mobile",
"core"
],
"nohoist": [
"**/react",
"**/react/**",
"**/@apollo/client",
"**/@apollo/client/**"
]
},
My core
package has @apollo/client
as a devDependency (mobile
also has it). When I remove @apollo/client
from the core
's devDependency, I can use the hooks correctly.
This doesn't seem to be strictly a problem with @apollo/client
, but more of a Metro/React Native issue.
No matter what I do, as long as @apollo/client
is in the devDependencies, this error appears.
Currently using @apollo/client@3.5.6
. Still getting the same error as OP.
I'm on version 3.11.4 and I'm still having this same problem.
When I try to use two mutations in the same component this occurs.
I feel like this is intermittent and related to hot reload
@MarcosSarges hmmm if its related to hot reload, I'm not sure there is much we can do unfortunately :/. Let me add this to our next team meeting in case someone knows something I don't that might help here.
@MarcosSarges hmmm if its related to hot reload, I'm not sure there is much we can do unfortunately :/. Let me add this to our next team meeting in case someone knows something I don't that might help here.
I will try to investigate and try to bring more details.
Feels like I'm going crazy about this issue. I'm currently using
@apollo/client
withreact-native
in a yarn workspace. I've setup the yarn workspace correctly with the custom metro config required, and the nohoist options. Here are my configs:This works as expected, and normal React hooks works. But using
useQuery
gives me:My application code is:
It seems like it's specifically the
useQuery
hook that breaks, as other hooks there works fine.I've checked and
@apollo/client
andreact
are also properly hoisted, meaning they should not be any weird version issues.