Your GraphQL API might return a validation response like this one:
{
"errors": [
{
"message": "Cannot query field \"nam\" on type \"Droid\".",
"locations": [
{
"line": 4,
"column": 5
}
]
}
]
}
This module defines the GraphQL "error" type, to help parse any validation issues within your Elm application.
{ message : String
, locations : List Location
, path : List PathSegment
, extensions : Dict String Json.Decode.Value
}
A validation error returned by your GraphQL API.
{ line : Basics.Int
, column : Basics.Int
}
Represents a location in your query/mutation
Helps identify which field might be causing problems
It's also possible for your GraphQL response to return partial errors, meaning that
both the data
fields and the errors field could come back in the same response.
If your application would like to access those partial errors, use either of these two functions:
Note: This will make your Msg
result values more complicated:
-- 1️⃣ BEFORE
type Msg
= ApiResponded (Result GraphQL.Http.Error Data)
-- 2️⃣ AFTER
type Msg
= ApiResponded
(Result GraphQL.Http.Error
{ data : Data
, errors : List Error
}
)