Open disbelief opened 3 years ago
I guess this is more of an @apollo/client
issue, but certainly relevant to this repo since a large percentage of svelte projects wouldn't have react installed.
There's an open issue about this react peer dependency here: https://github.com/apollographql/apollo-client/issues/7318
A workaround posted there is to import the ApolloClient
and related modules from @apollo/client/core
instead of @apollo/client
TL;DR this fixed it for me:
// App.svelte
<script>
import { ApolloClient, InMemoryCache } from "@apollo/client/core";
import { setClient } from "svelte-apollo";
const client = new ApolloClient({
uri: import.meta.env.SNOWPACK_PUBLIC_GRAPHQL_URI,
cache: new InMemoryCache(),
});
setClient(client);
</script>
//...
Funny question, but I'm trying to use
svelte-apollo
in a new svelte project, but when I try to instantiate the ApolloClient, I'm getting errors that parts of@apollo/client
are referencing an unknown modulereact
.build output:
Seems strange and slightly dirty to have to add react as a dep for my project. Also a little odd because
@apollo/client
specifies react is an optional peer dependency.