Hey guys. I’m trying to use :telemetry
to log any ‘validation errors’ that on my GraphQL API, as an early warning system for mistakes when change the schema.
I’ve successfully added to the validation of incoming requests with:
def log([:absinthe, :execute, :operation, :stop], _measurements, metadata, _config) do
for %Absinthe.Phase.Error{message: message} <- metadata.blueprint.execution.validation_errors do
Logger.warning("Validation error: #{message}")
end
end
I had an expectation that this would also log errors on the resolution of fields, when for example I set e field as ‘non_null’ when actually it could be resolved as null , however that hasn’t worked.
I then tried to check the errors for on the resolution of each individual field with:
def log([:absinthe, :resolve, :field, :stop], _measurements, %{resolution: %{errors: errors}}, _) do
dbg(errors)
end
But when executing a query that returns an error, like this:
{
// ...
"errors": [
{
"message": "Cannot return null for non-nullable field",
"path": ["brand","customFields",0,"isSuggestable"],
"locations": [{"line": 111,"column": 3}]
}
]
}
The resolution of all these fields have an empty list as error field.
Is there a way to check these errors?