Fragments error when using ApolloTestingModule
See original GitHub issueHello,
I set up a testing suite with ApolloTestingModule
and it worked ok so far. Recently, I added a fragment to my query I got the next error and my test fails.
WARN: 'You're using fragments in your queries, but either don't have the addTypename:
true option set in Apollo Client, or you are trying to write a fragment to the store without the __typename.
Please turn on the addTypename option and include __typename when writing fragments so that Apollo Client
can accurately match fragments.'
HeadlessChrome 67.0.3396 (Mac OS X 10.13.5): Executed 56 of 70 SUCCESS (0 secs / 1.117 secs)
WARN: 'Could not find __typename on Fragment ', 'RepairCase', Object{id: '1', categoryId: '10.10.10', createdAt: '2018-06-29T12:00:00Z', ...}
HeadlessChrome 67.0.3396 (Mac OS X 10.13.5): Executed 56 of 70 SUCCESS (0 secs / 1.117 secs)
WARN: 'DEPRECATION WARNING: using fragments without __typename is unsupported behavior and will be removed in future versions of Apollo client. You should fix this and set addTypename to true now.'
HeadlessChrome 67.0.3396 (Mac OS X 10.13.5): Executed 56 of 70 SUCCESS (0 secs / 1.117 secs)
ERROR: 'WARNING: heuristic fragment matching going on!'
It doesn’t depend on which query I use or which fragment I added. The test doesn’t do any fancy
imports: [
ApolloTestingModule
],
...
backend = TestBed.get(ApolloTestingController);
...
backend.expectOne('xxx').flush(TEST_RESPONSE);
I’m using apollo-angular@1.1.2
Issue Analytics
- State:
- Created 5 years ago
- Reactions:4
- Comments:13 (9 by maintainers)
Top Results From Across the Web
graphql / Apollo test case fails Error: Expected one matching ...
I am trying to write a test for an angular service which I am using with graphql & Apollo. I'm receiving these errors:...
Read more >Testing Apollo in Angular - GraphQL Code Generator
The process is pretty much the same as using a default client but the setup is a bit different: import { ApolloTestingModule, ...
Read more >Fragments - Apollo GraphQL Docs
A GraphQL fragment is a piece of logic that can be shared between multiple queries and mutations. Here's the declaration of a NameParts...
Read more >Getting started with Apollo + GraphQL in Angular - Briebug Blog
The Angular Apollo Client integrates with RxJs and Observables out of the box ... every time an error occurs with an Apollo GraphQL...
Read more >Heuristic Fragment matcher warning! How to fix it?
Apollo client is widely used for managing data fetched via GraphQL and caching is one of the main features it offers. If you...
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
@kamilkisiela I thought the whole point was to not have to do that in tests. Also, if I add
__typename
I will not be able to use type check onconst files: FileType[] = [ ... ]
because__typename
is not a property inFileType
@fetis @wszhi
#786 should allow to use custom cache
Here’s how you can solve the problem thanks to the PR: https://github.com/apollographql/apollo-angular/blob/ff3db3a0e6e68a2b0b0adfea57b3a03984b2058e/packages/apollo-angular/testing/tests/integration.spec.ts#L182-L230