FredKSchott / create-snowpack-app

The all-in-one app template for Snowpack. [moved]

Home Page:https://www.snowpack.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

snowpack react project does not work with @apollo/client

canercandan opened this issue · comments

Hi,

I need to use the Apollo React client in my project and using Snowpack it does not seem to work because @apollo/client uses a "require()" instruction somewhere in its bundle, is there any documented workaround for those kind of setup, also according to pika @apollo/client seems to be fine in terms of exposing a module endpoint.

Thanks

I can't reproduce, this works fine for me:

// first, npm install "@apollo/client" & "graphql@^14"

// src/index.js
import * as ap from '@apollo/client';
console.log(ap);

Thanks @FredKSchott for getting back to me that quick,

the issue actually occurs when using "ApolloProvider" from "@apollo/client" as such:

import {
  ApolloClient,
  ApolloProvider,
} from "@apollo/client"

and using it later:

const client = new ApolloClient(...)

render(
  <React.StrictMode>
    <ApolloProvider client={client}>
      <div>Dummy text</div>
    </ApolloProvider>
  </React.StrictMode>,
  document.getElementById("root")
)

thanks

Thanks! I can reproduce. This is an issue in Apollo's v3 beta version, unfortunately. I filed an issue here: apollographql/apollo-client#6352 (looks like it's been reported before though). Hopefully they fix before v3.0.0.

Until then, you'll want to use their non-beta via v2 release. pika.dev is currently build with Snowpack and Apollo and is using this branch, and it works great.

The Apollo team fixed the issue, the package should now work as of @apollo/client@3.0.0-beta.53

apollographql/apollo-client#6352