Error on building Next JS project with @apollo/client in the dependency tree
See original GitHub issueIntended 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:
> Build error occurred
TypeError: utilities.maybe is not a function
at Object.<anonymous> (/usr/src/app/node_modules/@apollo/client/link/http/http.cjs.js:178:29)
at Module._compile (internal/modules/cjs/loader.js:1072:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
at Module.load (internal/modules/cjs/loader.js:937:32)
at Function.Module._load (internal/modules/cjs/loader.js:778:12)
at Module.require (internal/modules/cjs/loader.js:961:19)
at require (internal/modules/cjs/helpers.js:92:18)
at Object.<anonymous> (/usr/src/app/node_modules/@apollo/client/core/core.cjs.js:9:12)
at Module._compile (internal/modules/cjs/loader.js:1072:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10) {
type: 'TypeError'
}
error Command failed with exit code 1.
How to reproduce the issue:
The setup is a NextJS application with @apollo/hooks
. Bellow there is some example code from the application:
import React from "react";
import fetch from "cross-fetch";
import { ApolloProvider } from "@apollo/react-hooks";
import { ApolloClient } from "apollo-client";
import { InMemoryCache } from "apollo-cache-inmemory";
import { HttpLink } from "apollo-link-http";
const buildClient = (url) =>
new ApolloClient({
cache: new InMemoryCache(),
link: new HttpLink({ uri: url, fetch: fetch }),
});
const GraphQLProvider = ({ gqlHost, children }) => (
<ApolloProvider client={buildClient(gqlHost)}>{children}</ApolloProvider>
);
export default GraphQLProvider;
And in a component wrapped in the GraphQLProvider
a query is used like so:
...
const { data, loading, error } = useQuery(....);
...
Versions
System:
OS: Linux 4.19 Debian GNU/Linux 10 (buster) 10 (buster)
Binaries:
Node: 14.15.0 - ~/.asdf/installs/nodejs/14.15.0/bin/node
Yarn: 1.22.5 - /usr/bin/yarn
npm: 6.14.8 - ~/.asdf/installs/nodejs/14.15.0/bin/npm
Browsers:
Chrome: 93.0.4577.82
Firefox: 78.14.0esr
npmPackages:
@apollo/react-hooks: 4.0.0 => 4.0.0
apollo-cache-inmemory: 1.6.6 => 1.6.6
apollo-client: 2.6.10 => 2.6.10
apollo-link-http: 1.5.17 => 1.5.17
NextJS version I’m using is 10.0.9
React version ^16.13.1
Issue Analytics
- State:
- Created 2 years ago
- Comments:11 (4 by maintainers)
Top Results From Across the Web
Getting Started With Apollo Client in Next.js
Now we have a GraphQL client we can use within the application, and we're ready to query for some data. However, before we...
Read more >Next.js fails to build due to Dynamic Code Evaluation not ...
js project started failing to compile in build time once i introduced Next-auth dependency to handle social-login within providers (google) and ...
Read more >Why use Next.js with Apollo - LogRocket Blog
Use the Apollo Client with Next.js for caching support, inbuilt loading and error states, and a declarative approach to data fetching.
Read more >Automatically handling Apollo Client errors in your React UI
Next, once your server has been able to parse a query successfully, there's all the things that can go wrong in your resolvers...
Read more >Advanced Features: Debugging - Next.js
At this point, you should have 2 applications in debug mode: the NextJS node application, and the client/ browser application. Debugging with Chrome...
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 FreeTop 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
Top GitHub Comments
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 😃Please try
@apollo/client@3.4.13
(which includes #8817) when you have a chance!