graph-client icon indicating copy to clipboard operation
graph-client copied to clipboard

SyntaxError: Named export 'ApolloLink' not found. The requested module '@apollo/client' is a CommonJS module, which may not support all module.exports as named exports.

Open schmidsi opened this issue 1 year ago • 4 comments

Running into this error while trying to load Graph Client with Apollo and Next.js.

Relevant code might be here: https://github.com/schmidsi/hackathon-starterkit/blob/main/frontend/lib/apolloClient.js

schmidsi avatar Oct 22 '22 09:10 schmidsi

Isolated repository: https://github.com/schmidsi/graph-client-apollo-next

Codesandbox Link

schmidsi avatar Oct 22 '22 14:10 schmidsi

I think it is an issue with Apollo Client. https://github.com/apollographql/apollo-feature-requests/issues/287 However we can convert named imports to default or * as but this would break treeshaking.

ardatan avatar Oct 22 '22 14:10 ardatan

Thanks for investigating. For my current purpose of building a tech demo/starterkit for the full Graph stack, tree shaking is not a hard requirement. Not sure about other users though?

If there is a fix that we can implement now and remove after Apollo Client fixed it on their side, I think this would be the way to go. Happy to implement a hack in my repo like resolutions or transpileModules but I don't think that this will work in that situation? I'm not an expert with this whole transpiling, importing thing.

schmidsi avatar Oct 22 '22 15:10 schmidsi

I use Urql for now. Worked great so far.

schmidsi avatar Oct 22 '22 17:10 schmidsi

@ardatan Would it make sense to leave this issue open as the problem with ApolloLink persists? Other people might run into the same problem.

schmidsi avatar Oct 28 '22 10:10 schmidsi