You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When submitting multiple queries or mutations in the same request, if an error is thrown by one of the queries (validation error etc..) processing will stop and return the errors without returning the queries / mutations already processed.
As execution stops at the first error, it will not process any other query / mutation after the first error.
Expected behavior/Solution
All queries / mutations are processed, and a mix response of data and errors is returned.
From what I have read from other issues, the fact that Lighthouse always returns a 200 is to support this specific use case, when the request partially fails.
Steps to reproduce
Query example:
In this example, the "validQuery" is processed (I can see the SQL queries being made and it goes through the @paginate directive)
Then the invalidQuery triggers an error as it's over the items limit (expected).
The output should have also returned a "data" entry with the results of "validQuery".
Mutation Example:
"invite1" is correctly processed (I can see the SQL queries + job + email invitation sent)
"invite2" has validation error (expected)
"invite3" is NOT processed at all, execution stopped at "invite2" (not expected)
I would have expected all 3 mutations to be processed, with the response containing the data for invite 1 & 3 and the error for invite 2
Lighthouse Version
v6.10.0
php 8.2.5
Laravel 10.13
The text was updated successfully, but these errors were encountered:
Lighthouse works as expected here, I added a test just to be sure: 2ecc00c.
Consider https://spec.graphql.org/draft/#sec-Handling-Field-Errors. GraphQL repsonses will always conform to what is promised in the schema. If a non-nullable field at any level of the query tree has an error, that entire level is invalidated and the error bubbles up to the next level. If you you already on the top level, you will get no data at all.
Hey @spawnia, thanks for the clarification, I wasn't aware of that distinction, pretty new to GraphQL.
Quick question, changing the return types to nullable did indeed work on mutations but not for my queries example, is there a reason for that, other than nullable return types ?
Both of these mutations are decorated with @field (resolver: "path/to/mutation@method")
The updateRow is prone to throw exceptions due to many factors. When it happen, I would like to prevent insertRow to insert new row in database.
Does anybody knows if it's possible to run both of mutations inside a "transaction block" without creating a third mutation just to wrap updateRow and insertRow?
Describe the bug
When submitting multiple queries or mutations in the same request, if an error is thrown by one of the queries (validation error etc..) processing will stop and return the errors without returning the queries / mutations already processed.
As execution stops at the first error, it will not process any other query / mutation after the first error.
Expected behavior/Solution
All queries / mutations are processed, and a mix response of data and errors is returned.
From what I have read from other issues, the fact that Lighthouse always returns a 200 is to support this specific use case, when the request partially fails.
Steps to reproduce
Query example:
![image](https://private-user-images.githubusercontent.com/32894646/249664945-f2bbf47d-84d0-4ae6-ab70-71e079ca275c.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjA0NzUzOTYsIm5iZiI6MTcyMDQ3NTA5NiwicGF0aCI6Ii8zMjg5NDY0Ni8yNDk2NjQ5NDUtZjJiYmY0N2QtODRkMC00YWU2LWFiNzAtNzFlMDc5Y2EyNzVjLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MDglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzA4VDIxNDQ1NlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWFmZDVjMGFkZGUxNTFhY2Y2ZDM2ZmY0OWRhMzgwNTQwMTJlODM3OGYyODQyZWEwOWY5MzhkNmQ0MTY3NTg2YzgmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.s1COGsRprA4v32Cvk3K0H_qpwBq0P1RCIunPGtBGVZE)
In this example, the "validQuery" is processed (I can see the SQL queries being made and it goes through the @paginate directive)
Then the invalidQuery triggers an error as it's over the items limit (expected).
The output should have also returned a "data" entry with the results of "validQuery".
Mutation Example:
![image](https://private-user-images.githubusercontent.com/32894646/249665245-5f9299c6-288b-4146-9d57-ecdad86a3728.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjA0NzUzOTYsIm5iZiI6MTcyMDQ3NTA5NiwicGF0aCI6Ii8zMjg5NDY0Ni8yNDk2NjUyNDUtNWY5Mjk5YzYtMjg4Yi00MTQ2LTlkNTctZWNkYWQ4NmEzNzI4LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MDglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzA4VDIxNDQ1NlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWEzOTNlMGVjNmU2YmZiOThmZjcyNGNmNGQxNGY5Y2ZjODZmMTFjODI5NzM2NTdkOGU5M2ZkZGUyYjMyMzQ0YjEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.7ypSBAvnxe12MjI6mKKHpgPOE65MwfnzXMCGPNqIz44)
"invite1" is correctly processed (I can see the SQL queries + job + email invitation sent)
"invite2" has validation error (expected)
"invite3" is NOT processed at all, execution stopped at "invite2" (not expected)
I would have expected all 3 mutations to be processed, with the response containing the data for invite 1 & 3 and the error for invite 2
Lighthouse Version
v6.10.0
php 8.2.5
Laravel 10.13
The text was updated successfully, but these errors were encountered: