wpgraphql-acf
wpgraphql-acf copied to clipboard
Choice Fields Should return key and value, not just value
What problem does this address?
Currently when querying a choice field, such as checkbox, select, or radio, only the value is returned.
i.e.
Some users would like to be able to query these fields and have both the label and value of the choice returned.
i.e (mocked example).
What is your proposed solution?
I have 2 ideas:
- Change choice fields to always return a GraphQL Object Type, something like an AcfChoice type that has a
labelandvaluefield. (this would be a breaking change) - Leave it as is, but introduce a new GraphQL Return Type (graphql_return_type) setting that allows the return type to be changed. Fields like choice fields could be changed to return a different Type, letting users opt-in at their leisure to a different return type (if it's a breaking change, it would be opt-in). . .This could be a global setting for all fields of xx type, or could be a setting that's determined on a field-by-field basis (or a combination of each)
What alternatives have you considered?
We could document how folks can do this via hooks/filters and leave default behavior as-is 🤷🏻
Additional Context
related: https://github.com/wp-graphql/wp-graphql-acf/issues/44
What's the status of this? I would love to see it working. We just ran into this issue.