Skip to content
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

throw and error/warn when "possibleTypes" are not configured and data requiring them is queried #6929

Open
capaj opened this issue Aug 28, 2020 · 4 comments

Comments

@capaj
Copy link
Contributor

capaj commented Aug 28, 2020

Please add a throw or a warning when "possibleTypes" are not configured and data requiring them is queried. Currently apollo-client returns empty object which obviously wreaks havoc at runtime.

Resolving this issue should make this common misconfiguration issue easier to identify and resolve: #6632

@benjamn
Copy link
Member

benjamn commented Aug 28, 2020

@capaj This will be happening in v3.2.0 as part of #6901, thanks to 03930ee.

@benjamn
Copy link
Member

benjamn commented Sep 10, 2020

Unfortunately, I think I spoke too soon, since any fragment's type condition could match a given __typename exactly, without any help from possibleTypes.

This is a problem for identifying (and warning about) fragments that will never match, since the client doesn't know which types are abstract (and thus require an entry in possibleTypes) and which types might be concrete (and thus could match exactly). Communicating this information to the client/cache would most likely involve adding information to possibleTypes anyway, so the warnings wouldn't become useful until you'd already done that work.

I'm open to other ideas about how and when to warn about unmatchable fragments, but I don't think my first idea will work.

@batamire
Copy link

batamire commented Apr 8, 2021

I just lost a few hours for the second time until I realized possibleTypes declaration was missing. The first time was a few months ago, an ancient past for my brain...

@mrclay
Copy link

mrclay commented Sep 18, 2022

Users are sending valid queries, and InMemoryCache cannot properly operate without possibleTypes set (hiding server-returned content is a huge bug). Hence it should be made a required config to highlight to users its importance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants