Casting Error in GraphQL C# Library (with Monday API Budget Complexity Message)

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?

This is something I’ve complained about in general, the monday.com graphql api does not handle all errors per the GraphQL spec. See Error codes

The problem is they do not return all errors in the errors key of the GraphQL response. They added their own structure around some of the errors. Unfortunately, because they developed the API around their own node.js/javascript client they did not consider compatibility with standards compliant clients.

You pretty much have to abandon standards compliant graphql clients and roll your own minimal one around basic http requests.