elm-graphql icon indicating copy to clipboard operation
elm-graphql copied to clipboard

A GraphQL response does not require the data field

Open ad-si opened this issue 2 years ago • 0 comments

https://github.com/ghivert/elm-graphql/blob/240f23903750c1047a53c77f93f72dc4ccb6e55f/src/GraphQl/Http.elm#L41

This is an incorrect assumption. You can get a valid response with just an errors field.

According to https://spec.graphql.org/draft/#sec-Response-Format GraphQL requests should produce something like this:

type alias GQLError = 
  { message : String
  , path : List String
  , locations : …
  , extensions : …
  }
 
  
type alias GQLResponse = 
  { errors: Maybe (List GQLError)
  , data: Maybe Value
  , extensions: Maybe Value
  }

ad-si avatar Dec 13 '22 11:12 ad-si