Skip to content

Commit

Permalink
Add ui.searchFields option (#6165)
Browse files Browse the repository at this point in the history
  • Loading branch information
emmatown authored Jul 25, 2021
1 parent ee8a514 commit e4e6cf9
Show file tree
Hide file tree
Showing 34 changed files with 377 additions and 106 deletions.
7 changes: 7 additions & 0 deletions .changeset/serious-pigs-attack.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@keystone-next/fields': major
'@keystone-next/keystone': major
'@keystone-next/types': major
---

Added `ui.searchFields` option to lists to allow searching by multiple fields in the Admin UI (the only current usage of this is in the select used in relationship fields) and to replace the usage of the `search` GraphQL argument which will be removed soon and should be replaced by using `contains` filters directly.
4 changes: 4 additions & 0 deletions docs/pages/docs/apis/schema.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ Options:

- `labelField`: Selects the field which will be used as the label column in the Admin UI.
By default looks for a field called `'label'`, then falls back to `'name'`, then `'title'`, and finally `'id'`, which is guaranteed to exist.
- `searchFields`: The fields used by the Admin UI when searching this list.
It is always possible to search by an id and `'id'` should not be specified in this option.
By default, the `labelField` is used if it has a string `contains` filter, otherwise none.
- `description` (default: `undefined`): Sets the list description displayed in the Admin UI.
- `isHidden` (default: `false`): Controls whether the list is visible in the navigation elements of the Admin UI.
Can be either a boolean value, or an async function with an argument `{ session }` that returns a boolean value.
Expand Down Expand Up @@ -106,6 +109,7 @@ export default config({
fields: { name: text({ /* ... */ }) },
ui: {
labelField: 'name',
searchFields: ['name', 'alternativeName'],
description: '...',
isHidden: ({ session }) => false,
hideCreate: ({ session }) => false,
Expand Down
6 changes: 6 additions & 0 deletions examples-staging/assets-cloud/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,7 @@ type KeystoneAdminUIFieldMeta {
createView: KeystoneAdminUIFieldMetaCreateView!
listView: KeystoneAdminUIFieldMetaListView!
itemView(id: ID!): KeystoneAdminUIFieldMetaItemView
search: QueryMode
}

type KeystoneAdminUIFieldMetaCreateView {
Expand Down Expand Up @@ -426,6 +427,11 @@ enum KeystoneAdminUIFieldMetaItemViewFieldMode {
hidden
}

enum QueryMode {
default
insensitive
}

type KeystoneAdminUISort {
field: String!
direction: KeystoneAdminUISortDirection!
Expand Down
6 changes: 6 additions & 0 deletions examples-staging/assets-local/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ type KeystoneAdminUIFieldMeta {
createView: KeystoneAdminUIFieldMetaCreateView!
listView: KeystoneAdminUIFieldMetaListView!
itemView(id: ID!): KeystoneAdminUIFieldMetaItemView
search: QueryMode
}

type KeystoneAdminUIFieldMetaCreateView {
Expand Down Expand Up @@ -404,6 +405,11 @@ enum KeystoneAdminUIFieldMetaItemViewFieldMode {
hidden
}

enum QueryMode {
default
insensitive
}

type KeystoneAdminUISort {
field: String!
direction: KeystoneAdminUISortDirection!
Expand Down
6 changes: 6 additions & 0 deletions examples-staging/auth/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ type KeystoneAdminUIFieldMeta {
createView: KeystoneAdminUIFieldMetaCreateView!
listView: KeystoneAdminUIFieldMetaListView!
itemView(id: ID!): KeystoneAdminUIFieldMetaItemView
search: QueryMode
}

type KeystoneAdminUIFieldMetaCreateView {
Expand Down Expand Up @@ -246,6 +247,11 @@ enum KeystoneAdminUIFieldMetaItemViewFieldMode {
hidden
}

enum QueryMode {
default
insensitive
}

type KeystoneAdminUISort {
field: String!
direction: KeystoneAdminUISortDirection!
Expand Down
6 changes: 6 additions & 0 deletions examples-staging/basic/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,7 @@ type KeystoneAdminUIFieldMeta {
createView: KeystoneAdminUIFieldMetaCreateView!
listView: KeystoneAdminUIFieldMetaListView!
itemView(id: ID!): KeystoneAdminUIFieldMetaItemView
search: QueryMode
}

type KeystoneAdminUIFieldMetaCreateView {
Expand Down Expand Up @@ -627,6 +628,11 @@ enum KeystoneAdminUIFieldMetaItemViewFieldMode {
hidden
}

enum QueryMode {
default
insensitive
}

type KeystoneAdminUISort {
field: String!
direction: KeystoneAdminUISortDirection!
Expand Down
6 changes: 6 additions & 0 deletions examples-staging/ecommerce/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -1250,6 +1250,7 @@ type KeystoneAdminUIFieldMeta {
createView: KeystoneAdminUIFieldMetaCreateView!
listView: KeystoneAdminUIFieldMetaListView!
itemView(id: ID!): KeystoneAdminUIFieldMetaItemView
search: QueryMode
}

type KeystoneAdminUIFieldMetaCreateView {
Expand Down Expand Up @@ -1280,6 +1281,11 @@ enum KeystoneAdminUIFieldMetaItemViewFieldMode {
hidden
}

enum QueryMode {
default
insensitive
}

type KeystoneAdminUISort {
field: String!
direction: KeystoneAdminUISortDirection!
Expand Down
6 changes: 6 additions & 0 deletions examples-staging/embedded-nextjs/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ type KeystoneAdminUIFieldMeta {
createView: KeystoneAdminUIFieldMetaCreateView!
listView: KeystoneAdminUIFieldMetaListView!
itemView(id: ID!): KeystoneAdminUIFieldMetaItemView
search: QueryMode
}

type KeystoneAdminUIFieldMetaCreateView {
Expand Down Expand Up @@ -202,6 +203,11 @@ enum KeystoneAdminUIFieldMetaItemViewFieldMode {
hidden
}

enum QueryMode {
default
insensitive
}

type KeystoneAdminUISort {
field: String!
direction: KeystoneAdminUISortDirection!
Expand Down
6 changes: 6 additions & 0 deletions examples-staging/graphql-api-endpoint/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,7 @@ type KeystoneAdminUIFieldMeta {
createView: KeystoneAdminUIFieldMetaCreateView!
listView: KeystoneAdminUIFieldMetaListView!
itemView(id: ID!): KeystoneAdminUIFieldMetaItemView
search: QueryMode
}

type KeystoneAdminUIFieldMetaCreateView {
Expand Down Expand Up @@ -596,6 +597,11 @@ enum KeystoneAdminUIFieldMetaItemViewFieldMode {
hidden
}

enum QueryMode {
default
insensitive
}

type KeystoneAdminUISort {
field: String!
direction: KeystoneAdminUISortDirection!
Expand Down
6 changes: 6 additions & 0 deletions examples-staging/playground/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ type KeystoneAdminUIFieldMeta {
createView: KeystoneAdminUIFieldMetaCreateView!
listView: KeystoneAdminUIFieldMetaListView!
itemView(id: ID!): KeystoneAdminUIFieldMetaItemView
search: QueryMode
}

type KeystoneAdminUIFieldMetaCreateView {
Expand Down Expand Up @@ -178,6 +179,11 @@ enum KeystoneAdminUIFieldMetaItemViewFieldMode {
hidden
}

enum QueryMode {
default
insensitive
}

type KeystoneAdminUISort {
field: String!
direction: KeystoneAdminUISortDirection!
Expand Down
6 changes: 6 additions & 0 deletions examples-staging/roles/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,7 @@ type KeystoneAdminUIFieldMeta {
createView: KeystoneAdminUIFieldMetaCreateView!
listView: KeystoneAdminUIFieldMetaListView!
itemView(id: ID!): KeystoneAdminUIFieldMetaItemView
search: QueryMode
}

type KeystoneAdminUIFieldMetaCreateView {
Expand Down Expand Up @@ -566,6 +567,11 @@ enum KeystoneAdminUIFieldMetaItemViewFieldMode {
hidden
}

enum QueryMode {
default
insensitive
}

type KeystoneAdminUISort {
field: String!
direction: KeystoneAdminUISortDirection!
Expand Down
6 changes: 6 additions & 0 deletions examples-staging/sandbox/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@ type KeystoneAdminUIFieldMeta {
createView: KeystoneAdminUIFieldMetaCreateView!
listView: KeystoneAdminUIFieldMetaListView!
itemView(id: ID!): KeystoneAdminUIFieldMetaItemView
search: QueryMode
}

type KeystoneAdminUIFieldMetaCreateView {
Expand Down Expand Up @@ -400,6 +401,11 @@ enum KeystoneAdminUIFieldMetaItemViewFieldMode {
hidden
}

enum QueryMode {
default
insensitive
}

type KeystoneAdminUISort {
field: String!
direction: KeystoneAdminUISortDirection!
Expand Down
6 changes: 6 additions & 0 deletions examples/blog/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ type KeystoneAdminUIFieldMeta {
createView: KeystoneAdminUIFieldMetaCreateView!
listView: KeystoneAdminUIFieldMetaListView!
itemView(id: ID!): KeystoneAdminUIFieldMetaItemView
search: QueryMode
}

type KeystoneAdminUIFieldMetaCreateView {
Expand Down Expand Up @@ -364,6 +365,11 @@ enum KeystoneAdminUIFieldMetaItemViewFieldMode {
hidden
}

enum QueryMode {
default
insensitive
}

type KeystoneAdminUISort {
field: String!
direction: KeystoneAdminUISortDirection!
Expand Down
6 changes: 6 additions & 0 deletions examples/custom-admin-ui-logo/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ type KeystoneAdminUIFieldMeta {
createView: KeystoneAdminUIFieldMetaCreateView!
listView: KeystoneAdminUIFieldMetaListView!
itemView(id: ID!): KeystoneAdminUIFieldMetaItemView
search: QueryMode
}

type KeystoneAdminUIFieldMetaCreateView {
Expand Down Expand Up @@ -348,6 +349,11 @@ enum KeystoneAdminUIFieldMetaItemViewFieldMode {
hidden
}

enum QueryMode {
default
insensitive
}

type KeystoneAdminUISort {
field: String!
direction: KeystoneAdminUISortDirection!
Expand Down
6 changes: 6 additions & 0 deletions examples/custom-field-view/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ type KeystoneAdminUIFieldMeta {
createView: KeystoneAdminUIFieldMetaCreateView!
listView: KeystoneAdminUIFieldMetaListView!
itemView(id: ID!): KeystoneAdminUIFieldMetaItemView
search: QueryMode
}

type KeystoneAdminUIFieldMetaCreateView {
Expand Down Expand Up @@ -351,6 +352,11 @@ enum KeystoneAdminUIFieldMetaItemViewFieldMode {
hidden
}

enum QueryMode {
default
insensitive
}

type KeystoneAdminUISort {
field: String!
direction: KeystoneAdminUISortDirection!
Expand Down
6 changes: 6 additions & 0 deletions examples/custom-field/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ type KeystoneAdminUIFieldMeta {
createView: KeystoneAdminUIFieldMetaCreateView!
listView: KeystoneAdminUIFieldMetaListView!
itemView(id: ID!): KeystoneAdminUIFieldMetaItemView
search: QueryMode
}

type KeystoneAdminUIFieldMetaCreateView {
Expand Down Expand Up @@ -378,6 +379,11 @@ enum KeystoneAdminUIFieldMetaItemViewFieldMode {
hidden
}

enum QueryMode {
default
insensitive
}

type KeystoneAdminUISort {
field: String!
direction: KeystoneAdminUISortDirection!
Expand Down
6 changes: 6 additions & 0 deletions examples/default-values/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ type KeystoneAdminUIFieldMeta {
createView: KeystoneAdminUIFieldMetaCreateView!
listView: KeystoneAdminUIFieldMetaListView!
itemView(id: ID!): KeystoneAdminUIFieldMetaItemView
search: QueryMode
}

type KeystoneAdminUIFieldMetaCreateView {
Expand Down Expand Up @@ -348,6 +349,11 @@ enum KeystoneAdminUIFieldMetaItemViewFieldMode {
hidden
}

enum QueryMode {
default
insensitive
}

type KeystoneAdminUISort {
field: String!
direction: KeystoneAdminUISortDirection!
Expand Down
6 changes: 6 additions & 0 deletions examples/document-field/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ type KeystoneAdminUIFieldMeta {
createView: KeystoneAdminUIFieldMetaCreateView!
listView: KeystoneAdminUIFieldMetaListView!
itemView(id: ID!): KeystoneAdminUIFieldMetaItemView
search: QueryMode
}

type KeystoneAdminUIFieldMetaCreateView {
Expand Down Expand Up @@ -379,6 +380,11 @@ enum KeystoneAdminUIFieldMetaItemViewFieldMode {
hidden
}

enum QueryMode {
default
insensitive
}

type KeystoneAdminUISort {
field: String!
direction: KeystoneAdminUISortDirection!
Expand Down
6 changes: 6 additions & 0 deletions examples/extend-graphql-schema/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ type KeystoneAdminUIFieldMeta {
createView: KeystoneAdminUIFieldMetaCreateView!
listView: KeystoneAdminUIFieldMetaListView!
itemView(id: ID!): KeystoneAdminUIFieldMetaItemView
search: QueryMode
}

type KeystoneAdminUIFieldMetaCreateView {
Expand Down Expand Up @@ -388,6 +389,11 @@ enum KeystoneAdminUIFieldMetaItemViewFieldMode {
hidden
}

enum QueryMode {
default
insensitive
}

type KeystoneAdminUISort {
field: String!
direction: KeystoneAdminUISortDirection!
Expand Down
6 changes: 6 additions & 0 deletions examples/json/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ type KeystoneAdminUIFieldMeta {
createView: KeystoneAdminUIFieldMetaCreateView!
listView: KeystoneAdminUIFieldMetaListView!
itemView(id: ID!): KeystoneAdminUIFieldMetaItemView
search: QueryMode
}

type KeystoneAdminUIFieldMetaCreateView {
Expand Down Expand Up @@ -321,6 +322,11 @@ enum KeystoneAdminUIFieldMetaItemViewFieldMode {
hidden
}

enum QueryMode {
default
insensitive
}

type KeystoneAdminUISort {
field: String!
direction: KeystoneAdminUISortDirection!
Expand Down
Loading

1 comment on commit e4e6cf9

@vercel
Copy link

@vercel vercel bot commented on e4e6cf9 Jul 25, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.