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

[BUG] Input type default value not set #350

Closed
yaquawa opened this issue Sep 9, 2018 · 7 comments
Closed

[BUG] Input type default value not set #350

yaquawa opened this issue Sep 9, 2018 · 7 comments

Comments

@yaquawa
Copy link

yaquawa commented Sep 9, 2018

Hi
Thanks for the great work!!

I'm using version : ^0.12 of graphql-php

and I found that seems like the default value of input type won't work.

For example:

input Condition {
    key: String!
    value: String!

    # This field won't be given as a argument if omit it in the query.
    operator: Operator = "eq" 
}

Hope this can be fixed.👍🏼

@vladar
Copy link
Member

vladar commented Oct 4, 2018

Default values for input type fields are not supported in the reference implementation yet. They must implement it first.

At the moment you have to define defaultValue at the field level of your parent object type. And it provides some ambiguity which has to be described in the spec first.

@yaquawa
Copy link
Author

yaquawa commented Oct 5, 2018

@vladar Thank you for checking this! Got it!

@yaquawa
Copy link
Author

yaquawa commented Oct 11, 2018

@vladar
I think the spec already said the input object field can have a default value!
https://facebook.github.io/graphql/June2018/#InputFieldsDefinition

@vladar
Copy link
Member

vladar commented Oct 11, 2018

input Input1 {
  a: String = "a"
  b: String = "b"
}

input Input2 {
  a: Input1 = { a: "b" }
}

In the example above - what value will be in a.b of Input2? Will it be null or "b". There are many possible edge cases with nested objects with default values. I am talking about this kind of ambiguity. It must be clarified in the spec.

@yaquawa
Copy link
Author

yaquawa commented Oct 11, 2018

@vladar You're right…! will this be clarified in the spec in the future?

@vladar
Copy link
Member

vladar commented Nov 21, 2018

I've posted a link in my first reply where you can track this. I suggest re-opening it after related spec updates are published.

@vladar vladar closed this as completed Nov 21, 2018
@spawnia
Copy link
Collaborator

spawnia commented Mar 28, 2019

@yaquawa i think i stumbled upon the issue you were having, from the looks of it while working on the same thing 😉

What i found is that the EnumType expects the default value to be set to the internal value. Since we construct the args straight from the schema definition, we have to lookup the internal value - i am about to fix that in Lighthouse.

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

No branches or pull requests

3 participants