josemarluedke / glimmer-apollo

Ember and Glimmer integration for Apollo Client.
https://glimmer-apollo.com
MIT License
39 stars 15 forks source link

Error caused by missing field used as keyField in cache is shadowed #75

Open jelhan opened 1 year ago

jelhan commented 1 year ago

I had an error caused by not querying a field, which was used as keyField in InMemoryCache configuration. It throw the following error:

    Invariant Violation: Missing field 'name' while extracting keyFields from {"foo": "bar","__typename":"Post"}

Debugging was very challenging because that error is shadowed. I was able to get that error by putting a breakpoint here: https://github.com/josemarluedke/glimmer-apollo/blob/1e507ec43a21e14cdcb8b4feacd75b47c9b6cbcc/packages/glimmer-apollo/src/-private/query.ts#L75-L90

The error was not logged in console. QueryResource.error was undefined.