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

WhereInput filter for multiselect field #9036

Open
remihuigen opened this issue Feb 22, 2024 · 1 comment
Open

WhereInput filter for multiselect field #9036

remihuigen opened this issue Feb 22, 2024 · 1 comment

Comments

@remihuigen
Copy link

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

@gautamsi
Copy link
Member

you can implement your own multi select field without using JSON, that way it is text field for storage and select field for display

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants