I have several union types in my schema and have added the IntrospectionFragmentMatcher to the InMemoryCache as specified in the docs. I don't think the fragmentMatcher is being used as I am getting these warnings. I'm using "apollo-cache-inmemory": "^0.1.0-0", however when I upgrade the the beta version I get a store update error.
The rest of my apollo stack is:
"apollo-client": "^1.9.3",
"apollo-link": "^0.7.0",
"apollo-link-http": "^0.7.0",
So I managed to fix the fact that the fragmentMatcher was not being picked up. I fixed it by reverting to the old way of installing the fragmentMatcher i.e. placing the property directly in the client's parameter object like so:
const client = new ApolloClient({ link: link, cache: cache, fragmentMatcher: fragment_matcher});
as opposed to placing it on the InMemoryCache config parameter like so:
const cache = new InMemoryCache({
fragmentMatcher: // matcher,
dataIdFromObject: // custom function,
addTypename: true,
customResolvers: // custom resolvers
});
Either the 2.0 upgrade doc needs to change or the library needs to be fixed.
hmm that doesn't seem right. Do you have a reproduction I can look at to verify whats happening?
Fixed with https://github.com/apollographql/apollo-client/pull/2281
It should be on the Cache, but the interface was expecting the .match function instead of the actual Matcher
@serle try beta.5 of the inMemoryCache package 馃憤
@jbaxleyiii thx will do
Thanks: confirming @jbaxleyiii findings & the fix for this issue.
Upgraded to beta.5 but it is still not working. This is my initialization code (where I get fragment matcher errors)
const fragment_matcher = new IntrospectionFragmentMatcher({..}
const cache_config = { addTypename: true, fragmentMatcher: fragment_matcher }
const cache = new InMemoryCache(cache_config)
const link = new HttpLink({ uri: 'http://localhost:4000' })
const client = new ApolloClient({ link: link, cache: cache})
This works:
const fragment_matcher = new IntrospectionFragmentMatcher({..}
const cache_config = { addTypename: true}
const cache = new InMemoryCache(cache_config)
const link = new HttpLink({ uri: 'http://localhost:4000' })
const client = new ApolloClient({ link: link, cache: cache, fragmentMatcher: fragment_matcher })
but fragmentMatcher is in the wrong place according to docs
@serle Did you find a solution for this problem?
@dbelchev I'm still using the second method in my comment above
Most helpful comment
Upgraded to beta.5 but it is still not working. This is my initialization code (where I get fragment matcher errors)
const fragment_matcher = new IntrospectionFragmentMatcher({..} const cache_config = { addTypename: true, fragmentMatcher: fragment_matcher } const cache = new InMemoryCache(cache_config) const link = new HttpLink({ uri: 'http://localhost:4000' }) const client = new ApolloClient({ link: link, cache: cache})This works:
const fragment_matcher = new IntrospectionFragmentMatcher({..} const cache_config = { addTypename: true} const cache = new InMemoryCache(cache_config) const link = new HttpLink({ uri: 'http://localhost:4000' }) const client = new ApolloClient({ link: link, cache: cache, fragmentMatcher: fragment_matcher })but fragmentMatcher is in the wrong place according to docs