Nested fragments throw heuristic fragment matching errors
See original GitHub issueIntended outcome:
Was trying to nest inline fragments into another fragment or use an interface, or union. Got an error about heuristic fragment matching.
Actual outcome:
When using nested fragments, unions or interfaces, InMemory will throw a heuristic fragment matching error:
WARNING: heuristic fragment matching going on!
fragment CharacterFields on Character {
... on Droid {
primaryFunction
}
... on Human {
height
}
}
query {
characters {
...CharacterFields
}
}
This works:
query {
characters {
... on Droid {
primaryFunction
}
... on Human {
height
}
}
}
How to reproduce the issue:
https://github.com/ledenis/apollo-introspection-fragment-matcher-issue
Versions
System:
OS: macOS 10.15
Binaries:
Node: 10.16.0 - ~/.nvm/versions/node/v10.16.0/bin/node
Yarn: 1.16.0 - ~/.nvm/versions/node/v10.16.0/bin/yarn
npm: 6.11.3 - ~/.nvm/versions/node/v10.16.0/bin/npm
Browsers:
Chrome: 77.0.3865.90
Firefox: 68.0.2
Safari: 13.0.2
npmPackages:
apollo-angular: 1.7.0 => 1.7.0
apollo-angular-link-http: 1.8.0 => 1.8.0
apollo-angular-link-persisted: 1.1.0 => 1.1.0
apollo-cache-inmemory: 1.6.3 => 1.6.3
apollo-cache-persist: 0.1.1 => 0.1.1
apollo-client: 2.6.4 => 2.6.4
apollo-link: 1.2.13 => 1.2.13
apollo-link-context: 1.0.19 => 1.0.19
apollo-link-error: 1.1.12 => 1.1.12
apollo-link-http: 1.5.16 => 1.5.16
apollo-link-ws: 1.0.19 => 1.0.19
apollo-server-core: 2.9.5 => 2.9.5
apollo-server-testing: 2.9.5 => 2.9.5
Related: https://github.com/apollographql/apollo-client/issues/3397 Partial temporary workaround (doesn’t work at all for interfaces):
const fragmentMatcher = new IntrospectionFragmentMatcher({
introspectionQueryResultData: {
__schema: {
types: []
}
}
});
Issue Analytics
- State:
- Created 4 years ago
- Reactions:33
- Comments:8 (2 by maintainers)
Top Results From Across the Web
Heuristic Fragment matcher warning! How to fix it?
Error : You are using the simple (heuristic) fragment matcher, but your queries contain union or interface types. Should you worry about this?...
Read more >Fragments - Apollo GraphQL Docs
A GraphQL fragment is a piece of logic that can be shared between multiple queries and mutations. ... Every fragment includes a subset...
Read more >[Solved]-How to build GraphQL schema for reverse lookup ...
WARNING: heuristic fragment matching going on!. It seems this is a bug (github issue). In order to fix it, in Apollo settings we...
Read more >Database Engine events and errors - SQL Server
Consult this MSSQL error code list to find explanations for error messages for SQL Server database engine events.
Read more >@apollo/client | Yarn - Package Manager
Fix error thrown by nested keyFields: ["a", ["b", "c"], "d"] type policies when writing ... Bring back an improved form of heuristic fragment...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@chandan-reddy-k
This fixed the problem for me, but just passing an empty array also works. Why fetch the schema ??
This problem was in existence from previous versions of apollo but the latest version ideally shouldn’t throw this warning. I solved this by fetching the entire schema into application. I wrote a detailed blog on this, Check it out:
https://medium.com/@chandan.reddy/whats-going-on-with-the-heuristic-fragment-matcher-in-graphql-apollo-client-e721075e92be