Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default values for Non Null types #1405

Closed
benwaffle opened this issue Jun 25, 2018 · 2 comments
Closed

Default values for Non Null types #1405

benwaffle opened this issue Jun 25, 2018 · 2 comments
Labels

Comments

@benwaffle
Copy link

benwaffle commented Jun 25, 2018

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.

@IvanGoncharov
Copy link
Member

@benwaffle Should be fixed in #1274
Can you please try it on 14.0.0-rc.2?

@benwaffle
Copy link
Author

benwaffle commented Jun 25, 2018

it works on 14.0.0-rc.2, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants