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

Default values for arguments and input type fields

Open hendrikniemann opened this issue 7 years ago • 0 comments

Currently it is not possible to add default values for field arguments and input fields. Ideally we could introduce a new function (and operator alias) withDefaultValue. If there is no value provided for a variable that has a default value we can use the default value.

withDefaultValue :: forall a n. Symbol n => Tuple (SProxy n) (Argument a) -> a -> Tuple (SProxy n) (Argument a)
withDefaultValue (Tuple name arg) defaultValue = ???

-- Usage
mutationType :: GQL.ObjectType Context Unit
mutationType = GQL.objectType "Mutation"
  :> GQL.field "myMutation" Scalar.boolean
    ?> GQL.arg GQLScalar.id (SProxy :: SProxy "id") `withDefaultValue` "123"

hendrikniemann avatar Nov 18 '18 11:11 hendrikniemann