question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Fragments error when using ApolloTestingModule

See original GitHub issue

Hello,

I set up a testing suite with ApolloTestingModuleand 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:closed
  • Created 5 years ago
  • Reactions:4
  • Comments:13 (9 by maintainers)

github_iconTop GitHub Comments

11reactions
adgoncalcommented, Oct 6, 2018

@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 on const files: FileType[] = [ ... ] because __typename is not a property in FileType

2reactions
kamilkisielacommented, Aug 30, 2018
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found