keystone
keystone copied to clipboard
WhereInput filter for multiselect field
First off: Not sure if this is a bug or a feature request
When using a multiselect field, this field cant be used as part of a WHERE filter.
// Example usage
export default list({
// list config
fields: {
stage: multiselect({
label: "Relevant in fase",
db: { map: 'stage' },
type: 'string',
options: stageOptions,
defaultValue: ['orientatie'],
ui: {
itemView: {
fieldPosition: 'sidebar'
},
listView: {
fieldMode: () => 'read',
},
},
hooks: {
validateInput: ({operation, resolvedData, inputData, fieldKey, addValidationError}) => {
if (operation === 'create' && !resolvedData[fieldKey]?.length) addValidationError('Een item moet ten minste één relevante fase hebben')
else if (operation === 'update' && inputData[fieldKey] && !inputData[fieldKey].length) addValidationError('Een item moet ten minste één relevante fase hebben')
}
}
})
}
})
I expected to be able to write queries with filters for this field. Such as
query {
pages(where: { stage: { some: { equals: "orientatie" }}}) {
id
}
}
But this gives an error Field "stage" is not defined by type "PageWhereInput".
I case this is not a bug: is such a feature going to be implemented any time soon? Because otherwise I'll need to look for another solution...
you can implement your own multi select field without using JSON, that way it is text field for storage and select field for display