Compatibility between Expo and Apollo Client 2.0

#1

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 ?

#2

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:

#3

Ok thanks ! I will investigate that !

#4

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

#5

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

#6

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 :

#7

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?

#8

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
#9

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