graphprotocol / graph-client

The Graph library for building GraphQL-based dapps in a decentralized way.
MIT License
171 stars 45 forks source link

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. #297

Closed schmidsi closed 1 year ago

schmidsi commented 1 year ago

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 commented 1 year ago

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

Codesandbox Link

ardatan commented 1 year ago

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.

schmidsi commented 1 year ago

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 commented 1 year ago

I use Urql for now. Worked great so far.

schmidsi commented 1 year ago

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