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

Add ui.searchFields option #6165

Merged
merged 8 commits into from
Jul 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}
Comment on lines +430 to +433
Copy link
Member Author

Choose a reason for hiding this comment

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

Note the naming and enum values here align with the mode field that will be in the new filters for strings (and since the new filters align with Prisma, so does this).


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