I have set up a select
field in KeystoneJS as per the docs:
const { Select } = require('@keystonejs/fields');
keystone.createList('Order', {
fields: {
status: { type: Select, options: 'pending, processed' },
},
});
How can I use introspection to get a list of valid options for this field?
Types in KeystoneJS seem to be named with the following format:
<list name><field name>Type
Additionally, if the first letter of <list name>
or <field name>
are lowercase, these are changed to uppercase. So for the example given in the question, the type name for the field status
would be:
OrderStatusType
The available options can then be queried with the following:
query {
__type (name: "OrderStatusType") {
enumValues {
name
}
}
}
Tested on a standard KeystoneJS install with a Postgres database.