dillonkearns/elm-graphql/1.2.0

NOTE: the latest version is 5.0.12

Graphql.OptionalArgument

= Present a
| Absent
| Null

This type is used to create values to pass in optional arguments.

  import Api.Enum.Episode as Episode exposing (Episode)
  import Api.Query as Query
  import Graphql.Operation exposing (RootQuery)
  import Graphql.OptionalArgument exposing (OptionalArgument(Null, Present))
  import Graphql.SelectionSet exposing (SelectionSet, with)




  query : SelectionSet Response RootQuery
  query =
      Query.selection Response
          |> with (Query.human { id = "1004" } human)
          |> with (Query.human { id = "1001" } human)
          |> with
              (Query.hero
                  (\optionals ->
                      { optionals
                          | episode = Present Episode.EMPIRE
                      }
                  )
                  hero
              )

An optional argument can be either present, absent, or null, so using a Maybe does not fully capture the GraphQL concept of an optional argument. For example, you could have a mutation that deletes an entry if a null argument is provided, or does nothing if the argument is absent. See The official GraphQL spec section on null for details.

Convert a Maybe to an OptionalArgument.

Transform an OptionalArgument value with a given function.