-
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
SSR crashes with "invariant violation" when InMemoryCache uses "possibleTypes" and "error-policy" is set to "all" #6915
Comments
@ZauberNerd Since the See the Errors section of the GraphQL spec, or this explanation of In other words, the following change seems to be the "right" way to fix the problem: diff --git a/src/server.ts b/src/server.ts
index f2f67d2..54379ae 100644
--- a/src/server.ts
+++ b/src/server.ts
@@ -14,7 +14,7 @@ app.get('/', async (_, res) => {
app.post('/graphql', (_, res) => {
res.json({
- data: { foo: 'bar' },
+ data: { foo: 'bar', bar: null },
errors: [
{
message: 'Could not resolve fields', As it happens, this particular exception used to be a warning (in AC2, before #6055). I might be open to switching back to a warning, but I think the content of the warning indicates something useful even in this case (an invalid GraphQL response). |
@ZauberNerd Have you found a way to mitigate this error? Did you refactor all of your resolvers? Or have you decided to not migrate yet? |
Hi @RadoslavGenov @benjamn yes, thank you for the great explanation. I have followed it and updated my GraphQL mock server, so this ticket can be closed. |
Fixes #8331 and #6915, and should help with the underlying cause of #7436 (comment)
Fixes #8331 and #6915, and should help with the underlying cause of #7436 (comment)
Intended outcome:
When a GraphQL resolver fails to resolve a field,
@apollo/client
should render as much data as possible (witherrorPolicy: all
) and should populate theerror
field ofuseQuery
.Actual outcome:
The server process crashes with an "Invariant violation" error:
How to reproduce the issue:
errorPolicy
toall
on your querypossibleTypes
for theInMemoryCache
Here is a reproduction: https://github.com/ZauberNerd/apollo-client-ssr-reproducer
Versions
The text was updated successfully, but these errors were encountered: