-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Dropdown Fields Returning Error #40
Comments
Hrm, looks like I need to do some protection on the dropdown values. GraphQL has much more strict rules than Craft does, which is causing this. |
Okay, |
@markhuot Looks like it's returning values now, but the values returned don't match the value from the field. example:
|
Not sure why |
I'm not sure what to do about the hyphen issue, though. GraphQL won't allow hyphens in enum values. I could just have it return a string, but then I wouldn't be able to validate it on mutation/input. E.g., {
upsertPost(
title: "foo"
dropdownField: "literally, anything, could be here"
) {
id
}
} With enums we have some protection, {
upsertPost(
title: "foo"
dropdownField: someValidGraphQLEnum #anything else would fail before data even gets to Craft
) {
id
}
} I'll need to think on this a bit… I'm open to any ideas you may have. |
@markhuot Thanks for the quick fix. I appreciate the ability to validate the return type and then handle the variable in code appropriately. This might be an edge case that I was using the dropdown field to insert the value into the |
Thanks @edolyne. I'm going to close this ticket because we've fixed the incorrect casing on valid values. One note on the invalid values: you can get the label of the input, if that helps like this, {
entries(id:2){
...on Stories{
id
title
socialLinks #enum field, returns listOf enum values
}
}
__type(name:"SocialLinksEnum"){ #the enum field I'm curious about
enumValues{
name # the value of the enum, maybe `myFieldValue`
description # the label of the enum, maybe `My Field Value`
}
}
} I wish there was some way that I could return the raw value inside |
At some point in the future I may consider subclassing the Enum type, allowing us to return the raw value. I've noted this in the roadmap. |
When querying a dropdown field, the following error is returned:
"message": "Expected a value of type \"BackgroundColorEnum\" but received: \"background--primary\"",
"message": "Expected a value of type \"ReduceRemoveSpacingEnum\" but received: \"reduceSpacingTopBottom\"",
Craft & CraftQL versions:
Craft -
RC3
CraftQL -
dev-master
The text was updated successfully, but these errors were encountered: