Compatibility between Expo and Apollo Client 2.0

Hello,

I try to setup the Apollo Client 2.0 on my expo app and I got the following error including some packages specific to the last version of Appolo Client :

Unable to resolve module graphql/language/parser from /Users/sofienethibault/Expo/appolo-client-2-0/node_modules/graphql-tag/lib/graphql-tag.umd.js: Module does not exist in the module map

Does it mean that the compatibility between expo and apollo client 2.0 is not yet possible ?

Compatibility is possible. I don’t think you’re pulling in the right module.

It should be imported from react-apollo. Also, you can try running:

watchman watch-del-all, rm -rf node_modules, clearing your exp cache and starting over.

I’m using Apollo 2 with Expo :slight_smile:

Ok thanks ! I will investigate that !

It also looks like you have a typo in the package name: appolo-client-2-0

appolo-client-2-0 is the name of the project not a package.

I do remove all the apollo client packages in the package.json and run =>
watchman watch-del-all && rm -rf $TMPDIR/react-* && rm -rf node_modules/ && npm cache clean --force && yarn install

After that project works well without any Apollo package

But when i add the following lines :

import { ApolloClient, HttpLink, InMemoryCache } from 'apollo-client-preset';
import gql from 'graphql-tag';
import { ApolloProvider, graphql } from 'react-apollo';

and run the following command line :

yarn add apollo-client-preset graphql-tag react-apollo

The same problem appear…

So I think there is a real probleme with Apollo Client 2.0.

If you only use the package react-apollo, that means you work on the 1.0 version if I refer to the doc :

It seems that you’re missing the graphql package, which is required by Apollo Client. Could you try running

yarn add graphql

and see if that helps?

1 Like

Yes you right ! graphql package was missing ! Thanks a lot !

FYI a boilerplate expo apollo 2.0 is available here => https://github.com/allpwrfulroot/yaba-social

3 Likes

Usually we just need to install the packages that we explicitly import. That’s why I forgot to install graphql package :sweat_smile:

1 Like