I getting warning that
You are using the simple (heuristic) fragment matcher, but your queries contain union or interface
types.
But I am not using any interface or union type. Is there any way i can check why i am getting this.
@abubakkarbutt could you create a small reproduction or share more code to help us figure out what is going on?
@jbaxleyiii I am sorry for late response. Actually i was using fragment, not on UNIONS or INTERFACE but for regular GraphQL types. I removed those fragments and warning disappeared.
Issue is when using fragments on regular types then it should not show this warning.
fragmentMatcher is for UNION and INTERFACE not for regular types
This issue has been automatically marked as stale becuase it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions to Apollo Client!
This issue has been automatically closed because it has not had recent activity after being marked as stale. If you belive this issue is still a problem or should be reopened, please reopen it! Thank you for your contributions to Apollo Client!
bump
also having this issue
Apollo Client 2.0 also having this issue .
bump
bump
Encountered this issue in Apollo 2 as well.
Specifically when I used a fragment as the return value of a mutation
Bump
Apollo Client 2.2.1 also having this issue
I'm getting it as well. More details here:
bump, also having this issue
I am using apollo-client 2.4.2 and I am also seeing this
Anyone found a way to debug what's going on? It would be helpful if apollo-client logged something about the problematic queries.
same
Same!
Check if you're using unions/fragments/interfaces, as you'll see this error if you don't do the proper setup.
import { InMemoryCache, IntrospectionFragmentMatcher } from 'apollo-cache-inmemory';
import introspectionQueryResultData from './fragmentTypes.json';
const fragmentMatcher = new IntrospectionFragmentMatcher({
introspectionQueryResultData,
});
// create apollo cache and setup normalization features with dataIdFromObject
const cache = new InMemoryCache({
dataIdFromObject: o => o.id,
fragmentMatcher,
});
https://www.apollographql.com/docs/react/advanced/fragments.html#fragment-matcher
The warning I was receiving was....
WARNING: heuristic fragment matching going on
I was able to resolve this by adding the __typename
to my update.
cache.writeFragment({
id: `MySchema:${someId}`,
fragment: gql`
fragment MyFragment on MySchema {
someField
}
`,
data: {
someField: "some value",
__typename: "MySchema"
}
});
same !
I had some leftovers in localStorage causing this. I just manually removed the localStorage keyval and it resolved itself. I know this doesn't address the issue, but it helped me, hopefully it'll help others.
I ran into this problem again, but slightly different than the last time I commented. Instead of not including the __typename
field, I had included it, but with the wrong value. Once I updated it to the correct value, this error went away.
Mine was caused by incorrect payload on the optimistic optimisticResponse section.
I had the same issue. It was happening because I tried to cache.writeQuery
another type (another type in __typename
) than I put in fragment myType on SomeType {...}
.
I fixed using fetchPolicy: "no-cache"
.
Most helpful comment
Apollo Client 2.2.1 also having this issue