graphql-client
graphql-client copied to clipboard
Casting Error in GraphQL C# Library
We are facing a piquant situation using GraphQLClient's SendQueryAsync method to call Monday.com API. The line goes like this
var response = await graphQLClient.SendQueryAsync(request)
If the server returns a proper JSON it is all fine. However if the server returns a message like Complexity budget exhausted, query cost 30001 budget remaining 29984 out of 1000000 reset in 8 seconds, it throws a message like
Error converting value Complexity budget exhausted, query cost 30001 budget remaining 29984 out of 1000000 reset in 8 seconds to type GraphQL.GraphQLError. Path errors[0] line 1 position 305
How do we configure this graphqlclient to cast the string into GraphQL Error or are we missing something else?
Hi, could you post the complete HTTP response you get when this issue occurs?
GraphQLResponse<dynamic> response is NULL. However captured using Fiddler as below
149
{"error_code":"ComplexityException","status_code":429,"error_message":"Complexity budget exhausted, query cost 30001 budget remaining 19986 out of 1000000 reset in 3 seconds","error_data":{},"errors":["Complexity budget exhausted, query cost 30001 budget remaining 19986 out of 1000000 reset in 3 seconds"],"account_id":2213213}
0
Formatted JSON Output (for readability)
{
"error_code": "ComplexityException",
"status_code": 429,
"error_message": "Complexity budget exhausted, query cost 30001 budget remaining 19986 out of 1000000 reset in 3 seconds",
"error_data": {},
"errors": [
"Complexity budget exhausted, query cost 30001 budget remaining 19986 out of 1000000 reset in 3 seconds"
],
"account_id": 2213213
}
The response does not adhere to the GraphQL Spec.
The errors entry is expected to contain a list of maps, which must have at least the property message containing a description string. Thats why the deserialization fails.
It is currently not possible to use a custom GraphQLResponse type, the only way would be to clone the code and build yourself a custom version of this library.
The response does not adhere to the GraphQL Spec.
I called this out to the OP in the monday.com community as well. monday.com refuses to acknowledge they do not follow the spec for errors as well.