ghivert/elm-graphql/5.0.0

GraphQl.Http

This module provides helpers to directly deal with HTTP with GraphQL.

type alias Options =
{ url : String
, headers : List Header
}

Defines all the options for a GraphQl request.

send : Options -> (Result Error c -> msg) -> Decoder c -> Request a b -> Cmd msg

Send a GraphQL request directly through an HTTP post, directly decoding the data field in the response.

graphQlRequestOptions : GraphQl.Options
graphQlRequestOptions =
  { url = "/example_endpoint"
  , headers = []
  }


sendMyAwesomeRequest : (Result Http.Error a -> msg) -> Decoder a -> Cmd msg
sendMyAwesomeRequest msg decoder =
  GraphQl.query myAwesomeRequest
  |> GraphQl.Http.send graphQlRequestOptions msg decoder