Closed
Description
When supplying a default value for a required field, it is not used and instead throws a validation error.
const { graphql, buildSchema } = require('graphql')
const schema = buildSchema(`
type Query {
hello(x: Int! = 42): Int
}
`)
const root = {
hello: (args) => args.x
}
graphql(schema, '{ hello }', root).then(console.log)
Produces:
GraphQLError: Field "hello" argument "x" of type "Int!" is required but not provided.