owanturist/elm-graphql/1.0.1

NOTE: this package is not compatible with Elm 0.19.1

GraphQL.Argument

Define GraphQL inputs in Elm

Primitives

type alias Argument =
Argument

Represents a GraphQL input values.

string : String -> Argument

Pass string argument into a graph.

GraphQL.Selector.succeed Constructor
    |> GraphQL.Selector.field "fieldName"
        [ ( "asString", string "foo" )
        ]
        GraphQL.Selector.int

Equals to:

"""
fieldName(asString: "foo")
"""
int : Int -> Argument

Pass int argument into a graph.

GraphQL.Selector.succeed Constructor
    |> GraphQL.Selector.field "fieldName"
        [ ( "asInt", int 1 )
        ]
        GraphQL.Selector.int

Equals to:

"""
fieldName(asInt: 1)
"""
float : Float -> Argument

Pass float argument into a graph.

GraphQL.Selector.succeed Constructor
    |> GraphQL.Selector.field "fieldName"
        [ ( "asFloat", float 3.14 )
        ]
        GraphQL.Selector.int

Equals to:

"""
fieldName(asFloat: 3.14)
"""
bool : Bool -> Argument

Pass bool argument into a graph.

GraphQL.Selector.succeed Constructor
    |> GraphQL.Selector.field "fieldName"
        [ ( "asBool", bool True )
        ]
        GraphQL.Selector.int

Equals to:

"""
fieldName(asBool: true)
"""
null : Argument

Pass null argument into a graph.

GraphQL.Selector.succeed Constructor
    |> GraphQL.Selector.field "fieldName"
        [ ( "asNull", null )
        ]
        GraphQL.Selector.int

Equals to:

"""
fieldName(asNull: null)
"""

Arrays

list : List Argument -> Argument

Pass list of arguments into a graph.

GraphQL.Selector.succeed Constructor
    |> GraphQL.Selector.field "fieldName"
        [ ( "asInConsistentList"
          , list
                [ string "foo"
                , int 0
                , list [ bool False ]
                ]
          )
        , ( "asConsistentList"
          , list
                [ int 0
                , int 1
                , int 2
                ]
          )
        ]
        GraphQL.Selector.int

Equals to:

"""
fieldName(
    asInConsistentList: ["foo", 0, false],
    asConsistentList: [0, 1, 2]
)
"""
array : Array Argument -> Argument

Pass array of arguments into a graph.

GraphQL.Selector.succeed Constructor
    |> GraphQL.Selector.field "fieldName"
        [ ( "asInConsistentArray"
          , array
                (Array.fromList
                    [ string "foo"
                    , int 0
                    , array [ bool False ]
                    ]
                )
          )
        , ( "asConsistentArray"
          , array
                (Array.fromList
                    [ int 0
                    , int 1
                    , int 2
                    ]
                )
          )
        ]
        GraphQL.Selector.int

Equals to:

"""
fieldName(
    asInConsistentList: ["foo", 0, false],
    asConsistentList: [0, 1, 2]
)
"""

Objects

object : List ( String, Argument ) -> Argument

Pass object of arguments into a graph.

GraphQL.Selector.succeed Constructor
    |> GraphQL.Selector.field "fieldName"
        [ ( "asObject"
          , object
                [ ( "asString", string "foo" )
                , ( "asInt", int 1 )
                , ( "asFloat", float 3.14 )
                , ( "asBool", bool True )
                , ( "asNull", null )
                ]
          )
        ]
        GraphQL.Selector.int

Equals to:

"""
fieldName(asObject: {
    asString: "foo",
    asInt: 1,
    asFloat: 3.14,
    asBool: true,
    asNull: null
})
"""