WhereInput filter for multiselect field

Open
#9,036 1 comment 1 reaction 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
graphql, typescript

Research direction

Start by tracing how multiselect fields are represented in the generated GraphQL schema and how PageWhereInput is built. Compare the requested some/equals filter with existing field filters; done when a multiselect field exposes the filter and the example query works.

Written by the indexing model from the issue text.

Description

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

Dominant language
TypeScript
Stars
10k
Forks
1.3k
Avg merge
1d 12h
Merged PRs (30d)
38

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from keystonejs/keystone

All issues in keystonejs/keystone

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.