Perhaps I am just not getting what apollo-link-state does, but I figured if I had a "default" value, THAT would show up in my props via the Provider. Yet, I can't locate it. How do you access the "cache" or local state?
I have:
import { ApolloClient, createNetworkInterface } from 'react-apollo';
import { InMemoryCache } from 'apollo-cache-inmemory';
import { withClientState } from 'apollo-link-state';
import dataIdFromObject from './dataIdFromObject';
const defaults = {
NAME: 'Biff'
};
const resolvers = {};
const cache = new InMemoryCache();
const stateLink = withClientState({ cache, resolvers, defaults });
const apolloClient = new ApolloClient({
cache,
link: stateLink,
networkInterface: createNetworkInterface({
uri: `${config.url}/graphql`,
opts: {
credentials: 'include'
}
}),
addTypename: true,
dataIdFromObject
});
I am passing in an empty object for my resolvers as it absolutely makes no sense to replicate all of reducers that are in the backend. I figured that I'd see the "name: Biff" in the props. Nope.
The store is my "redux" store and is not part of this question. I figured with that "client" prop, I'd see my default. Nope.
<ApolloProvider store={this.props.store} client={apolloClient}>
when I log my props in a child component, no sign of cache or "name: Biff" anywhere. How do I get at this local state in my child components. If I update it with a mutation, I should see my components rerender and having access to that new updated local state...but.. where is it?
ApolloProvider
no longer takesstore
as a prop and does not depend on a redux store, period. That's what the InMemoryCache is for. Similarly, links have replacedcreateNetworkInterface
. You shouldn't even be able to import that if you were using version 2.0 – Daniel Rearden