I have the following method in a service within my Angular 6 app;
public getPupilReport(): Observable {
return this.apollo.query<
The cause of the duplicate data is the apollo caching system correctly doing its job.
Apollo identifies an object by its __typename and id (or _id) field. Due to an error in my hardcoded test data there are objects with duplicate IDs. Correcting my data so that all objects of the same type have unique IDs (as they should) fixed this issue.
If the id field is unavailable or the IDs are expected to be duplicated, a custom dataIdFromObject function can be provided to the InMemoryCache constructor to tell Apollo how to correctly normalize such objects.
See here for a better explanation