I have GraphQL Schema that accepts a query like this:
query () {
Customers() {
Id
Age
}
}
If the caller requests a non existing field, like "Birthday" in the following example:
query () {
Customers() {
Id
Age
Birthday
}
}
The .NET GraphQL library automatically returns an error to the caller in the response:
{
"errors": [
{
"message": "GraphQL.Validation.Errors.FieldsOnCorrectTypeError: Cannot query field \"Birthday\" on type \"CustomerType\". Did you mean \"Age\" or \"Name\"?",
"locations": [
{
"line": 4,
"column": 13
}
],
"extensions": {
"code": "FIELDS_ON_CORRECT_TYPE",
"codes": [
"FIELDS_ON_CORRECT_TYPE"
],
"number": "5.3.1"
}
}
]
}
How can I get this error (that JSON object) in my backend code? I'd like to log this error or check what field is being searched.