Error on building Next JS project with @apollo/client in the dependency tree #8814
Closed
Description
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:
> 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