Expose select Field Options via GraphQL and REST APIs #12420
jjimenez22991
started this conversation in
Feature Requests & Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
It would be highly beneficial if Payload could expose the options configured for select fields through its GraphQL and REST APIs. Is there any way to do this right now?
Use Case
Currently, when using
select
fields with predefined options (as an array of strings or label-value pairs), these options are only accessible within the admin panel or codebase. This presents a challenge in headless implementations where client-side applications (e.g., React, Next.js) need to dynamically render these options (e.g., in dropdowns or filter components) without duplicating the logic.Proposed Solution
Extend the GraphQL and REST APIs to expose the options of
select
fields, potentially in one of the following ways:/api/[collection]/[field]/options
(GET REST) orCollection_fieldName_Options
(GraphQL).Benefits
select
options on the client side.I've a possible implementation in case doesn't exist anything similar and there's no reason to not to implement it. Of course this is a new endpoint from a client perspective if we want to integrate something inside the core could be good to have something inside the graphql property of the collection to be able to expose the fields or not.
Beta Was this translation helpful? Give feedback.
All reactions