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

Choice Fields Should return key and value, not just value #105

Open
jasonbahl opened this issue Oct 30, 2023 · 1 comment
Open

Choice Fields Should return key and value, not just value #105

jasonbahl opened this issue Oct 30, 2023 · 1 comment
Labels
needs: discussion Requires a discussion to proceed type: enhancement Improvements to existing functionality

Comments

@jasonbahl
Copy link
Contributor

What problem does this address?

Currently when querying a choice field, such as checkbox, select, or radio, only the value is returned.

i.e.

CleanShot 2023-10-30 at 13 04 55

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).

CleanShot 2023-10-30 at 13 09 46

What is your proposed solution?

I have 2 ideas:

  1. Change choice fields to always return a GraphQL Object Type, something like an AcfChoice type that has a label and value field. (this would be a breaking change)
  2. 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: wp-graphql/wp-graphql-acf#44

@danimalweb
Copy link

What's the status of this? I would love to see it working. We just ran into this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs: discussion Requires a discussion to proceed type: enhancement Improvements to existing functionality
Projects
None yet
Development

No branches or pull requests

2 participants