apollo-client: createNetworkInterface is not a function
The docs say that you can create a new Network Interface by using
import ApolloClient, { createNetworkInterface } from 'apollo-client';
const networkInterface = createNetworkInterface('http://localhost:8080/graphql');
const client = new ApolloClient({
networkInterface
});
but for me it throws
Uncaught TypeError: (0 , _apolloClient.createNetworkInterface) is not a function
Is there anything that I’m missing?
(I’m using apollo-client with Electron and a normal Graphql Server.)
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 18 (3 by maintainers)
Commits related to this issue
- Merge pull request #108 from kamilkisiela/angular2/new-api Update Angular2 to use new API — committed to apollographql/apollo-client by Urigo 8 years ago
- Merge pull request #108 from apollostack/gschmidt-patch-2 Fix run-on sentence — committed to apollographql/apollo-client by deleted user 8 years ago
I just opened a project and updated
react-apollo
and it detonated everything, which is also highlighting that https://github.com/apollographql/react-apollo is currently some troll documentation.I was using these like this in React Native:
It definitely doesn’t work in React Web with
react-apollo 2.0
.I checked my RN app and even though I installed it last week~, its using
react-apollo 1.4
.I will downgrade back to sub 2.0, and post my results since someone else will surely see this as well.
Thanks to the magic of time travel, here are my results:
There is no 1.5, 1.6, 1.7, 1.8, or 1.9, so that will downgrade you to the newest non-2.0 version, and you can use:
You don’t need to install
apollo-client
.Just kidding,
apollo-client
is included withreact-apollo
. You should see it in node_modules if you burn everything to the ground and just installreact-apollo
1.4~.Here is some bonus code, just in case anyone wants to confirm what works well:
./src/index.js
I imagine you will want to avoid anything to do with this code if you are looking to get to
react-apollo 2.0
.I checked it out and the setup looked haywire breaking change, so I won’t be switching to it ASAP unless someone posts a migration path and usage of
graphql()
andwithApollo()
are virtually identical.same 🔢
I confirm downgrading
react-apollo
from version 2 to 1.4 solved my problem. Special thanks to @amackintosh👋 me too
I solved this problem by using apollo-boost
If the problem raise after update apollo-client to v.2.0 this upgrade instructions may help
same here
I have the same issue.
You use a deprecated function!
To be able to use it you can downgrade react-apollo to 1.4.
yarn upgrade react-apollo@1.4
Also make sure that you’re importing from react-apollo.
@jaroslav-kubicek still throwing
event when
@christiansaiki works perfectly. just learned about this
There is error in docs. Check that you are importing from
apollo-client
, not fromreact-apollo
:import ApolloClient, { createNetworkInterface } from 'apollo-client';