-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
using possibleTypes in the cache subsequently requires every test mock to set a __typename #7001
Comments
Here's one error that's completely wrong:
here's the full mock in question. It clearly has a __typename:
|
@xxx This exception (which used to be a warning) was an intentional breaking change introduced by #6055 in Apollo Client 3. Although I get that it's annoying to see so many test failures, your mock data really does need to have the appropriate In your comment #7001 (comment) above, it looks like the object that contains the |
It doesn't sound like there is an outstanding issue here, so closing. Thanks! |
Intended outcome:
I don't get invariant violation errors for every mock that doesn't explicitly include a
__typename
field.Actual outcome:
Every test that uses a mock without
__typename
fails with an invariant violation. This causes hundreds of failures in our test suite. Changing theaddTypename
prop on MockedProvider has no effect on this behavior.How to reproduce the issue:
Add a
possibleTypes
field to your cache, then run a test that uses a mock that doesn't have__typename
set in every object.It looks like this is intended. From writeToStore.js:
It's not clear to me why these behaviors are intertwined like this though. I'd rather not have to wade through all of these failed specs just for
__typename
, when without thepossibleTypes
setting (which only configures a single type out of dozens), things are fine.Versions
System:
OS: Linux 5.3 Ubuntu 19.10 (Eoan Ermine)
Binaries:
Node: 12.16.3 - ~/.nvm/versions/node/v12.16.3/bin/node
Yarn: 1.22.4 - ~/.yarn/bin/yarn
npm: 6.14.4 - ~/.nvm/versions/node/v12.16.3/bin/npm
Browsers:
Chrome: 83.0.4103.116
Firefox: 78.0.2
npmPackages:
@apollo/client: 3.1.4 => 3.1.4
Edit: 3.1.5 has the same issue.
The text was updated successfully, but these errors were encountered: