Closed svetliomihailov closed 3 years ago
A vary hacky way around the issue was adding custom resolutions in the package.json
file for the previous version of @apollo/client:
"resolutions": {
"@apollo/react-hooks/@apollo/client": "3.4.11",
"raketa-next-client/@apollo/react-ssr/@apollo/client": "3.4.11"
}
It turned out there @apollo/react-ssr
as nested dependency which also uses the latest version of @apollo/client
.
I'm suddenly having this same error when running my tests on a CRA project using @apollo/client
FAIL src/Features/User/Pages/LoginPage.test.tsx
● Test suite failed to run
TypeError: utilities.maybe is not a function
4 |
5 | import { CssBaseline, MuiThemeProvider } from '@material-ui/core'
> 6 | import { ApolloProvider } from '@apollo/client/react'
| ^
7 | import '@fontsource/roboto'
8 | import { client } from 'Util/ApiClient'
9 | import Theme from 'Util/theme'
at Object.<anonymous> (node_modules/@apollo/client/link/http/createHttpLink.js:15:19)
at Object.<anonymous> (node_modules/@apollo/client/core/core.cjs.js:9:12)
at Object.<anonymous> (node_modules/@apollo/client/main.cjs.js:5:12)
at Object.<anonymous> (node_modules/@apollo/client/utilities/utilities.cjs.js:10:10)
at Object.<anonymous> (node_modules/@apollo/client/react/context/context.cjs.js:7:17)
at Object.<anonymous> (node_modules/@apollo/client/react/react.cjs.js:6:15)
at Object.<anonymous> (src/setupTestsRenderer.tsx:6:1)
at Object.<anonymous> (src/Features/User/Pages/LoginPage.test.tsx:2:1)
edit. I don't get the error when I downgrade to @apollo/client@3.4.10
@oskari I'm seeing similar issues as well on the latest version (3.4.12). In my case importing ApolloProvider
from '@apollo/client'
as per the official documentation resolved my issue.
Given the narrow version range and the nature of the problem, I'm hopeful #8817 will be the answer. I'll have a new @apollo/client
version for you to try shortly!
Please try @apollo/client@3.4.13
(which includes #8817) when you have a chance!
@benjamn thank you very much for the super quick response! I tried the new version and it is working :)
I still see the same error even after using "@apollo/client": "^3.4.13"
:(
My other apollo dependencies are:
"@apollo/link-error": "^2.0.0-beta.3"
"@apollo/react-ssr": "^4.0.0"
@VytasMule Do you see any other versions if you do npm ls @apollo/client
? Maybe try removing your .next/
directory and rebuilding (just in case)?
I removed .next/
with node_modules/
before building but it still fails.
After running npm ls @apollo/client
I can see that I have a couple of dependencies:
@keystone-next/fields@4.1.1
@apollo/link-error@2.0.0-beta.3
@apollo/react-ssr@4.0.0
@keystone-next/admin-ui@8.0.2
@keystone-next/cloudinary@2.0.9
Okay, I finally fixed it.
The problem was I had my library as "@apollo/client": "^3.4.13"
not as "@apollo/client": "3.4.13"
.
^
made all the difference :)
Ahh yes, that's a good reminder of something I keep learning and then forgetting: having "some-package": "^3.4.13"
in your dependencies
does not force npm
to upgrade some-package
from an earlier 3.4.x (x < 13) patch version, because the ^
notation allows any version that's minor/patch-compatible with the requested version (including earlier minor/patch versions).
Intended outcome:
I'm using Next JS with Apollo and until today the
next build
command was a success.Actual outcome:
Today upon building the application I got the following error:
How to reproduce the issue:
The setup is a NextJS application with
@apollo/hooks
. Bellow there is some example code from the application:And in a component wrapped in the
GraphQLProvider
a query is used like so:Versions
NextJS version I'm using is
10.0.9
React version^16.13.1