Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apollo2.0 - FragmentMatcher not enabled/picked up #2246

Closed
serle opened this issue Oct 3, 2017 · 9 comments
Closed

Apollo2.0 - FragmentMatcher not enabled/picked up #2246

serle opened this issue Oct 3, 2017 · 9 comments
Milestone

Comments

@serle
Copy link

serle commented Oct 3, 2017

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",

@serle
Copy link
Author

serle commented Oct 3, 2017

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.

@serle serle changed the title Apollo2.0 - WARNING: heuristic fragment matching going on! Apollo2.0 - FragmentMatcher not enabled/picked up Oct 5, 2017
@jbaxleyiii
Copy link
Contributor

hmm that doesn't seem right. Do you have a reproduction I can look at to verify whats happening?

@jbaxleyiii jbaxleyiii added this to the 2.0 milestone Oct 10, 2017
@jbaxleyiii
Copy link
Contributor

Fixed with #2281

It should be on the Cache, but the interface was expecting the .match function instead of the actual Matcher

@jbaxleyiii
Copy link
Contributor

@serle try beta.5 of the inMemoryCache package 👍

@serle
Copy link
Author

serle commented Oct 11, 2017

@jbaxleyiii thx will do

@eugene1g
Copy link

Thanks: confirming @jbaxleyiii findings & the fix for this issue.

@serle
Copy link
Author

serle commented Oct 12, 2017

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

@dbelchev
Copy link

@serle Did you find a solution for this problem?

@serle
Copy link
Author

serle commented Jan 25, 2018

@dbelchev I'm still using the second method in my comment above

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants