How to add default values to input arguments in graphql

It looks like the grammar allows default values on input object types, so you can declare

input ExampleInput {
  value: Int = 0
  another: String
  isAvailable: Boolean = false
}

The spec is clear that default values exist and explains how they get used (first bullet under “Input Coercion”).

(Whether any specific tooling supports this is probably variable: graphql.org had an informal version of the IDL for quite a while before it was actually in the spec, and I have the impression some libraries haven’t caught up to the released spec yet.)

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)