In order to initialize Apollo Client, you must specify link & cache properties on the config
See original GitHub issueThis is really strange and demotivating using Apollo from the very beginning.
Here is your docs:
The only thing you need to get started is the endpoint for your GraphQL server. If you don’t pass in uri directly, it defaults to the /graphql endpoint on the same host your app is served from.
I pass the only thing and your package throws you must specify link & cache properties on the config object
.
How can it be?
Intended outcome: Working client, working app, no erros thrown
Actual outcome:
Error:
In order to initialize Apollo Client, you must specify link & cache properties on the config object.
This is part of the required upgrade when migrating from Apollo Client 1.0 to Apollo Client 2.0.
For more information, please visit:
https://www.apollographql.com/docs/react/basics/setup.html
to help you get started.
How to reproduce the issue:
import { ApolloProvider } from 'react-apollo';
import { ApolloClient } from 'apollo-boost';
render() {
const apolloClient = new ApolloClient({
uri: AppSync.graphqlEndpoint,
});
return (
<ApolloProvider client={apolloClient}>
... app
</ApolloProvider>
)
}
Versions System: OS: macOS High Sierra 10.13.4 Binaries: Node: 8.11.3 - /usr/local/bin/node npm: 5.6.0 - /usr/local/bin/npm Browsers: Chrome: 67.0.3396.99 Safari: 11.1 npmPackages: apollo-boost: ^0.1.4 => 0.1.5 apollo-cache-inmemory: ^1.1.0 => 1.2.0 apollo-client: ^2.0.3 => 2.3.0 apollo-link: ^1.0.3 => 1.2.2 apollo-link-http: ^1.2.0 => 1.5.4 react-apollo: ^2.1.1 => 2.1.3
Issue Analytics
- State:
- Created 5 years ago
- Reactions:39
- Comments:28 (5 by maintainers)
Top GitHub Comments
Switch:
to
If you do that you’ll then be using the
apollo-boost
version of Apollo Client, which doesn’t require you to specify a link/cache. You’re encountering this error becauseapollo-boost
also exports the full version ofapollo-client
, as a named export, for backwards compatibility reasons. So you’re referencing the fullapollo-client
, which requires you to pass in a link/cache.Sorry for the confusion! We know this can be a problem, and are planning on changing this around in the future. Thanks!
I’ve run into so many problems with that tutorial. It makes me reconsider whether to use this library at all.