Bug: `apollo-client` not working with `Nextjs`
yashtotla opened this issue · comments
I tried using @graphprotocol/client-apollo
with @apollo/client
in the default nextjs app.
I modified the default _app.tsx
file so that it matches with the apolllo client example
The build fails with the error https://github.com/yashtotla/nextjs-apollo-graphprotocol-issue/blob/main/build-error.txt
Example repo to reproduce the error: https://github.com/yashtotla/nextjs-apollo-graphprotocol-issue
Repo is set up using create-next-app with typescript. Node version 16. Package manager: yarn
I could get the build to not fail by using MeshApolloLink
instead of GraphApolloLink
// import { GraphApolloLink } from "@graphprotocol/client-apollo";
const { MeshApolloLink } = require("@graphql-mesh/apollo-link");
And initializing the client as follows
const subGraphClient = new ApolloClient({
link: new MeshApolloLink(GraphClient),
cache: new InMemoryCache()
});
But this does not seem ideal
I see you are importing Mesh's Apollo Link with require
. What happens when you import GraphClient's Apollo Link in the same way?
If I change the import to
const { GraphApolloLink } = require("@graphprotocol/client-apollo");
The build is successful. The code compiles with these warnings
./node_modules/@graphql-mesh/utils/esm/defaultImportFn.js
Critical dependency: the request of a dependency is an expression
Import trace for requested module:
./node_modules/@graphql-mesh/utils/esm/defaultImportFn.js
./node_modules/@graphql-mesh/utils/esm/index.js
./.graphclient/index.ts
./node_modules/@graphql-tools/url-loader/esm/index.js
Critical dependency: the request of a dependency is an expression
Import trace for requested module:
./node_modules/@graphql-tools/url-loader/esm/index.js
./node_modules/@graphql-mesh/graphql/esm/index.js
./.graphclient/index.ts
Hi @yashtotla . Had the same issue. Undesirable dirty logs but it's currently working.
See #303 and ardatan/graphql-mesh#2256.