From 5cd8ffd6cb822dbee8555b47846a5019c4d2b1c3 Mon Sep 17 00:00:00 2001 From: Mitchell Hamilton Date: Tue, 27 Jul 2021 15:25:09 +1000 Subject: [PATCH] Remove legacy GraphQL API features (#6196) --- .changeset/brown-glasses-complain.md | 7 + .changeset/cold-cycles-cry.md | 6 + .changeset/early-experts-allow.md | 7 + .changeset/lovely-pears-sort.md | 7 + examples-staging/assets-cloud/schema.graphql | 71 ----- examples-staging/assets-local/schema.graphql | 71 ----- examples-staging/auth/schema.graphql | 30 -- examples-staging/basic/schema.graphql | 112 -------- examples-staging/ecommerce/schema.graphql | 265 ------------------ .../embedded-nextjs/schema.graphql | 30 -- .../graphql-api-endpoint/schema.graphql | 121 -------- examples-staging/playground/schema.graphql | 26 -- examples-staging/roles/schema.graphql | 118 -------- examples-staging/sandbox/schema.graphql | 77 ----- examples/blog/schema.graphql | 71 ----- examples/custom-admin-ui-logo/schema.graphql | 69 ----- examples/custom-field-view/schema.graphql | 69 ----- examples/custom-field/schema.graphql | 73 ----- examples/default-values/schema.graphql | 69 ----- examples/document-field/schema.graphql | 71 ----- examples/extend-graphql-schema/schema.graphql | 71 ----- examples/json/schema.graphql | 65 ----- examples/task-manager/schema.graphql | 69 ----- examples/testing/schema.graphql | 71 ----- examples/virtual-field/schema.graphql | 71 ----- examples/with-auth/schema.graphql | 71 ----- package.json | 4 +- .../fields/src/types/relationship/index.ts | 14 - .../relationship/tests/implementation.test.ts | 5 +- packages/keystone/src/lib/context/itemAPI.ts | 14 +- .../keystone/src/lib/core/graphql-schema.ts | 1 - .../keystone/src/lib/core/queries/index.ts | 42 +-- .../src/lib/core/queries/output-field.ts | 28 +- .../src/lib/core/queries/resolvers.ts | 98 ++++--- .../keystone/src/lib/core/types-for-lists.ts | 57 +--- packages/keystone/src/lib/core/utils.ts | 19 -- .../__snapshots__/artifacts.test.ts.snap | 3 - .../fixtures/basic-project/schema.graphql | 26 -- packages/types/src/config/lists.ts | 5 - packages/types/src/context.ts | 8 +- packages/types/src/core.ts | 2 - packages/types/src/next-fields.ts | 18 +- packages/types/src/utils.ts | 6 +- tests/api-tests/queries/cache-hints.test.ts | 4 +- tests/api-tests/queries/search.test.ts | 246 ---------------- tests/api-tests/queries/sortBy.test.ts | 242 ---------------- .../relationships/filtering/nested.test.ts | 51 +--- tests/test-projects/basic/schema.graphql | 163 +---------- 48 files changed, 118 insertions(+), 2726 deletions(-) create mode 100644 .changeset/brown-glasses-complain.md create mode 100644 .changeset/cold-cycles-cry.md create mode 100644 .changeset/early-experts-allow.md create mode 100644 .changeset/lovely-pears-sort.md delete mode 100644 tests/api-tests/queries/search.test.ts delete mode 100644 tests/api-tests/queries/sortBy.test.ts diff --git a/.changeset/brown-glasses-complain.md b/.changeset/brown-glasses-complain.md new file mode 100644 index 00000000000..1dd24fb1cbd --- /dev/null +++ b/.changeset/brown-glasses-complain.md @@ -0,0 +1,7 @@ +--- +'@keystone-next/fields': major +'@keystone-next/keystone': major +'@keystone-next/types': major +--- + +Removed `_ListKeyMeta` and `_toManyRelationshipFieldMeta` fields. You should use `listKeyCount` and `toManyRelationshipFieldCount` instead diff --git a/.changeset/cold-cycles-cry.md b/.changeset/cold-cycles-cry.md new file mode 100644 index 00000000000..01d444759a0 --- /dev/null +++ b/.changeset/cold-cycles-cry.md @@ -0,0 +1,6 @@ +--- +'@keystone-next/keystone': major +'@keystone-next/types': major +--- + +Removed all arguments from `context.lists.List.count` and `context.db.lists.List.count` except for `where`. diff --git a/.changeset/early-experts-allow.md b/.changeset/early-experts-allow.md new file mode 100644 index 00000000000..0ba0c99a6e4 --- /dev/null +++ b/.changeset/early-experts-allow.md @@ -0,0 +1,7 @@ +--- +'@keystone-next/fields': major +'@keystone-next/keystone': major +'@keystone-next/types': major +--- + +Removed `search` argument from the GraphQL API for finding many items, Lists/DB API and to-many relationship fields. You should use `contains` filters instead. diff --git a/.changeset/lovely-pears-sort.md b/.changeset/lovely-pears-sort.md new file mode 100644 index 00000000000..4522dc1b66e --- /dev/null +++ b/.changeset/lovely-pears-sort.md @@ -0,0 +1,7 @@ +--- +'@keystone-next/fields': major +'@keystone-next/keystone': major +'@keystone-next/types': major +--- + +Removed `sortBy` argument from the GraphQL API for finding many items, Lists/DB API and to-many relationship fields. You should use `orderBy` instead. diff --git a/examples-staging/assets-cloud/schema.graphql b/examples-staging/assets-cloud/schema.graphql index bb17d25c696..8bbf3de800d 100644 --- a/examples-staging/assets-cloud/schema.graphql +++ b/examples-staging/assets-cloud/schema.graphql @@ -98,19 +98,6 @@ input PostWhereUniqueInput { id: ID } -enum SortPostsBy { - id_ASC - id_DESC - title_ASC - title_DESC - status_ASC - status_DESC - content_ASC - content_DESC - publishDate_ASC - publishDate_DESC -} - input PostOrderByInput { id: OrderDirection title: OrderDirection @@ -181,32 +168,13 @@ type Author { email: String posts( where: PostWhereInput! = {} - search: String - sortBy: [SortPostsBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") orderBy: [PostOrderByInput!]! = [] first: Int skip: Int! = 0 ): [Post!] - _postsMeta( - where: PostWhereInput! = {} - search: String - sortBy: [SortPostsBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") - orderBy: [PostOrderByInput!]! = [] - first: Int - skip: Int! = 0 - ): _QueryMeta - @deprecated( - reason: "This query will be removed in a future version. Please use postsCount instead." - ) postsCount(where: PostWhereInput! = {}): Int } -type _QueryMeta { - count: Int -} - input AuthorWhereInput { AND: [AuthorWhereInput!] OR: [AuthorWhereInput!] @@ -240,15 +208,6 @@ input AuthorWhereUniqueInput { email: String } -enum SortAuthorsBy { - id_ASC - id_DESC - name_ASC - name_DESC - email_ASC - email_DESC -} - input AuthorOrderByInput { id: OrderDirection name: OrderDirection @@ -309,49 +268,19 @@ type Mutation { type Query { allPosts( where: PostWhereInput! = {} - search: String - sortBy: [SortPostsBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") orderBy: [PostOrderByInput!]! = [] first: Int skip: Int! = 0 ): [Post!] Post(where: PostWhereUniqueInput!): Post - _allPostsMeta( - where: PostWhereInput! = {} - search: String - sortBy: [SortPostsBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") - orderBy: [PostOrderByInput!]! = [] - first: Int - skip: Int! = 0 - ): _QueryMeta - @deprecated( - reason: "This query will be removed in a future version. Please use postsCount instead." - ) postsCount(where: PostWhereInput! = {}): Int allAuthors( where: AuthorWhereInput! = {} - search: String - sortBy: [SortAuthorsBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") orderBy: [AuthorOrderByInput!]! = [] first: Int skip: Int! = 0 ): [Author!] Author(where: AuthorWhereUniqueInput!): Author - _allAuthorsMeta( - where: AuthorWhereInput! = {} - search: String - sortBy: [SortAuthorsBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") - orderBy: [AuthorOrderByInput!]! = [] - first: Int - skip: Int! = 0 - ): _QueryMeta - @deprecated( - reason: "This query will be removed in a future version. Please use authorsCount instead." - ) authorsCount(where: AuthorWhereInput! = {}): Int keystone: KeystoneMeta! } diff --git a/examples-staging/assets-local/schema.graphql b/examples-staging/assets-local/schema.graphql index 12e3539da25..f8ba3bbce0b 100644 --- a/examples-staging/assets-local/schema.graphql +++ b/examples-staging/assets-local/schema.graphql @@ -83,19 +83,6 @@ input PostWhereUniqueInput { id: ID } -enum SortPostsBy { - id_ASC - id_DESC - title_ASC - title_DESC - status_ASC - status_DESC - content_ASC - content_DESC - publishDate_ASC - publishDate_DESC -} - input PostOrderByInput { id: OrderDirection title: OrderDirection @@ -159,32 +146,13 @@ type Author { email: String posts( where: PostWhereInput! = {} - search: String - sortBy: [SortPostsBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") orderBy: [PostOrderByInput!]! = [] first: Int skip: Int! = 0 ): [Post!] - _postsMeta( - where: PostWhereInput! = {} - search: String - sortBy: [SortPostsBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") - orderBy: [PostOrderByInput!]! = [] - first: Int - skip: Int! = 0 - ): _QueryMeta - @deprecated( - reason: "This query will be removed in a future version. Please use postsCount instead." - ) postsCount(where: PostWhereInput! = {}): Int } -type _QueryMeta { - count: Int -} - input AuthorWhereInput { AND: [AuthorWhereInput!] OR: [AuthorWhereInput!] @@ -218,15 +186,6 @@ input AuthorWhereUniqueInput { email: String } -enum SortAuthorsBy { - id_ASC - id_DESC - name_ASC - name_DESC - email_ASC - email_DESC -} - input AuthorOrderByInput { id: OrderDirection name: OrderDirection @@ -287,49 +246,19 @@ type Mutation { type Query { allPosts( where: PostWhereInput! = {} - search: String - sortBy: [SortPostsBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") orderBy: [PostOrderByInput!]! = [] first: Int skip: Int! = 0 ): [Post!] Post(where: PostWhereUniqueInput!): Post - _allPostsMeta( - where: PostWhereInput! = {} - search: String - sortBy: [SortPostsBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") - orderBy: [PostOrderByInput!]! = [] - first: Int - skip: Int! = 0 - ): _QueryMeta - @deprecated( - reason: "This query will be removed in a future version. Please use postsCount instead." - ) postsCount(where: PostWhereInput! = {}): Int allAuthors( where: AuthorWhereInput! = {} - search: String - sortBy: [SortAuthorsBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") orderBy: [AuthorOrderByInput!]! = [] first: Int skip: Int! = 0 ): [Author!] Author(where: AuthorWhereUniqueInput!): Author - _allAuthorsMeta( - where: AuthorWhereInput! = {} - search: String - sortBy: [SortAuthorsBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") - orderBy: [AuthorOrderByInput!]! = [] - first: Int - skip: Int! = 0 - ): _QueryMeta - @deprecated( - reason: "This query will be removed in a future version. Please use authorsCount instead." - ) authorsCount(where: AuthorWhereInput! = {}): Int keystone: KeystoneMeta! } diff --git a/examples-staging/auth/schema.graphql b/examples-staging/auth/schema.graphql index eb12169b29d..6b1f98996cb 100644 --- a/examples-staging/auth/schema.graphql +++ b/examples-staging/auth/schema.graphql @@ -43,17 +43,6 @@ input UserWhereUniqueInput { email: String } -enum SortUsersBy { - id_ASC - id_DESC - name_ASC - name_DESC - email_ASC - email_DESC - isAdmin_ASC - isAdmin_DESC -} - input UserOrderByInput { id: OrderDirection name: OrderDirection @@ -97,10 +86,6 @@ scalar JSON url: "http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf" ) -type _QueryMeta { - count: Int -} - type Mutation { createUser(data: UserCreateInput): User createUsers(data: [UsersCreateInput]): [User] @@ -151,26 +136,11 @@ input CreateInitialUserInput { type Query { allUsers( where: UserWhereInput! = {} - search: String - sortBy: [SortUsersBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") orderBy: [UserOrderByInput!]! = [] first: Int skip: Int! = 0 ): [User!] User(where: UserWhereUniqueInput!): User - _allUsersMeta( - where: UserWhereInput! = {} - search: String - sortBy: [SortUsersBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") - orderBy: [UserOrderByInput!]! = [] - first: Int - skip: Int! = 0 - ): _QueryMeta - @deprecated( - reason: "This query will be removed in a future version. Please use usersCount instead." - ) usersCount(where: UserWhereInput! = {}): Int authenticatedItem: AuthenticatedItem keystone: KeystoneMeta! diff --git a/examples-staging/basic/schema.graphql b/examples-staging/basic/schema.graphql index fec0d2c6abe..bb052c8e40d 100644 --- a/examples-staging/basic/schema.graphql +++ b/examples-staging/basic/schema.graphql @@ -9,47 +9,17 @@ type User { roles: String phoneNumbers( where: PhoneNumberWhereInput! = {} - search: String - sortBy: [SortPhoneNumbersBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") orderBy: [PhoneNumberOrderByInput!]! = [] first: Int skip: Int! = 0 ): [PhoneNumber!] - _phoneNumbersMeta( - where: PhoneNumberWhereInput! = {} - search: String - sortBy: [SortPhoneNumbersBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") - orderBy: [PhoneNumberOrderByInput!]! = [] - first: Int - skip: Int! = 0 - ): _QueryMeta - @deprecated( - reason: "This query will be removed in a future version. Please use phoneNumbersCount instead." - ) phoneNumbersCount(where: PhoneNumberWhereInput! = {}): Int posts( where: PostWhereInput! = {} - search: String - sortBy: [SortPostsBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") orderBy: [PostOrderByInput!]! = [] first: Int skip: Int! = 0 ): [Post!] - _postsMeta( - where: PostWhereInput! = {} - search: String - sortBy: [SortPostsBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") - orderBy: [PostOrderByInput!]! = [] - first: Int - skip: Int! = 0 - ): _QueryMeta - @deprecated( - reason: "This query will be removed in a future version. Please use postsCount instead." - ) postsCount(where: PostWhereInput! = {}): Int randomNumber: Float } @@ -82,10 +52,6 @@ type PasswordState { isSet: Boolean! } -type _QueryMeta { - count: Int -} - type LocalImageFieldOutput implements ImageFieldOutput { id: ID! filesize: Int! @@ -148,19 +114,6 @@ input UserWhereUniqueInput { email: String } -enum SortUsersBy { - id_ASC - id_DESC - name_ASC - name_DESC - email_ASC - email_DESC - isAdmin_ASC - isAdmin_DESC - roles_ASC - roles_DESC -} - input UserOrderByInput { id: OrderDirection name: OrderDirection @@ -273,15 +226,6 @@ input PhoneNumberWhereUniqueInput { id: ID } -enum SortPhoneNumbersBy { - id_ASC - id_DESC - type_ASC - type_DESC - value_ASC - value_DESC -} - input PhoneNumberOrderByInput { id: OrderDirection type: OrderDirection @@ -366,17 +310,6 @@ input PostWhereUniqueInput { id: ID } -enum SortPostsBy { - id_ASC - id_DESC - title_ASC - title_DESC - status_ASC - status_DESC - publishDate_ASC - publishDate_DESC -} - input PostOrderByInput { id: OrderDirection title: OrderDirection @@ -485,72 +418,27 @@ type RandomNumber { type Query { allUsers( where: UserWhereInput! = {} - search: String - sortBy: [SortUsersBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") orderBy: [UserOrderByInput!]! = [] first: Int skip: Int! = 0 ): [User!] User(where: UserWhereUniqueInput!): User - _allUsersMeta( - where: UserWhereInput! = {} - search: String - sortBy: [SortUsersBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") - orderBy: [UserOrderByInput!]! = [] - first: Int - skip: Int! = 0 - ): _QueryMeta - @deprecated( - reason: "This query will be removed in a future version. Please use usersCount instead." - ) usersCount(where: UserWhereInput! = {}): Int allPhoneNumbers( where: PhoneNumberWhereInput! = {} - search: String - sortBy: [SortPhoneNumbersBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") orderBy: [PhoneNumberOrderByInput!]! = [] first: Int skip: Int! = 0 ): [PhoneNumber!] PhoneNumber(where: PhoneNumberWhereUniqueInput!): PhoneNumber - _allPhoneNumbersMeta( - where: PhoneNumberWhereInput! = {} - search: String - sortBy: [SortPhoneNumbersBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") - orderBy: [PhoneNumberOrderByInput!]! = [] - first: Int - skip: Int! = 0 - ): _QueryMeta - @deprecated( - reason: "This query will be removed in a future version. Please use phoneNumbersCount instead." - ) phoneNumbersCount(where: PhoneNumberWhereInput! = {}): Int allPosts( where: PostWhereInput! = {} - search: String - sortBy: [SortPostsBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") orderBy: [PostOrderByInput!]! = [] first: Int skip: Int! = 0 ): [Post!] Post(where: PostWhereUniqueInput!): Post - _allPostsMeta( - where: PostWhereInput! = {} - search: String - sortBy: [SortPostsBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") - orderBy: [PostOrderByInput!]! = [] - first: Int - skip: Int! = 0 - ): _QueryMeta - @deprecated( - reason: "This query will be removed in a future version. Please use postsCount instead." - ) postsCount(where: PostWhereInput! = {}): Int authenticatedItem: AuthenticatedItem randomNumber: RandomNumber diff --git a/examples-staging/ecommerce/schema.graphql b/examples-staging/ecommerce/schema.graphql index 81a06185654..0ce434bc698 100644 --- a/examples-staging/ecommerce/schema.graphql +++ b/examples-staging/ecommerce/schema.graphql @@ -5,70 +5,25 @@ type User { password: PasswordState cart( where: CartItemWhereInput! = {} - search: String - sortBy: [SortCartItemsBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") orderBy: [CartItemOrderByInput!]! = [] first: Int skip: Int! = 0 ): [CartItem!] - _cartMeta( - where: CartItemWhereInput! = {} - search: String - sortBy: [SortCartItemsBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") - orderBy: [CartItemOrderByInput!]! = [] - first: Int - skip: Int! = 0 - ): _QueryMeta - @deprecated( - reason: "This query will be removed in a future version. Please use cartCount instead." - ) cartCount(where: CartItemWhereInput! = {}): Int orders( where: OrderWhereInput! = {} - search: String - sortBy: [SortOrdersBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") orderBy: [OrderOrderByInput!]! = [] first: Int skip: Int! = 0 ): [Order!] - _ordersMeta( - where: OrderWhereInput! = {} - search: String - sortBy: [SortOrdersBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") - orderBy: [OrderOrderByInput!]! = [] - first: Int - skip: Int! = 0 - ): _QueryMeta - @deprecated( - reason: "This query will be removed in a future version. Please use ordersCount instead." - ) ordersCount(where: OrderWhereInput! = {}): Int role: Role products( where: ProductWhereInput! = {} - search: String - sortBy: [SortProductsBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") orderBy: [ProductOrderByInput!]! = [] first: Int skip: Int! = 0 ): [Product!] - _productsMeta( - where: ProductWhereInput! = {} - search: String - sortBy: [SortProductsBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") - orderBy: [ProductOrderByInput!]! = [] - first: Int - skip: Int! = 0 - ): _QueryMeta - @deprecated( - reason: "This query will be removed in a future version. Please use productsCount instead." - ) productsCount(where: ProductWhereInput! = {}): Int passwordResetToken: PasswordState passwordResetIssuedAt: String @@ -79,10 +34,6 @@ type PasswordState { isSet: Boolean! } -type _QueryMeta { - count: Int -} - input UserWhereInput { AND: [UserWhereInput!] OR: [UserWhereInput!] @@ -142,19 +93,6 @@ input UserWhereUniqueInput { email: String } -enum SortUsersBy { - id_ASC - id_DESC - name_ASC - name_DESC - email_ASC - email_DESC - passwordResetIssuedAt_ASC - passwordResetIssuedAt_DESC - passwordResetRedeemedAt_ASC - passwordResetRedeemedAt_DESC -} - input UserOrderByInput { id: OrderDirection name: OrderDirection @@ -286,19 +224,6 @@ input ProductWhereUniqueInput { id: ID } -enum SortProductsBy { - id_ASC - id_DESC - name_ASC - name_DESC - description_ASC - description_DESC - status_ASC - status_DESC - price_ASC - price_DESC -} - input ProductOrderByInput { id: OrderDirection name: OrderDirection @@ -433,13 +358,6 @@ input ProductImageWhereUniqueInput { id: ID } -enum SortProductImagesBy { - id_ASC - id_DESC - altText_ASC - altText_DESC -} - input ProductImageOrderByInput { id: OrderDirection altText: OrderDirection @@ -514,13 +432,6 @@ input CartItemWhereUniqueInput { id: ID } -enum SortCartItemsBy { - id_ASC - id_DESC - quantity_ASC - quantity_DESC -} - input CartItemOrderByInput { id: OrderDirection quantity: OrderDirection @@ -606,19 +517,6 @@ input OrderItemWhereUniqueInput { id: ID } -enum SortOrderItemsBy { - id_ASC - id_DESC - name_ASC - name_DESC - description_ASC - description_DESC - price_ASC - price_DESC - quantity_ASC - quantity_DESC -} - input OrderItemOrderByInput { id: OrderDirection name: OrderDirection @@ -667,25 +565,10 @@ type Order { total: Int items( where: OrderItemWhereInput! = {} - search: String - sortBy: [SortOrderItemsBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") orderBy: [OrderItemOrderByInput!]! = [] first: Int skip: Int! = 0 ): [OrderItem!] - _itemsMeta( - where: OrderItemWhereInput! = {} - search: String - sortBy: [SortOrderItemsBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") - orderBy: [OrderItemOrderByInput!]! = [] - first: Int - skip: Int! = 0 - ): _QueryMeta - @deprecated( - reason: "This query will be removed in a future version. Please use itemsCount instead." - ) itemsCount(where: OrderItemWhereInput! = {}): Int user: User charge: String @@ -727,15 +610,6 @@ input OrderWhereUniqueInput { id: ID } -enum SortOrdersBy { - id_ASC - id_DESC - total_ASC - total_DESC - charge_ASC - charge_DESC -} - input OrderOrderByInput { id: OrderDirection total: OrderDirection @@ -783,25 +657,10 @@ type Role { canManageOrders: Boolean assignedTo( where: UserWhereInput! = {} - search: String - sortBy: [SortUsersBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") orderBy: [UserOrderByInput!]! = [] first: Int skip: Int! = 0 ): [User!] - _assignedToMeta( - where: UserWhereInput! = {} - search: String - sortBy: [SortUsersBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") - orderBy: [UserOrderByInput!]! = [] - first: Int - skip: Int! = 0 - ): _QueryMeta - @deprecated( - reason: "This query will be removed in a future version. Please use assignedToCount instead." - ) assignedToCount(where: UserWhereInput! = {}): Int } @@ -843,25 +702,6 @@ input RoleWhereUniqueInput { id: ID } -enum SortRolesBy { - id_ASC - id_DESC - name_ASC - name_DESC - canManageProducts_ASC - canManageProducts_DESC - canSeeOtherUsers_ASC - canSeeOtherUsers_DESC - canManageUsers_ASC - canManageUsers_DESC - canManageRoles_ASC - canManageRoles_DESC - canManageCart_ASC - canManageCart_DESC - canManageOrders_ASC - canManageOrders_DESC -} - input RoleOrderByInput { id: OrderDirection name: OrderDirection @@ -1043,164 +883,59 @@ enum PasswordResetRedemptionErrorCode { type Query { allUsers( where: UserWhereInput! = {} - search: String - sortBy: [SortUsersBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") orderBy: [UserOrderByInput!]! = [] first: Int skip: Int! = 0 ): [User!] User(where: UserWhereUniqueInput!): User - _allUsersMeta( - where: UserWhereInput! = {} - search: String - sortBy: [SortUsersBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") - orderBy: [UserOrderByInput!]! = [] - first: Int - skip: Int! = 0 - ): _QueryMeta - @deprecated( - reason: "This query will be removed in a future version. Please use usersCount instead." - ) usersCount(where: UserWhereInput! = {}): Int allProducts( where: ProductWhereInput! = {} - search: String - sortBy: [SortProductsBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") orderBy: [ProductOrderByInput!]! = [] first: Int skip: Int! = 0 ): [Product!] Product(where: ProductWhereUniqueInput!): Product - _allProductsMeta( - where: ProductWhereInput! = {} - search: String - sortBy: [SortProductsBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") - orderBy: [ProductOrderByInput!]! = [] - first: Int - skip: Int! = 0 - ): _QueryMeta - @deprecated( - reason: "This query will be removed in a future version. Please use productsCount instead." - ) productsCount(where: ProductWhereInput! = {}): Int allProductImages( where: ProductImageWhereInput! = {} - search: String - sortBy: [SortProductImagesBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") orderBy: [ProductImageOrderByInput!]! = [] first: Int skip: Int! = 0 ): [ProductImage!] ProductImage(where: ProductImageWhereUniqueInput!): ProductImage - _allProductImagesMeta( - where: ProductImageWhereInput! = {} - search: String - sortBy: [SortProductImagesBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") - orderBy: [ProductImageOrderByInput!]! = [] - first: Int - skip: Int! = 0 - ): _QueryMeta - @deprecated( - reason: "This query will be removed in a future version. Please use productImagesCount instead." - ) productImagesCount(where: ProductImageWhereInput! = {}): Int allCartItems( where: CartItemWhereInput! = {} - search: String - sortBy: [SortCartItemsBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") orderBy: [CartItemOrderByInput!]! = [] first: Int skip: Int! = 0 ): [CartItem!] CartItem(where: CartItemWhereUniqueInput!): CartItem - _allCartItemsMeta( - where: CartItemWhereInput! = {} - search: String - sortBy: [SortCartItemsBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") - orderBy: [CartItemOrderByInput!]! = [] - first: Int - skip: Int! = 0 - ): _QueryMeta - @deprecated( - reason: "This query will be removed in a future version. Please use cartItemsCount instead." - ) cartItemsCount(where: CartItemWhereInput! = {}): Int allOrderItems( where: OrderItemWhereInput! = {} - search: String - sortBy: [SortOrderItemsBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") orderBy: [OrderItemOrderByInput!]! = [] first: Int skip: Int! = 0 ): [OrderItem!] OrderItem(where: OrderItemWhereUniqueInput!): OrderItem - _allOrderItemsMeta( - where: OrderItemWhereInput! = {} - search: String - sortBy: [SortOrderItemsBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") - orderBy: [OrderItemOrderByInput!]! = [] - first: Int - skip: Int! = 0 - ): _QueryMeta - @deprecated( - reason: "This query will be removed in a future version. Please use orderItemsCount instead." - ) orderItemsCount(where: OrderItemWhereInput! = {}): Int allOrders( where: OrderWhereInput! = {} - search: String - sortBy: [SortOrdersBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") orderBy: [OrderOrderByInput!]! = [] first: Int skip: Int! = 0 ): [Order!] Order(where: OrderWhereUniqueInput!): Order - _allOrdersMeta( - where: OrderWhereInput! = {} - search: String - sortBy: [SortOrdersBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") - orderBy: [OrderOrderByInput!]! = [] - first: Int - skip: Int! = 0 - ): _QueryMeta - @deprecated( - reason: "This query will be removed in a future version. Please use ordersCount instead." - ) ordersCount(where: OrderWhereInput! = {}): Int allRoles( where: RoleWhereInput! = {} - search: String - sortBy: [SortRolesBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") orderBy: [RoleOrderByInput!]! = [] first: Int skip: Int! = 0 ): [Role!] Role(where: RoleWhereUniqueInput!): Role - _allRolesMeta( - where: RoleWhereInput! = {} - search: String - sortBy: [SortRolesBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") - orderBy: [RoleOrderByInput!]! = [] - first: Int - skip: Int! = 0 - ): _QueryMeta - @deprecated( - reason: "This query will be removed in a future version. Please use rolesCount instead." - ) rolesCount(where: RoleWhereInput! = {}): Int authenticatedItem: AuthenticatedItem validateUserPasswordResetToken( diff --git a/examples-staging/embedded-nextjs/schema.graphql b/examples-staging/embedded-nextjs/schema.graphql index de26c2004c7..5b4862bf14c 100644 --- a/examples-staging/embedded-nextjs/schema.graphql +++ b/examples-staging/embedded-nextjs/schema.graphql @@ -40,17 +40,6 @@ input PostWhereUniqueInput { id: ID } -enum SortPostsBy { - id_ASC - id_DESC - title_ASC - title_DESC - slug_ASC - slug_DESC - content_ASC - content_DESC -} - input PostOrderByInput { id: OrderDirection title: OrderDirection @@ -92,10 +81,6 @@ scalar JSON url: "http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf" ) -type _QueryMeta { - count: Int -} - type Mutation { createPost(data: PostCreateInput): Post createPosts(data: [PostsCreateInput]): [Post] @@ -108,26 +93,11 @@ type Mutation { type Query { allPosts( where: PostWhereInput! = {} - search: String - sortBy: [SortPostsBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") orderBy: [PostOrderByInput!]! = [] first: Int skip: Int! = 0 ): [Post!] Post(where: PostWhereUniqueInput!): Post - _allPostsMeta( - where: PostWhereInput! = {} - search: String - sortBy: [SortPostsBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") - orderBy: [PostOrderByInput!]! = [] - first: Int - skip: Int! = 0 - ): _QueryMeta - @deprecated( - reason: "This query will be removed in a future version. Please use postsCount instead." - ) postsCount(where: PostWhereInput! = {}): Int keystone: KeystoneMeta! } diff --git a/examples-staging/graphql-api-endpoint/schema.graphql b/examples-staging/graphql-api-endpoint/schema.graphql index 1d2317e7b47..8e50d81745b 100644 --- a/examples-staging/graphql-api-endpoint/schema.graphql +++ b/examples-staging/graphql-api-endpoint/schema.graphql @@ -5,25 +5,10 @@ type User { password: PasswordState posts( where: PostWhereInput! = {} - search: String - sortBy: [SortPostsBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") orderBy: [PostOrderByInput!]! = [] first: Int skip: Int! = 0 ): [Post!] - _postsMeta( - where: PostWhereInput! = {} - search: String - sortBy: [SortPostsBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") - orderBy: [PostOrderByInput!]! = [] - first: Int - skip: Int! = 0 - ): _QueryMeta - @deprecated( - reason: "This query will be removed in a future version. Please use postsCount instead." - ) postsCount(where: PostWhereInput! = {}): Int } @@ -31,10 +16,6 @@ type PasswordState { isSet: Boolean! } -type _QueryMeta { - count: Int -} - input UserWhereInput { AND: [UserWhereInput!] OR: [UserWhereInput!] @@ -93,15 +74,6 @@ input UserWhereUniqueInput { email: String } -enum SortUsersBy { - id_ASC - id_DESC - name_ASC - name_DESC - email_ASC - email_DESC -} - input UserOrderByInput { id: OrderDirection name: OrderDirection @@ -152,25 +124,10 @@ type Post { author: User tags( where: TagWhereInput! = {} - search: String - sortBy: [SortTagsBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") orderBy: [TagOrderByInput!]! = [] first: Int skip: Int! = 0 ): [Tag!] - _tagsMeta( - where: TagWhereInput! = {} - search: String - sortBy: [SortTagsBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") - orderBy: [TagOrderByInput!]! = [] - first: Int - skip: Int! = 0 - ): _QueryMeta - @deprecated( - reason: "This query will be removed in a future version. Please use tagsCount instead." - ) tagsCount(where: TagWhereInput! = {}): Int } @@ -230,17 +187,6 @@ input PostWhereUniqueInput { id: ID } -enum SortPostsBy { - id_ASC - id_DESC - title_ASC - title_DESC - status_ASC - status_DESC - publishDate_ASC - publishDate_DESC -} - input PostOrderByInput { id: OrderDirection title: OrderDirection @@ -294,25 +240,10 @@ type Tag { name: String posts( where: PostWhereInput! = {} - search: String - sortBy: [SortPostsBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") orderBy: [PostOrderByInput!]! = [] first: Int skip: Int! = 0 ): [Post!] - _postsMeta( - where: PostWhereInput! = {} - search: String - sortBy: [SortPostsBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") - orderBy: [PostOrderByInput!]! = [] - first: Int - skip: Int! = 0 - ): _QueryMeta - @deprecated( - reason: "This query will be removed in a future version. Please use postsCount instead." - ) postsCount(where: PostWhereInput! = {}): Int } @@ -354,13 +285,6 @@ input TagWhereUniqueInput { id: ID } -enum SortTagsBy { - id_ASC - id_DESC - name_ASC - name_DESC -} - input TagOrderByInput { id: OrderDirection name: OrderDirection @@ -455,72 +379,27 @@ input CreateInitialUserInput { type Query { allUsers( where: UserWhereInput! = {} - search: String - sortBy: [SortUsersBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") orderBy: [UserOrderByInput!]! = [] first: Int skip: Int! = 0 ): [User!] User(where: UserWhereUniqueInput!): User - _allUsersMeta( - where: UserWhereInput! = {} - search: String - sortBy: [SortUsersBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") - orderBy: [UserOrderByInput!]! = [] - first: Int - skip: Int! = 0 - ): _QueryMeta - @deprecated( - reason: "This query will be removed in a future version. Please use usersCount instead." - ) usersCount(where: UserWhereInput! = {}): Int allPosts( where: PostWhereInput! = {} - search: String - sortBy: [SortPostsBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") orderBy: [PostOrderByInput!]! = [] first: Int skip: Int! = 0 ): [Post!] Post(where: PostWhereUniqueInput!): Post - _allPostsMeta( - where: PostWhereInput! = {} - search: String - sortBy: [SortPostsBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") - orderBy: [PostOrderByInput!]! = [] - first: Int - skip: Int! = 0 - ): _QueryMeta - @deprecated( - reason: "This query will be removed in a future version. Please use postsCount instead." - ) postsCount(where: PostWhereInput! = {}): Int allTags( where: TagWhereInput! = {} - search: String - sortBy: [SortTagsBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") orderBy: [TagOrderByInput!]! = [] first: Int skip: Int! = 0 ): [Tag!] Tag(where: TagWhereUniqueInput!): Tag - _allTagsMeta( - where: TagWhereInput! = {} - search: String - sortBy: [SortTagsBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") - orderBy: [TagOrderByInput!]! = [] - first: Int - skip: Int! = 0 - ): _QueryMeta - @deprecated( - reason: "This query will be removed in a future version. Please use tagsCount instead." - ) tagsCount(where: TagWhereInput! = {}): Int authenticatedItem: AuthenticatedItem keystone: KeystoneMeta! diff --git a/examples-staging/playground/schema.graphql b/examples-staging/playground/schema.graphql index 8221afe9a35..0f4658a9ebe 100644 --- a/examples-staging/playground/schema.graphql +++ b/examples-staging/playground/schema.graphql @@ -26,13 +26,6 @@ input NoteWhereUniqueInput { id: ID } -enum SortNotesBy { - id_ASC - id_DESC - label_ASC - label_DESC -} - input NoteOrderByInput { id: OrderDirection label: OrderDirection @@ -68,10 +61,6 @@ scalar JSON url: "http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf" ) -type _QueryMeta { - count: Int -} - type Mutation { createNote(data: NoteCreateInput): Note createNotes(data: [NotesCreateInput]): [Note] @@ -84,26 +73,11 @@ type Mutation { type Query { allNotes( where: NoteWhereInput! = {} - search: String - sortBy: [SortNotesBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") orderBy: [NoteOrderByInput!]! = [] first: Int skip: Int! = 0 ): [Note!] Note(where: NoteWhereUniqueInput!): Note - _allNotesMeta( - where: NoteWhereInput! = {} - search: String - sortBy: [SortNotesBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") - orderBy: [NoteOrderByInput!]! = [] - first: Int - skip: Int! = 0 - ): _QueryMeta - @deprecated( - reason: "This query will be removed in a future version. Please use notesCount instead." - ) notesCount(where: NoteWhereInput! = {}): Int keystone: KeystoneMeta! } diff --git a/examples-staging/roles/schema.graphql b/examples-staging/roles/schema.graphql index 3e08096c460..c28c00324ef 100644 --- a/examples-staging/roles/schema.graphql +++ b/examples-staging/roles/schema.graphql @@ -35,17 +35,6 @@ input TodoWhereUniqueInput { id: ID } -enum SortTodosBy { - id_ASC - id_DESC - label_ASC - label_DESC - isComplete_ASC - isComplete_DESC - isPrivate_ASC - isPrivate_DESC -} - input TodoOrderByInput { id: OrderDirection label: OrderDirection @@ -96,25 +85,10 @@ type Person { role: Role tasks( where: TodoWhereInput! = {} - search: String - sortBy: [SortTodosBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") orderBy: [TodoOrderByInput!]! = [] first: Int skip: Int! = 0 ): [Todo!] - _tasksMeta( - where: TodoWhereInput! = {} - search: String - sortBy: [SortTodosBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") - orderBy: [TodoOrderByInput!]! = [] - first: Int - skip: Int! = 0 - ): _QueryMeta - @deprecated( - reason: "This query will be removed in a future version. Please use tasksCount instead." - ) tasksCount(where: TodoWhereInput! = {}): Int } @@ -122,10 +96,6 @@ type PasswordState { isSet: Boolean! } -type _QueryMeta { - count: Int -} - input PersonWhereInput { AND: [PersonWhereInput!] OR: [PersonWhereInput!] @@ -162,15 +132,6 @@ input PersonWhereUniqueInput { email: String } -enum SortPeopleBy { - id_ASC - id_DESC - name_ASC - name_DESC - email_ASC - email_DESC -} - input PersonOrderByInput { id: OrderDirection name: OrderDirection @@ -227,25 +188,10 @@ type Role { canManageRoles: Boolean assignedTo( where: PersonWhereInput! = {} - search: String - sortBy: [SortPeopleBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") orderBy: [PersonOrderByInput!]! = [] first: Int skip: Int! = 0 ): [Person!] - _assignedToMeta( - where: PersonWhereInput! = {} - search: String - sortBy: [SortPeopleBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") - orderBy: [PersonOrderByInput!]! = [] - first: Int - skip: Int! = 0 - ): _QueryMeta - @deprecated( - reason: "This query will be removed in a future version. Please use assignedToCount instead." - ) assignedToCount(where: PersonWhereInput! = {}): Int } @@ -287,25 +233,6 @@ input RoleWhereUniqueInput { id: ID } -enum SortRolesBy { - id_ASC - id_DESC - name_ASC - name_DESC - canCreateTodos_ASC - canCreateTodos_DESC - canManageAllTodos_ASC - canManageAllTodos_DESC - canSeeOtherPeople_ASC - canSeeOtherPeople_DESC - canEditOtherPeople_ASC - canEditOtherPeople_DESC - canManagePeople_ASC - canManagePeople_DESC - canManageRoles_ASC - canManageRoles_DESC -} - input RoleOrderByInput { id: OrderDirection name: OrderDirection @@ -425,72 +352,27 @@ input CreateInitialPersonInput { type Query { allTodos( where: TodoWhereInput! = {} - search: String - sortBy: [SortTodosBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") orderBy: [TodoOrderByInput!]! = [] first: Int skip: Int! = 0 ): [Todo!] Todo(where: TodoWhereUniqueInput!): Todo - _allTodosMeta( - where: TodoWhereInput! = {} - search: String - sortBy: [SortTodosBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") - orderBy: [TodoOrderByInput!]! = [] - first: Int - skip: Int! = 0 - ): _QueryMeta - @deprecated( - reason: "This query will be removed in a future version. Please use todosCount instead." - ) todosCount(where: TodoWhereInput! = {}): Int allPeople( where: PersonWhereInput! = {} - search: String - sortBy: [SortPeopleBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") orderBy: [PersonOrderByInput!]! = [] first: Int skip: Int! = 0 ): [Person!] Person(where: PersonWhereUniqueInput!): Person - _allPeopleMeta( - where: PersonWhereInput! = {} - search: String - sortBy: [SortPeopleBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") - orderBy: [PersonOrderByInput!]! = [] - first: Int - skip: Int! = 0 - ): _QueryMeta - @deprecated( - reason: "This query will be removed in a future version. Please use peopleCount instead." - ) peopleCount(where: PersonWhereInput! = {}): Int allRoles( where: RoleWhereInput! = {} - search: String - sortBy: [SortRolesBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") orderBy: [RoleOrderByInput!]! = [] first: Int skip: Int! = 0 ): [Role!] Role(where: RoleWhereUniqueInput!): Role - _allRolesMeta( - where: RoleWhereInput! = {} - search: String - sortBy: [SortRolesBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") - orderBy: [RoleOrderByInput!]! = [] - first: Int - skip: Int! = 0 - ): _QueryMeta - @deprecated( - reason: "This query will be removed in a future version. Please use rolesCount instead." - ) rolesCount(where: RoleWhereInput! = {}): Int authenticatedItem: AuthenticatedItem keystone: KeystoneMeta! diff --git a/examples-staging/sandbox/schema.graphql b/examples-staging/sandbox/schema.graphql index 165bef05567..bafe8169a57 100644 --- a/examples-staging/sandbox/schema.graphql +++ b/examples-staging/sandbox/schema.graphql @@ -59,21 +59,6 @@ input TodoWhereUniqueInput { id: ID } -enum SortTodosBy { - id_ASC - id_DESC - label_ASC - label_DESC - isComplete_ASC - isComplete_DESC - finishBy_ASC - finishBy_DESC - createdAt_ASC - createdAt_DESC - updatedAt_ASC - updatedAt_DESC -} - input TodoOrderByInput { id: OrderDirection label: OrderDirection @@ -125,25 +110,10 @@ type User { password: PasswordState tasks( where: TodoWhereInput! = {} - search: String - sortBy: [SortTodosBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") orderBy: [TodoOrderByInput!]! = [] first: Int skip: Int! = 0 ): [Todo!] - _tasksMeta( - where: TodoWhereInput! = {} - search: String - sortBy: [SortTodosBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") - orderBy: [TodoOrderByInput!]! = [] - first: Int - skip: Int! = 0 - ): _QueryMeta - @deprecated( - reason: "This query will be removed in a future version. Please use tasksCount instead." - ) tasksCount(where: TodoWhereInput! = {}): Int createdAt: String updatedAt: String @@ -153,10 +123,6 @@ type PasswordState { isSet: Boolean! } -type _QueryMeta { - count: Int -} - input UserWhereInput { AND: [UserWhereInput!] OR: [UserWhereInput!] @@ -206,19 +172,6 @@ input UserWhereUniqueInput { id: ID } -enum SortUsersBy { - id_ASC - id_DESC - name_ASC - name_DESC - email_ASC - email_DESC - createdAt_ASC - createdAt_DESC - updatedAt_ASC - updatedAt_DESC -} - input UserOrderByInput { id: OrderDirection name: OrderDirection @@ -283,49 +236,19 @@ type Mutation { type Query { allTodos( where: TodoWhereInput! = {} - search: String - sortBy: [SortTodosBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") orderBy: [TodoOrderByInput!]! = [] first: Int skip: Int! = 0 ): [Todo!] Todo(where: TodoWhereUniqueInput!): Todo - _allTodosMeta( - where: TodoWhereInput! = {} - search: String - sortBy: [SortTodosBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") - orderBy: [TodoOrderByInput!]! = [] - first: Int - skip: Int! = 0 - ): _QueryMeta - @deprecated( - reason: "This query will be removed in a future version. Please use todosCount instead." - ) todosCount(where: TodoWhereInput! = {}): Int allUsers( where: UserWhereInput! = {} - search: String - sortBy: [SortUsersBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") orderBy: [UserOrderByInput!]! = [] first: Int skip: Int! = 0 ): [User!] User(where: UserWhereUniqueInput!): User - _allUsersMeta( - where: UserWhereInput! = {} - search: String - sortBy: [SortUsersBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") - orderBy: [UserOrderByInput!]! = [] - first: Int - skip: Int! = 0 - ): _QueryMeta - @deprecated( - reason: "This query will be removed in a future version. Please use usersCount instead." - ) usersCount(where: UserWhereInput! = {}): Int keystone: KeystoneMeta! } diff --git a/examples/blog/schema.graphql b/examples/blog/schema.graphql index 3561da90882..ab8ddb02ab4 100644 --- a/examples/blog/schema.graphql +++ b/examples/blog/schema.graphql @@ -55,19 +55,6 @@ input PostWhereUniqueInput { id: ID } -enum SortPostsBy { - id_ASC - id_DESC - title_ASC - title_DESC - status_ASC - status_DESC - content_ASC - content_DESC - publishDate_ASC - publishDate_DESC -} - input PostOrderByInput { id: OrderDirection title: OrderDirection @@ -119,32 +106,13 @@ type Author { email: String posts( where: PostWhereInput! = {} - search: String - sortBy: [SortPostsBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") orderBy: [PostOrderByInput!]! = [] first: Int skip: Int! = 0 ): [Post!] - _postsMeta( - where: PostWhereInput! = {} - search: String - sortBy: [SortPostsBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") - orderBy: [PostOrderByInput!]! = [] - first: Int - skip: Int! = 0 - ): _QueryMeta - @deprecated( - reason: "This query will be removed in a future version. Please use postsCount instead." - ) postsCount(where: PostWhereInput! = {}): Int } -type _QueryMeta { - count: Int -} - input AuthorWhereInput { AND: [AuthorWhereInput!] OR: [AuthorWhereInput!] @@ -178,15 +146,6 @@ input AuthorWhereUniqueInput { email: String } -enum SortAuthorsBy { - id_ASC - id_DESC - name_ASC - name_DESC - email_ASC - email_DESC -} - input AuthorOrderByInput { id: OrderDirection name: OrderDirection @@ -247,49 +206,19 @@ type Mutation { type Query { allPosts( where: PostWhereInput! = {} - search: String - sortBy: [SortPostsBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") orderBy: [PostOrderByInput!]! = [] first: Int skip: Int! = 0 ): [Post!] Post(where: PostWhereUniqueInput!): Post - _allPostsMeta( - where: PostWhereInput! = {} - search: String - sortBy: [SortPostsBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") - orderBy: [PostOrderByInput!]! = [] - first: Int - skip: Int! = 0 - ): _QueryMeta - @deprecated( - reason: "This query will be removed in a future version. Please use postsCount instead." - ) postsCount(where: PostWhereInput! = {}): Int allAuthors( where: AuthorWhereInput! = {} - search: String - sortBy: [SortAuthorsBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") orderBy: [AuthorOrderByInput!]! = [] first: Int skip: Int! = 0 ): [Author!] Author(where: AuthorWhereUniqueInput!): Author - _allAuthorsMeta( - where: AuthorWhereInput! = {} - search: String - sortBy: [SortAuthorsBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") - orderBy: [AuthorOrderByInput!]! = [] - first: Int - skip: Int! = 0 - ): _QueryMeta - @deprecated( - reason: "This query will be removed in a future version. Please use authorsCount instead." - ) authorsCount(where: AuthorWhereInput! = {}): Int keystone: KeystoneMeta! } diff --git a/examples/custom-admin-ui-logo/schema.graphql b/examples/custom-admin-ui-logo/schema.graphql index 7a9006d84c0..73415451e79 100644 --- a/examples/custom-admin-ui-logo/schema.graphql +++ b/examples/custom-admin-ui-logo/schema.graphql @@ -52,19 +52,6 @@ input TaskWhereUniqueInput { id: ID } -enum SortTasksBy { - id_ASC - id_DESC - label_ASC - label_DESC - priority_ASC - priority_DESC - isComplete_ASC - isComplete_DESC - finishBy_ASC - finishBy_DESC -} - input TaskOrderByInput { id: OrderDirection label: OrderDirection @@ -115,32 +102,13 @@ type Person { name: String tasks( where: TaskWhereInput! = {} - search: String - sortBy: [SortTasksBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") orderBy: [TaskOrderByInput!]! = [] first: Int skip: Int! = 0 ): [Task!] - _tasksMeta( - where: TaskWhereInput! = {} - search: String - sortBy: [SortTasksBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") - orderBy: [TaskOrderByInput!]! = [] - first: Int - skip: Int! = 0 - ): _QueryMeta - @deprecated( - reason: "This query will be removed in a future version. Please use tasksCount instead." - ) tasksCount(where: TaskWhereInput! = {}): Int } -type _QueryMeta { - count: Int -} - input PersonWhereInput { AND: [PersonWhereInput!] OR: [PersonWhereInput!] @@ -167,13 +135,6 @@ input PersonWhereUniqueInput { id: ID } -enum SortPeopleBy { - id_ASC - id_DESC - name_ASC - name_DESC -} - input PersonOrderByInput { id: OrderDirection name: OrderDirection @@ -231,49 +192,19 @@ type Mutation { type Query { allTasks( where: TaskWhereInput! = {} - search: String - sortBy: [SortTasksBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") orderBy: [TaskOrderByInput!]! = [] first: Int skip: Int! = 0 ): [Task!] Task(where: TaskWhereUniqueInput!): Task - _allTasksMeta( - where: TaskWhereInput! = {} - search: String - sortBy: [SortTasksBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") - orderBy: [TaskOrderByInput!]! = [] - first: Int - skip: Int! = 0 - ): _QueryMeta - @deprecated( - reason: "This query will be removed in a future version. Please use tasksCount instead." - ) tasksCount(where: TaskWhereInput! = {}): Int allPeople( where: PersonWhereInput! = {} - search: String - sortBy: [SortPeopleBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") orderBy: [PersonOrderByInput!]! = [] first: Int skip: Int! = 0 ): [Person!] Person(where: PersonWhereUniqueInput!): Person - _allPeopleMeta( - where: PersonWhereInput! = {} - search: String - sortBy: [SortPeopleBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") - orderBy: [PersonOrderByInput!]! = [] - first: Int - skip: Int! = 0 - ): _QueryMeta - @deprecated( - reason: "This query will be removed in a future version. Please use peopleCount instead." - ) peopleCount(where: PersonWhereInput! = {}): Int keystone: KeystoneMeta! } diff --git a/examples/custom-field-view/schema.graphql b/examples/custom-field-view/schema.graphql index 3e04f67be8c..5cd2ccb5b11 100644 --- a/examples/custom-field-view/schema.graphql +++ b/examples/custom-field-view/schema.graphql @@ -53,19 +53,6 @@ input TaskWhereUniqueInput { id: ID } -enum SortTasksBy { - id_ASC - id_DESC - label_ASC - label_DESC - priority_ASC - priority_DESC - isComplete_ASC - isComplete_DESC - finishBy_ASC - finishBy_DESC -} - input TaskOrderByInput { id: OrderDirection label: OrderDirection @@ -118,32 +105,13 @@ type Person { name: String tasks( where: TaskWhereInput! = {} - search: String - sortBy: [SortTasksBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") orderBy: [TaskOrderByInput!]! = [] first: Int skip: Int! = 0 ): [Task!] - _tasksMeta( - where: TaskWhereInput! = {} - search: String - sortBy: [SortTasksBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") - orderBy: [TaskOrderByInput!]! = [] - first: Int - skip: Int! = 0 - ): _QueryMeta - @deprecated( - reason: "This query will be removed in a future version. Please use tasksCount instead." - ) tasksCount(where: TaskWhereInput! = {}): Int } -type _QueryMeta { - count: Int -} - input PersonWhereInput { AND: [PersonWhereInput!] OR: [PersonWhereInput!] @@ -170,13 +138,6 @@ input PersonWhereUniqueInput { id: ID } -enum SortPeopleBy { - id_ASC - id_DESC - name_ASC - name_DESC -} - input PersonOrderByInput { id: OrderDirection name: OrderDirection @@ -234,49 +195,19 @@ type Mutation { type Query { allTasks( where: TaskWhereInput! = {} - search: String - sortBy: [SortTasksBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") orderBy: [TaskOrderByInput!]! = [] first: Int skip: Int! = 0 ): [Task!] Task(where: TaskWhereUniqueInput!): Task - _allTasksMeta( - where: TaskWhereInput! = {} - search: String - sortBy: [SortTasksBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") - orderBy: [TaskOrderByInput!]! = [] - first: Int - skip: Int! = 0 - ): _QueryMeta - @deprecated( - reason: "This query will be removed in a future version. Please use tasksCount instead." - ) tasksCount(where: TaskWhereInput! = {}): Int allPeople( where: PersonWhereInput! = {} - search: String - sortBy: [SortPeopleBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") orderBy: [PersonOrderByInput!]! = [] first: Int skip: Int! = 0 ): [Person!] Person(where: PersonWhereUniqueInput!): Person - _allPeopleMeta( - where: PersonWhereInput! = {} - search: String - sortBy: [SortPeopleBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") - orderBy: [PersonOrderByInput!]! = [] - first: Int - skip: Int! = 0 - ): _QueryMeta - @deprecated( - reason: "This query will be removed in a future version. Please use peopleCount instead." - ) peopleCount(where: PersonWhereInput! = {}): Int keystone: KeystoneMeta! } diff --git a/examples/custom-field/schema.graphql b/examples/custom-field/schema.graphql index af29f20fabd..b404413bff6 100644 --- a/examples/custom-field/schema.graphql +++ b/examples/custom-field/schema.graphql @@ -64,21 +64,6 @@ input PostWhereUniqueInput { id: ID } -enum SortPostsBy { - id_ASC - id_DESC - title_ASC - title_DESC - status_ASC - status_DESC - content_ASC - content_DESC - rating_ASC - rating_DESC - publishDate_ASC - publishDate_DESC -} - input PostOrderByInput { id: OrderDirection title: OrderDirection @@ -133,32 +118,13 @@ type Author { email: String posts( where: PostWhereInput! = {} - search: String - sortBy: [SortPostsBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") orderBy: [PostOrderByInput!]! = [] first: Int skip: Int! = 0 ): [Post!] - _postsMeta( - where: PostWhereInput! = {} - search: String - sortBy: [SortPostsBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") - orderBy: [PostOrderByInput!]! = [] - first: Int - skip: Int! = 0 - ): _QueryMeta - @deprecated( - reason: "This query will be removed in a future version. Please use postsCount instead." - ) postsCount(where: PostWhereInput! = {}): Int } -type _QueryMeta { - count: Int -} - input AuthorWhereInput { AND: [AuthorWhereInput!] OR: [AuthorWhereInput!] @@ -192,15 +158,6 @@ input AuthorWhereUniqueInput { email: String } -enum SortAuthorsBy { - id_ASC - id_DESC - name_ASC - name_DESC - email_ASC - email_DESC -} - input AuthorOrderByInput { id: OrderDirection name: OrderDirection @@ -261,49 +218,19 @@ type Mutation { type Query { allPosts( where: PostWhereInput! = {} - search: String - sortBy: [SortPostsBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") orderBy: [PostOrderByInput!]! = [] first: Int skip: Int! = 0 ): [Post!] Post(where: PostWhereUniqueInput!): Post - _allPostsMeta( - where: PostWhereInput! = {} - search: String - sortBy: [SortPostsBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") - orderBy: [PostOrderByInput!]! = [] - first: Int - skip: Int! = 0 - ): _QueryMeta - @deprecated( - reason: "This query will be removed in a future version. Please use postsCount instead." - ) postsCount(where: PostWhereInput! = {}): Int allAuthors( where: AuthorWhereInput! = {} - search: String - sortBy: [SortAuthorsBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") orderBy: [AuthorOrderByInput!]! = [] first: Int skip: Int! = 0 ): [Author!] Author(where: AuthorWhereUniqueInput!): Author - _allAuthorsMeta( - where: AuthorWhereInput! = {} - search: String - sortBy: [SortAuthorsBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") - orderBy: [AuthorOrderByInput!]! = [] - first: Int - skip: Int! = 0 - ): _QueryMeta - @deprecated( - reason: "This query will be removed in a future version. Please use authorsCount instead." - ) authorsCount(where: AuthorWhereInput! = {}): Int keystone: KeystoneMeta! } diff --git a/examples/default-values/schema.graphql b/examples/default-values/schema.graphql index 7a9006d84c0..73415451e79 100644 --- a/examples/default-values/schema.graphql +++ b/examples/default-values/schema.graphql @@ -52,19 +52,6 @@ input TaskWhereUniqueInput { id: ID } -enum SortTasksBy { - id_ASC - id_DESC - label_ASC - label_DESC - priority_ASC - priority_DESC - isComplete_ASC - isComplete_DESC - finishBy_ASC - finishBy_DESC -} - input TaskOrderByInput { id: OrderDirection label: OrderDirection @@ -115,32 +102,13 @@ type Person { name: String tasks( where: TaskWhereInput! = {} - search: String - sortBy: [SortTasksBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") orderBy: [TaskOrderByInput!]! = [] first: Int skip: Int! = 0 ): [Task!] - _tasksMeta( - where: TaskWhereInput! = {} - search: String - sortBy: [SortTasksBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") - orderBy: [TaskOrderByInput!]! = [] - first: Int - skip: Int! = 0 - ): _QueryMeta - @deprecated( - reason: "This query will be removed in a future version. Please use tasksCount instead." - ) tasksCount(where: TaskWhereInput! = {}): Int } -type _QueryMeta { - count: Int -} - input PersonWhereInput { AND: [PersonWhereInput!] OR: [PersonWhereInput!] @@ -167,13 +135,6 @@ input PersonWhereUniqueInput { id: ID } -enum SortPeopleBy { - id_ASC - id_DESC - name_ASC - name_DESC -} - input PersonOrderByInput { id: OrderDirection name: OrderDirection @@ -231,49 +192,19 @@ type Mutation { type Query { allTasks( where: TaskWhereInput! = {} - search: String - sortBy: [SortTasksBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") orderBy: [TaskOrderByInput!]! = [] first: Int skip: Int! = 0 ): [Task!] Task(where: TaskWhereUniqueInput!): Task - _allTasksMeta( - where: TaskWhereInput! = {} - search: String - sortBy: [SortTasksBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") - orderBy: [TaskOrderByInput!]! = [] - first: Int - skip: Int! = 0 - ): _QueryMeta - @deprecated( - reason: "This query will be removed in a future version. Please use tasksCount instead." - ) tasksCount(where: TaskWhereInput! = {}): Int allPeople( where: PersonWhereInput! = {} - search: String - sortBy: [SortPeopleBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") orderBy: [PersonOrderByInput!]! = [] first: Int skip: Int! = 0 ): [Person!] Person(where: PersonWhereUniqueInput!): Person - _allPeopleMeta( - where: PersonWhereInput! = {} - search: String - sortBy: [SortPeopleBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") - orderBy: [PersonOrderByInput!]! = [] - first: Int - skip: Int! = 0 - ): _QueryMeta - @deprecated( - reason: "This query will be removed in a future version. Please use peopleCount instead." - ) peopleCount(where: PersonWhereInput! = {}): Int keystone: KeystoneMeta! } diff --git a/examples/document-field/schema.graphql b/examples/document-field/schema.graphql index 04e0d84c69a..5fe71318dfb 100644 --- a/examples/document-field/schema.graphql +++ b/examples/document-field/schema.graphql @@ -61,19 +61,6 @@ input PostWhereUniqueInput { slug: String } -enum SortPostsBy { - id_ASC - id_DESC - title_ASC - title_DESC - slug_ASC - slug_DESC - status_ASC - status_DESC - publishDate_ASC - publishDate_DESC -} - input PostOrderByInput { id: OrderDirection title: OrderDirection @@ -127,33 +114,14 @@ type Author { email: String posts( where: PostWhereInput! = {} - search: String - sortBy: [SortPostsBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") orderBy: [PostOrderByInput!]! = [] first: Int skip: Int! = 0 ): [Post!] - _postsMeta( - where: PostWhereInput! = {} - search: String - sortBy: [SortPostsBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") - orderBy: [PostOrderByInput!]! = [] - first: Int - skip: Int! = 0 - ): _QueryMeta - @deprecated( - reason: "This query will be removed in a future version. Please use postsCount instead." - ) postsCount(where: PostWhereInput! = {}): Int bio: Author_bio_DocumentField } -type _QueryMeta { - count: Int -} - type Author_bio_DocumentField { document(hydrateRelationships: Boolean! = false): JSON! } @@ -191,15 +159,6 @@ input AuthorWhereUniqueInput { email: String } -enum SortAuthorsBy { - id_ASC - id_DESC - name_ASC - name_DESC - email_ASC - email_DESC -} - input AuthorOrderByInput { id: OrderDirection name: OrderDirection @@ -262,49 +221,19 @@ type Mutation { type Query { allPosts( where: PostWhereInput! = {} - search: String - sortBy: [SortPostsBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") orderBy: [PostOrderByInput!]! = [] first: Int skip: Int! = 0 ): [Post!] Post(where: PostWhereUniqueInput!): Post - _allPostsMeta( - where: PostWhereInput! = {} - search: String - sortBy: [SortPostsBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") - orderBy: [PostOrderByInput!]! = [] - first: Int - skip: Int! = 0 - ): _QueryMeta - @deprecated( - reason: "This query will be removed in a future version. Please use postsCount instead." - ) postsCount(where: PostWhereInput! = {}): Int allAuthors( where: AuthorWhereInput! = {} - search: String - sortBy: [SortAuthorsBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") orderBy: [AuthorOrderByInput!]! = [] first: Int skip: Int! = 0 ): [Author!] Author(where: AuthorWhereUniqueInput!): Author - _allAuthorsMeta( - where: AuthorWhereInput! = {} - search: String - sortBy: [SortAuthorsBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") - orderBy: [AuthorOrderByInput!]! = [] - first: Int - skip: Int! = 0 - ): _QueryMeta - @deprecated( - reason: "This query will be removed in a future version. Please use authorsCount instead." - ) authorsCount(where: AuthorWhereInput! = {}): Int keystone: KeystoneMeta! } diff --git a/examples/extend-graphql-schema/schema.graphql b/examples/extend-graphql-schema/schema.graphql index 3776366f4fa..0eb0a3c21ea 100644 --- a/examples/extend-graphql-schema/schema.graphql +++ b/examples/extend-graphql-schema/schema.graphql @@ -55,19 +55,6 @@ input PostWhereUniqueInput { id: ID } -enum SortPostsBy { - id_ASC - id_DESC - title_ASC - title_DESC - status_ASC - status_DESC - content_ASC - content_DESC - publishDate_ASC - publishDate_DESC -} - input PostOrderByInput { id: OrderDirection title: OrderDirection @@ -119,32 +106,13 @@ type Author { email: String posts( where: PostWhereInput! = {} - search: String - sortBy: [SortPostsBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") orderBy: [PostOrderByInput!]! = [] first: Int skip: Int! = 0 ): [Post!] - _postsMeta( - where: PostWhereInput! = {} - search: String - sortBy: [SortPostsBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") - orderBy: [PostOrderByInput!]! = [] - first: Int - skip: Int! = 0 - ): _QueryMeta - @deprecated( - reason: "This query will be removed in a future version. Please use postsCount instead." - ) postsCount(where: PostWhereInput! = {}): Int } -type _QueryMeta { - count: Int -} - input AuthorWhereInput { AND: [AuthorWhereInput!] OR: [AuthorWhereInput!] @@ -178,15 +146,6 @@ input AuthorWhereUniqueInput { email: String } -enum SortAuthorsBy { - id_ASC - id_DESC - name_ASC - name_DESC - email_ASC - email_DESC -} - input AuthorOrderByInput { id: OrderDirection name: OrderDirection @@ -261,49 +220,19 @@ type Statistics { type Query { allPosts( where: PostWhereInput! = {} - search: String - sortBy: [SortPostsBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") orderBy: [PostOrderByInput!]! = [] first: Int skip: Int! = 0 ): [Post!] Post(where: PostWhereUniqueInput!): Post - _allPostsMeta( - where: PostWhereInput! = {} - search: String - sortBy: [SortPostsBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") - orderBy: [PostOrderByInput!]! = [] - first: Int - skip: Int! = 0 - ): _QueryMeta - @deprecated( - reason: "This query will be removed in a future version. Please use postsCount instead." - ) postsCount(where: PostWhereInput! = {}): Int allAuthors( where: AuthorWhereInput! = {} - search: String - sortBy: [SortAuthorsBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") orderBy: [AuthorOrderByInput!]! = [] first: Int skip: Int! = 0 ): [Author!] Author(where: AuthorWhereUniqueInput!): Author - _allAuthorsMeta( - where: AuthorWhereInput! = {} - search: String - sortBy: [SortAuthorsBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") - orderBy: [AuthorOrderByInput!]! = [] - first: Int - skip: Int! = 0 - ): _QueryMeta - @deprecated( - reason: "This query will be removed in a future version. Please use authorsCount instead." - ) authorsCount(where: AuthorWhereInput! = {}): Int """ diff --git a/examples/json/schema.graphql b/examples/json/schema.graphql index 12311df0352..0f32ca2d09b 100644 --- a/examples/json/schema.graphql +++ b/examples/json/schema.graphql @@ -33,15 +33,6 @@ input PackageWhereUniqueInput { id: ID } -enum SortPackagesBy { - id_ASC - id_DESC - label_ASC - label_DESC - isPrivate_ASC - isPrivate_DESC -} - input PackageOrderByInput { id: OrderDirection label: OrderDirection @@ -88,32 +79,13 @@ type Person { name: String packages( where: PackageWhereInput! = {} - search: String - sortBy: [SortPackagesBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") orderBy: [PackageOrderByInput!]! = [] first: Int skip: Int! = 0 ): [Package!] - _packagesMeta( - where: PackageWhereInput! = {} - search: String - sortBy: [SortPackagesBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") - orderBy: [PackageOrderByInput!]! = [] - first: Int - skip: Int! = 0 - ): _QueryMeta - @deprecated( - reason: "This query will be removed in a future version. Please use packagesCount instead." - ) packagesCount(where: PackageWhereInput! = {}): Int } -type _QueryMeta { - count: Int -} - input PersonWhereInput { AND: [PersonWhereInput!] OR: [PersonWhereInput!] @@ -140,13 +112,6 @@ input PersonWhereUniqueInput { id: ID } -enum SortPeopleBy { - id_ASC - id_DESC - name_ASC - name_DESC -} - input PersonOrderByInput { id: OrderDirection name: OrderDirection @@ -204,49 +169,19 @@ type Mutation { type Query { allPackages( where: PackageWhereInput! = {} - search: String - sortBy: [SortPackagesBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") orderBy: [PackageOrderByInput!]! = [] first: Int skip: Int! = 0 ): [Package!] Package(where: PackageWhereUniqueInput!): Package - _allPackagesMeta( - where: PackageWhereInput! = {} - search: String - sortBy: [SortPackagesBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") - orderBy: [PackageOrderByInput!]! = [] - first: Int - skip: Int! = 0 - ): _QueryMeta - @deprecated( - reason: "This query will be removed in a future version. Please use packagesCount instead." - ) packagesCount(where: PackageWhereInput! = {}): Int allPeople( where: PersonWhereInput! = {} - search: String - sortBy: [SortPeopleBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") orderBy: [PersonOrderByInput!]! = [] first: Int skip: Int! = 0 ): [Person!] Person(where: PersonWhereUniqueInput!): Person - _allPeopleMeta( - where: PersonWhereInput! = {} - search: String - sortBy: [SortPeopleBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") - orderBy: [PersonOrderByInput!]! = [] - first: Int - skip: Int! = 0 - ): _QueryMeta - @deprecated( - reason: "This query will be removed in a future version. Please use peopleCount instead." - ) peopleCount(where: PersonWhereInput! = {}): Int keystone: KeystoneMeta! } diff --git a/examples/task-manager/schema.graphql b/examples/task-manager/schema.graphql index 7a9006d84c0..73415451e79 100644 --- a/examples/task-manager/schema.graphql +++ b/examples/task-manager/schema.graphql @@ -52,19 +52,6 @@ input TaskWhereUniqueInput { id: ID } -enum SortTasksBy { - id_ASC - id_DESC - label_ASC - label_DESC - priority_ASC - priority_DESC - isComplete_ASC - isComplete_DESC - finishBy_ASC - finishBy_DESC -} - input TaskOrderByInput { id: OrderDirection label: OrderDirection @@ -115,32 +102,13 @@ type Person { name: String tasks( where: TaskWhereInput! = {} - search: String - sortBy: [SortTasksBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") orderBy: [TaskOrderByInput!]! = [] first: Int skip: Int! = 0 ): [Task!] - _tasksMeta( - where: TaskWhereInput! = {} - search: String - sortBy: [SortTasksBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") - orderBy: [TaskOrderByInput!]! = [] - first: Int - skip: Int! = 0 - ): _QueryMeta - @deprecated( - reason: "This query will be removed in a future version. Please use tasksCount instead." - ) tasksCount(where: TaskWhereInput! = {}): Int } -type _QueryMeta { - count: Int -} - input PersonWhereInput { AND: [PersonWhereInput!] OR: [PersonWhereInput!] @@ -167,13 +135,6 @@ input PersonWhereUniqueInput { id: ID } -enum SortPeopleBy { - id_ASC - id_DESC - name_ASC - name_DESC -} - input PersonOrderByInput { id: OrderDirection name: OrderDirection @@ -231,49 +192,19 @@ type Mutation { type Query { allTasks( where: TaskWhereInput! = {} - search: String - sortBy: [SortTasksBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") orderBy: [TaskOrderByInput!]! = [] first: Int skip: Int! = 0 ): [Task!] Task(where: TaskWhereUniqueInput!): Task - _allTasksMeta( - where: TaskWhereInput! = {} - search: String - sortBy: [SortTasksBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") - orderBy: [TaskOrderByInput!]! = [] - first: Int - skip: Int! = 0 - ): _QueryMeta - @deprecated( - reason: "This query will be removed in a future version. Please use tasksCount instead." - ) tasksCount(where: TaskWhereInput! = {}): Int allPeople( where: PersonWhereInput! = {} - search: String - sortBy: [SortPeopleBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") orderBy: [PersonOrderByInput!]! = [] first: Int skip: Int! = 0 ): [Person!] Person(where: PersonWhereUniqueInput!): Person - _allPeopleMeta( - where: PersonWhereInput! = {} - search: String - sortBy: [SortPeopleBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") - orderBy: [PersonOrderByInput!]! = [] - first: Int - skip: Int! = 0 - ): _QueryMeta - @deprecated( - reason: "This query will be removed in a future version. Please use peopleCount instead." - ) peopleCount(where: PersonWhereInput! = {}): Int keystone: KeystoneMeta! } diff --git a/examples/testing/schema.graphql b/examples/testing/schema.graphql index 29ebca46864..436f9a2b71c 100644 --- a/examples/testing/schema.graphql +++ b/examples/testing/schema.graphql @@ -52,19 +52,6 @@ input TaskWhereUniqueInput { id: ID } -enum SortTasksBy { - id_ASC - id_DESC - label_ASC - label_DESC - priority_ASC - priority_DESC - isComplete_ASC - isComplete_DESC - finishBy_ASC - finishBy_DESC -} - input TaskOrderByInput { id: OrderDirection label: OrderDirection @@ -117,25 +104,10 @@ type Person { password: PasswordState tasks( where: TaskWhereInput! = {} - search: String - sortBy: [SortTasksBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") orderBy: [TaskOrderByInput!]! = [] first: Int skip: Int! = 0 ): [Task!] - _tasksMeta( - where: TaskWhereInput! = {} - search: String - sortBy: [SortTasksBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") - orderBy: [TaskOrderByInput!]! = [] - first: Int - skip: Int! = 0 - ): _QueryMeta - @deprecated( - reason: "This query will be removed in a future version. Please use tasksCount instead." - ) tasksCount(where: TaskWhereInput! = {}): Int } @@ -143,10 +115,6 @@ type PasswordState { isSet: Boolean! } -type _QueryMeta { - count: Int -} - input PersonWhereInput { AND: [PersonWhereInput!] OR: [PersonWhereInput!] @@ -181,15 +149,6 @@ input PersonWhereUniqueInput { email: String } -enum SortPeopleBy { - id_ASC - id_DESC - name_ASC - name_DESC - email_ASC - email_DESC -} - input PersonOrderByInput { id: OrderDirection name: OrderDirection @@ -290,49 +249,19 @@ input CreateInitialPersonInput { type Query { allTasks( where: TaskWhereInput! = {} - search: String - sortBy: [SortTasksBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") orderBy: [TaskOrderByInput!]! = [] first: Int skip: Int! = 0 ): [Task!] Task(where: TaskWhereUniqueInput!): Task - _allTasksMeta( - where: TaskWhereInput! = {} - search: String - sortBy: [SortTasksBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") - orderBy: [TaskOrderByInput!]! = [] - first: Int - skip: Int! = 0 - ): _QueryMeta - @deprecated( - reason: "This query will be removed in a future version. Please use tasksCount instead." - ) tasksCount(where: TaskWhereInput! = {}): Int allPeople( where: PersonWhereInput! = {} - search: String - sortBy: [SortPeopleBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") orderBy: [PersonOrderByInput!]! = [] first: Int skip: Int! = 0 ): [Person!] Person(where: PersonWhereUniqueInput!): Person - _allPeopleMeta( - where: PersonWhereInput! = {} - search: String - sortBy: [SortPeopleBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") - orderBy: [PersonOrderByInput!]! = [] - first: Int - skip: Int! = 0 - ): _QueryMeta - @deprecated( - reason: "This query will be removed in a future version. Please use peopleCount instead." - ) peopleCount(where: PersonWhereInput! = {}): Int authenticatedItem: AuthenticatedItem keystone: KeystoneMeta! diff --git a/examples/virtual-field/schema.graphql b/examples/virtual-field/schema.graphql index 3a44d1d7ed8..fc45fb81c79 100644 --- a/examples/virtual-field/schema.graphql +++ b/examples/virtual-field/schema.graphql @@ -65,19 +65,6 @@ input PostWhereUniqueInput { id: ID } -enum SortPostsBy { - id_ASC - id_DESC - title_ASC - title_DESC - status_ASC - status_DESC - content_ASC - content_DESC - publishDate_ASC - publishDate_DESC -} - input PostOrderByInput { id: OrderDirection title: OrderDirection @@ -129,33 +116,14 @@ type Author { email: String posts( where: PostWhereInput! = {} - search: String - sortBy: [SortPostsBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") orderBy: [PostOrderByInput!]! = [] first: Int skip: Int! = 0 ): [Post!] - _postsMeta( - where: PostWhereInput! = {} - search: String - sortBy: [SortPostsBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") - orderBy: [PostOrderByInput!]! = [] - first: Int - skip: Int! = 0 - ): _QueryMeta - @deprecated( - reason: "This query will be removed in a future version. Please use postsCount instead." - ) postsCount(where: PostWhereInput! = {}): Int latestPost: Post } -type _QueryMeta { - count: Int -} - input AuthorWhereInput { AND: [AuthorWhereInput!] OR: [AuthorWhereInput!] @@ -189,15 +157,6 @@ input AuthorWhereUniqueInput { email: String } -enum SortAuthorsBy { - id_ASC - id_DESC - name_ASC - name_DESC - email_ASC - email_DESC -} - input AuthorOrderByInput { id: OrderDirection name: OrderDirection @@ -258,49 +217,19 @@ type Mutation { type Query { allPosts( where: PostWhereInput! = {} - search: String - sortBy: [SortPostsBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") orderBy: [PostOrderByInput!]! = [] first: Int skip: Int! = 0 ): [Post!] Post(where: PostWhereUniqueInput!): Post - _allPostsMeta( - where: PostWhereInput! = {} - search: String - sortBy: [SortPostsBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") - orderBy: [PostOrderByInput!]! = [] - first: Int - skip: Int! = 0 - ): _QueryMeta - @deprecated( - reason: "This query will be removed in a future version. Please use postsCount instead." - ) postsCount(where: PostWhereInput! = {}): Int allAuthors( where: AuthorWhereInput! = {} - search: String - sortBy: [SortAuthorsBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") orderBy: [AuthorOrderByInput!]! = [] first: Int skip: Int! = 0 ): [Author!] Author(where: AuthorWhereUniqueInput!): Author - _allAuthorsMeta( - where: AuthorWhereInput! = {} - search: String - sortBy: [SortAuthorsBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") - orderBy: [AuthorOrderByInput!]! = [] - first: Int - skip: Int! = 0 - ): _QueryMeta - @deprecated( - reason: "This query will be removed in a future version. Please use authorsCount instead." - ) authorsCount(where: AuthorWhereInput! = {}): Int keystone: KeystoneMeta! } diff --git a/examples/with-auth/schema.graphql b/examples/with-auth/schema.graphql index 29ebca46864..436f9a2b71c 100644 --- a/examples/with-auth/schema.graphql +++ b/examples/with-auth/schema.graphql @@ -52,19 +52,6 @@ input TaskWhereUniqueInput { id: ID } -enum SortTasksBy { - id_ASC - id_DESC - label_ASC - label_DESC - priority_ASC - priority_DESC - isComplete_ASC - isComplete_DESC - finishBy_ASC - finishBy_DESC -} - input TaskOrderByInput { id: OrderDirection label: OrderDirection @@ -117,25 +104,10 @@ type Person { password: PasswordState tasks( where: TaskWhereInput! = {} - search: String - sortBy: [SortTasksBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") orderBy: [TaskOrderByInput!]! = [] first: Int skip: Int! = 0 ): [Task!] - _tasksMeta( - where: TaskWhereInput! = {} - search: String - sortBy: [SortTasksBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") - orderBy: [TaskOrderByInput!]! = [] - first: Int - skip: Int! = 0 - ): _QueryMeta - @deprecated( - reason: "This query will be removed in a future version. Please use tasksCount instead." - ) tasksCount(where: TaskWhereInput! = {}): Int } @@ -143,10 +115,6 @@ type PasswordState { isSet: Boolean! } -type _QueryMeta { - count: Int -} - input PersonWhereInput { AND: [PersonWhereInput!] OR: [PersonWhereInput!] @@ -181,15 +149,6 @@ input PersonWhereUniqueInput { email: String } -enum SortPeopleBy { - id_ASC - id_DESC - name_ASC - name_DESC - email_ASC - email_DESC -} - input PersonOrderByInput { id: OrderDirection name: OrderDirection @@ -290,49 +249,19 @@ input CreateInitialPersonInput { type Query { allTasks( where: TaskWhereInput! = {} - search: String - sortBy: [SortTasksBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") orderBy: [TaskOrderByInput!]! = [] first: Int skip: Int! = 0 ): [Task!] Task(where: TaskWhereUniqueInput!): Task - _allTasksMeta( - where: TaskWhereInput! = {} - search: String - sortBy: [SortTasksBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") - orderBy: [TaskOrderByInput!]! = [] - first: Int - skip: Int! = 0 - ): _QueryMeta - @deprecated( - reason: "This query will be removed in a future version. Please use tasksCount instead." - ) tasksCount(where: TaskWhereInput! = {}): Int allPeople( where: PersonWhereInput! = {} - search: String - sortBy: [SortPeopleBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") orderBy: [PersonOrderByInput!]! = [] first: Int skip: Int! = 0 ): [Person!] Person(where: PersonWhereUniqueInput!): Person - _allPeopleMeta( - where: PersonWhereInput! = {} - search: String - sortBy: [SortPeopleBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") - orderBy: [PersonOrderByInput!]! = [] - first: Int - skip: Int! = 0 - ): _QueryMeta - @deprecated( - reason: "This query will be removed in a future version. Please use peopleCount instead." - ) peopleCount(where: PersonWhereInput! = {}): Int authenticatedItem: AuthenticatedItem keystone: KeystoneMeta! diff --git a/package.json b/package.json index 52e5acd28fa..4080d66115f 100644 --- a/package.json +++ b/package.json @@ -34,8 +34,8 @@ "npm-tag": "manypkg npm-tag", "update": "manypkg upgrade", "no-cypress-install": "cross-env CYPRESS_INSTALL_BINARY=0 yarn", - "postinstall-examples": "for d in `find examples -type d -maxdepth 1 -mindepth 1`; do cd $d; yarn keystone-next postinstall --fix; cd ../..; done; for d in `find examples-staging -type d -maxdepth 1 -mindepth 1`; do cd $d; yarn keystone-next postinstall --fix; cd ../..; done", - "lint:examples": "for d in `find examples -type d -maxdepth 1 -mindepth 1`; do cd $d; echo $d; SKIP_PROMPTS=1 yarn keystone-next postinstall; if [ $? -ne 0 ]; then exit 1; fi; cd ../..; done; for d in `find examples-staging -type d -maxdepth 1 -mindepth 1`; do cd $d; echo $d; SKIP_PROMPTS=1 yarn keystone-next postinstall; if [ $? -ne 0 ]; then exit 1; fi; cd ../..; done" + "postinstall-examples": "for d in `find examples -type d -maxdepth 1 -mindepth 1`; do cd $d; yarn keystone-next postinstall --fix; cd ../..; done; for d in `find examples-staging -type d -maxdepth 1 -mindepth 1`; do cd $d; yarn keystone-next postinstall --fix; cd ../..; done; for d in `find tests/test-projects -type d -maxdepth 1 -mindepth 1`; do cd $d; yarn keystone-next postinstall --fix; cd ../..; done", + "lint:examples": "for d in `find examples -type d -maxdepth 1 -mindepth 1`; do cd $d; echo $d; SKIP_PROMPTS=1 yarn keystone-next postinstall; if [ $? -ne 0 ]; then exit 1; fi; cd ../..; done; for d in `find examples-staging -type d -maxdepth 1 -mindepth 1`; do cd $d; echo $d; SKIP_PROMPTS=1 yarn keystone-next postinstall; if [ $? -ne 0 ]; then exit 1; fi; cd ../..; done; for d in `find tests/test-projects -type d -maxdepth 1 -mindepth 1`; do cd $d; echo $d; SKIP_PROMPTS=1 yarn keystone-next postinstall; if [ $? -ne 0 ]; then exit 1; fi; cd ../..; done" }, "dependencies": { "@babel/core": "^7.14.8", diff --git a/packages/fields/src/types/relationship/index.ts b/packages/fields/src/types/relationship/index.ts index d76df5cd882..65014067a40 100644 --- a/packages/fields/src/types/relationship/index.ts +++ b/packages/fields/src/types/relationship/index.ts @@ -6,7 +6,6 @@ import { schema, AdminMetaRootVal, FieldDefaultValue, - QueryMeta, } from '@keystone-next/types'; import { resolveView } from '../../resolve-view'; @@ -180,14 +179,6 @@ export const relationship = }), extraOutputFields: withMeta ? { - [`_${meta.fieldKey}Meta`]: schema.field({ - type: QueryMeta, - args: listTypes.findManyArgs, - deprecationReason: `This query will be removed in a future version. Please use ${meta.fieldKey}Count instead.`, - resolve({ value }, args) { - return { getCount: () => value.count(args) }; - }, - }), [`${meta.fieldKey}Count`]: schema.field({ type: schema.Int, args: { @@ -196,11 +187,6 @@ export const relationship = resolve({ value }, args) { return value.count({ where: args.where, - orderBy: [], - sortBy: undefined, - first: undefined, - search: undefined, - skip: 0, }); }, }), diff --git a/packages/fields/src/types/relationship/tests/implementation.test.ts b/packages/fields/src/types/relationship/tests/implementation.test.ts index dcb20b6ccc9..a9b61decbf2 100644 --- a/packages/fields/src/types/relationship/tests/implementation.test.ts +++ b/packages/fields/src/types/relationship/tests/implementation.test.ts @@ -201,8 +201,7 @@ describe('Type Generation', () => { expect(printType(schema.getType('Test')!)).toMatchInlineSnapshot(` "type Test { id: ID! - foo(where: ZipWhereInput! = {}, search: String, sortBy: [SortZipsBy!] @deprecated(reason: \\"sortBy has been deprecated in favour of orderBy\\"), orderBy: [ZipOrderByInput!]! = [], first: Int, skip: Int! = 0): [Zip!] - _fooMeta(where: ZipWhereInput! = {}, search: String, sortBy: [SortZipsBy!] @deprecated(reason: \\"sortBy has been deprecated in favour of orderBy\\"), orderBy: [ZipOrderByInput!]! = [], first: Int, skip: Int! = 0): _QueryMeta @deprecated(reason: \\"This query will be removed in a future version. Please use fooCount instead.\\") + foo(where: ZipWhereInput! = {}, orderBy: [ZipOrderByInput!]! = [], first: Int, skip: Int! = 0): [Zip!] fooCount(where: ZipWhereInput! = {}): Int }" `); @@ -214,7 +213,7 @@ describe('Type Generation', () => { expect(printType(schema.getType('Test')!)).toMatchInlineSnapshot(` "type Test { id: ID! - foo(where: ZipWhereInput! = {}, search: String, sortBy: [SortZipsBy!] @deprecated(reason: \\"sortBy has been deprecated in favour of orderBy\\"), orderBy: [ZipOrderByInput!]! = [], first: Int, skip: Int! = 0): [Zip!] + foo(where: ZipWhereInput! = {}, orderBy: [ZipOrderByInput!]! = [], first: Int, skip: Int! = 0): [Zip!] }" `); }); diff --git a/packages/keystone/src/lib/context/itemAPI.ts b/packages/keystone/src/lib/context/itemAPI.ts index 58ae7b2b888..e78e83d705e 100644 --- a/packages/keystone/src/lib/context/itemAPI.ts +++ b/packages/keystone/src/lib/context/itemAPI.ts @@ -32,7 +32,7 @@ export function getDbAPIFactory( const api = { findOne: f(queryFields[gqlNames.itemQueryName]), findMany: f(queryFields[gqlNames.listQueryName]), - count: f(queryFields[gqlNames.listQueryMetaName]), + count: f(queryFields[gqlNames.listQueryCountName]), createOne: f(mutationFields[gqlNames.createMutationName]), createMany: f(mutationFields[gqlNames.createManyMutationName]), updateOne: f(mutationFields[gqlNames.updateMutationName]), @@ -47,7 +47,6 @@ export function getDbAPIFactory( (args: Record) => impl(args, context), ]) ); - obj.count = async (args: Record) => (await api.count(args, context)).getCount(); return obj; }; } @@ -97,12 +96,11 @@ export function itemAPIForList( return { findOne: f('query', gqlNames.itemQueryName, dbAPI.findOne), findMany: f('query', gqlNames.listQueryName, dbAPI.findMany), - async count(args = {}) { - const { first, skip = 0, where = {} } = args; - const { listQueryMetaName, whereInputName } = context.gqlNames(listKey); - const query = `query ($first: Int, $skip: Int! = 0, $where: ${whereInputName}! = {}) { ${listQueryMetaName}(first: $first, skip: $skip, where: $where) { count } }`; - const response = await context.graphql.run({ query, variables: { first, skip, where } }); - return response[listQueryMetaName].count; + async count({ where = {} } = {}) { + const { listQueryCountName, whereInputName } = context.gqlNames(listKey); + const query = `query ($where: ${whereInputName}!) { count: ${listQueryCountName}(where: $where) }`; + const response = await context.graphql.run({ query, variables: { where } }); + return response.count; }, createOne: f('mutation', gqlNames.createMutationName, dbAPI.createOne), createMany: f('mutation', gqlNames.createManyMutationName, dbAPI.createMany), diff --git a/packages/keystone/src/lib/core/graphql-schema.ts b/packages/keystone/src/lib/core/graphql-schema.ts index ad902e69648..9e0260af483 100644 --- a/packages/keystone/src/lib/core/graphql-schema.ts +++ b/packages/keystone/src/lib/core/graphql-schema.ts @@ -61,7 +61,6 @@ function collectTypes( } collectedTypes.push(list.types.where.graphQLType); collectedTypes.push(list.types.uniqueWhere.graphQLType); - collectedTypes.push(list.types.findManyArgs.sortBy.type.of.of.graphQLType); collectedTypes.push(list.types.orderBy.graphQLType); } if (list.access.update) { diff --git a/packages/keystone/src/lib/core/queries/index.ts b/packages/keystone/src/lib/core/queries/index.ts index 6898738237a..4e335310f11 100644 --- a/packages/keystone/src/lib/core/queries/index.ts +++ b/packages/keystone/src/lib/core/queries/index.ts @@ -1,6 +1,5 @@ -import { getGqlNames, QueryMeta, schema } from '@keystone-next/types'; +import { getGqlNames, schema } from '@keystone-next/types'; import { InitialisedList } from '../types-for-lists'; -import { applyFirstSkipToCount } from '../utils'; import * as queries from './resolvers'; export function getQueriesForList(list: InitialisedList) { @@ -27,50 +26,13 @@ export function getQueriesForList(list: InitialisedList) { type: schema.Int, args: { where: schema.arg({ type: schema.nonNull(list.types.where), defaultValue: {} }) }, async resolve(_rootVal, args, context, info) { - const count = await queries.count(args, list, context); - if (info && info.cacheControl && list.cacheHint) { - info.cacheControl.setCacheHint( - list.cacheHint({ - results: count, - operationName: info.operation.name?.value, - meta: true, - }) as any - ); - } - return count; + return queries.count(args, list, context, info); }, }); - const metaQuery = schema.field({ - type: QueryMeta, - args: list.types.findManyArgs, - resolve(_rootVal, { first, search, skip, where }, context, info) { - return { - getCount: async () => { - const count = applyFirstSkipToCount({ - count: await queries.count({ where, search }, list, context), - first, - skip, - }); - if (info && info.cacheControl && list.cacheHint) { - info.cacheControl.setCacheHint( - list.cacheHint({ - results: count, - operationName: info.operation.name?.value, - meta: true, - }) as any - ); - } - return count; - }, - }; - }, - deprecationReason: `This query will be removed in a future version. Please use ${names.listQueryCountName} instead.`, - }); return { [names.listQueryName]: findMany, [names.itemQueryName]: findOne, - [names.listQueryMetaName]: metaQuery, [names.listQueryCountName]: countQuery, }; } diff --git a/packages/keystone/src/lib/core/queries/output-field.ts b/packages/keystone/src/lib/core/queries/output-field.ts index c91960d7136..33ef64f6b20 100644 --- a/packages/keystone/src/lib/core/queries/output-field.ts +++ b/packages/keystone/src/lib/core/queries/output-field.ts @@ -8,18 +8,14 @@ import { schema, FindManyArgsValue, KeystoneContext, + TypesForList, } from '@keystone-next/types'; import { GraphQLResolveInfo } from 'graphql'; import { validateFieldAccessControl } from '../access-control'; import { accessDeniedError } from '../graphql-errors'; import { ResolvedDBField, ResolvedRelationDBField } from '../resolve-relationships'; import { InitialisedList } from '../types-for-lists'; -import { - applyFirstSkipToCount, - IdType, - getDBFieldKeyForFieldOnMultiField, - runWithPrisma, -} from '../utils'; +import { IdType, getDBFieldKeyForFieldOnMultiField, runWithPrisma } from '../utils'; import { accessControlledFilter } from './resolvers'; import * as queries from './resolvers'; @@ -39,24 +35,8 @@ function getRelationVal( return { findMany: async (args: FindManyArgsValue) => queries.findMany(args, foreignList, context, info, relationFilter), - count: async ({ where, search, first, skip }: FindManyArgsValue) => { - // This is the same as the legacy metaQuery resolver - const count = applyFirstSkipToCount({ - count: await queries.count({ where, search }, foreignList, context, relationFilter), - first, - skip, - }); - if (info.cacheControl && foreignList.cacheHint) { - info.cacheControl.setCacheHint( - foreignList.cacheHint({ - results: count, - operationName: info.operation.name?.value, - meta: true, - }) as any - ); - } - return count; - }, + count: async ({ where }: { where: TypesForList['where'] }) => + queries.count({ where }, foreignList, context, info, relationFilter), }; } else { return async () => { diff --git a/packages/keystone/src/lib/core/queries/resolvers.ts b/packages/keystone/src/lib/core/queries/resolvers.ts index ee8a334ad17..73c36d81c14 100644 --- a/packages/keystone/src/lib/core/queries/resolvers.ts +++ b/packages/keystone/src/lib/core/queries/resolvers.ts @@ -46,8 +46,7 @@ export function mapUniqueWhereToWhere( export async function accessControlledFilter( list: InitialisedList, context: KeystoneContext, - resolvedWhere: PrismaFilter, - search?: string | null | undefined + resolvedWhere: PrismaFilter ) { // Run access control const access = await validateNonCreateListAccessControl({ @@ -63,11 +62,6 @@ export async function accessControlledFilter( resolvedWhere = { AND: [resolvedWhere, await resolveWhereInput(access, list)] }; } - // Merge legacy `search` inputs - if (search) { - resolvedWhere = list.applySearchField(resolvedWhere, search); - } - return resolvedWhere; } @@ -92,18 +86,18 @@ export async function findOne( } export async function findMany( - { where, first, skip, orderBy: rawOrderBy, search, sortBy }: FindManyArgsValue, + { where, first, skip, orderBy: rawOrderBy }: FindManyArgsValue, list: InitialisedList, context: KeystoneContext, info: GraphQLResolveInfo, extraFilter?: PrismaFilter ): Promise { - const orderBy = await resolveOrderBy(rawOrderBy, sortBy, list, context); + const orderBy = await resolveOrderBy(rawOrderBy, list, context); applyEarlyMaxResults(first, list); let resolvedWhere = await resolveWhereInput(where || {}, list); - resolvedWhere = await accessControlledFilter(list, context, resolvedWhere, search); + resolvedWhere = await accessControlledFilter(list, context, resolvedWhere); const results = await runWithPrisma(context, list, model => model.findMany({ @@ -126,68 +120,70 @@ export async function findMany( async function resolveOrderBy( orderBy: readonly Record[], - sortBy: readonly string[] | null | undefined, list: InitialisedList, context: KeystoneContext ): Promise[]> { - return ( - await Promise.all( - orderBy.map(async orderBySelection => { - const keys = Object.keys(orderBySelection); + return await Promise.all( + orderBy.map(async orderBySelection => { + const keys = Object.keys(orderBySelection); + if (keys.length !== 1) { + throw new Error( + `Only a single key must be passed to ${list.types.orderBy.graphQLType.name}` + ); + } + + const fieldKey = keys[0]; + const value = orderBySelection[fieldKey]; + if (value === null) { + throw new Error('null cannot be passed as an order direction'); + } + + const field = list.fields[fieldKey]; + const resolve = field.input!.orderBy!.resolve; + const resolvedValue = resolve ? await resolve(value, context) : value; + if (field.dbField.kind === 'multi') { + const keys = Object.keys(resolvedValue); if (keys.length !== 1) { throw new Error( - `Only a single key must be passed to ${list.types.orderBy.graphQLType.name}` + `Only a single key must be returned from an orderBy input resolver for a multi db field` ); } - - const fieldKey = keys[0]; - const value = orderBySelection[fieldKey]; - if (value === null) { - throw new Error('null cannot be passed as an order direction'); - } - - const field = list.fields[fieldKey]; - const resolve = field.input!.orderBy!.resolve; - const resolvedValue = resolve ? await resolve(value, context) : value; - if (field.dbField.kind === 'multi') { - const keys = Object.keys(resolvedValue); - if (keys.length !== 1) { - throw new Error( - `Only a single key must be returned from an orderBy input resolver for a multi db field` - ); - } - const innerKey = keys[0]; - return { - [getDBFieldKeyForFieldOnMultiField(fieldKey, innerKey)]: resolvedValue[innerKey], - }; - } else { - return { [fieldKey]: resolvedValue }; - } - }) - ) - ).concat( - sortBy?.map(sort => - sort.endsWith('_DESC') - ? { [sort.slice(0, -'_DESC'.length)]: 'desc' } - : { [sort.slice(0, -'_ASC'.length)]: 'asc' } - ) || [] + const innerKey = keys[0]; + return { + [getDBFieldKeyForFieldOnMultiField(fieldKey, innerKey)]: resolvedValue[innerKey], + }; + } else { + return { [fieldKey]: resolvedValue }; + } + }) ); } export async function count( - { where, search }: { where: Record; search?: string | null }, + { where }: { where: Record }, list: InitialisedList, context: KeystoneContext, + info: GraphQLResolveInfo, extraFilter?: PrismaFilter ) { let resolvedWhere = await resolveWhereInput(where || {}, list); - resolvedWhere = await accessControlledFilter(list, context, resolvedWhere, search); + resolvedWhere = await accessControlledFilter(list, context, resolvedWhere); - return runWithPrisma(context, list, model => + const count = await runWithPrisma(context, list, model => model.count({ where: extraFilter === undefined ? resolvedWhere : { AND: [resolvedWhere, extraFilter] }, }) ); + if (info.cacheControl && list.cacheHint) { + info.cacheControl.setCacheHint( + list.cacheHint({ + results: count, + operationName: info.operation.name?.value, + meta: true, + }) as any + ); + } + return count; } const limitsExceedError = (args: { type: string; limit: number; list: string }) => diff --git a/packages/keystone/src/lib/core/types-for-lists.ts b/packages/keystone/src/lib/core/types-for-lists.ts index 3f621466521..a179f3b66ac 100644 --- a/packages/keystone/src/lib/core/types-for-lists.ts +++ b/packages/keystone/src/lib/core/types-for-lists.ts @@ -11,11 +11,9 @@ import { KeystoneConfig, DatabaseProvider, FindManyArgs, - orderDirectionEnum, CacheHintArgs, } from '@keystone-next/types'; import { FieldHooks } from '@keystone-next/types/src/config/hooks'; -import { GraphQLEnumType } from 'graphql'; import { ResolvedFieldAccessControl, ResolvedListAccessControl, @@ -44,7 +42,6 @@ export type InitialisedList = { access: ResolvedListAccessControl; hooks: ListHooks; adminUILabels: { label: string; singular: string; plural: string; path: string }; - applySearchField: (filter: PrismaFilter, search: string | null | undefined) => PrismaFilter; cacheHint: ((args: CacheHintArgs) => CacheHint) | undefined; maxResults: number; listKey: string; @@ -163,15 +160,6 @@ export function initialiseLists( const findManyArgs: FindManyArgs = { where: schema.arg({ type: schema.nonNull(where), defaultValue: {} }), - search: schema.arg({ type: schema.String }), - sortBy: schema.arg({ - type: schema.list( - schema.nonNull( - schema.enum({ name: names.listSortName, values: schema.enumValues(['bad']) }) - ) - ), - deprecationReason: 'sortBy has been deprecated in favour of orderBy', - }), orderBy: schema.arg({ type: schema.nonNull(schema.list(schema.nonNull(orderBy))), defaultValue: [], @@ -278,35 +266,10 @@ export function initialiseLists( }) ); - for (const [listKey, { fields, pluralGraphQLName }] of Object.entries( + for (const [listKey, { fields }] of Object.entries( listsWithInitialisedFieldsAndResolvedDbFields )) { assertFieldsValid({ listKey, fields }); - // this is quite a hack, we could do this in a better way if we "initialised" the fields twice, - // the first time to see if they have an orderBy and then the second time for real - // but that would be more complicated and this works - Object.assign( - listInfos[listKey].types.findManyArgs.sortBy.type.graphQLType.ofType.ofType, - new GraphQLEnumType({ - name: getGqlNames({ listKey, pluralGraphQLName }).listSortName, - values: Object.fromEntries( - Object.entries(fields).flatMap(([fieldKey, field]) => { - if ( - field.input?.orderBy?.arg.type === orderDirectionEnum && - field.input?.orderBy?.arg.defaultValue === undefined && - field.input?.orderBy?.resolve === undefined && - field.access.read !== false - ) { - return [ - [`${fieldKey}_ASC`, {}], - [`${fieldKey}_DESC`, {}], - ]; - } - return []; - }) - ), - }) - ); } const lists: Record = {}; @@ -338,24 +301,6 @@ export function initialiseLists( } }) ), - applySearchField: (filter, search) => { - const searchFieldName = listsConfig[listKey].db?.searchField ?? 'name'; - const searchField = list.fields[searchFieldName]; - if (search != null && search !== '' && searchField) { - if (searchField.dbField.kind === 'scalar' && searchField.dbField.scalar === 'String') { - const mode = provider === 'sqlite' ? undefined : 'insensitive'; - filter = { - AND: [filter, { [searchFieldName]: { contains: search, mode } }], - }; - } else { - // Return no results - filter = { - AND: [filter, { [searchFieldName]: null }, { NOT: { [searchFieldName]: null } }], - }; - } - } - return filter; - }, cacheHint: (() => { const cacheHint = listsConfig[listKey].graphql?.cacheHint; if (cacheHint === undefined) { diff --git a/packages/keystone/src/lib/core/utils.ts b/packages/keystone/src/lib/core/utils.ts index c038a6f663b..d380eabb062 100644 --- a/packages/keystone/src/lib/core/utils.ts +++ b/packages/keystone/src/lib/core/utils.ts @@ -89,25 +89,6 @@ declare const idTypeSymbol: unique symbol; export type IdType = { ___keystoneIdType: typeof idTypeSymbol; toString(): string }; -export function applyFirstSkipToCount({ - count, - first, - skip, -}: { - count: number; - first: number | null | undefined; - skip: number | null | undefined; -}) { - if (skip !== undefined && skip !== null) { - count -= skip; - } - if (first !== undefined && first !== null) { - count = Math.min(count, first); - } - count = Math.max(0, count); // Don't want to go negative from a skip! - return count; -} - // these aren't here out of thinking this is better syntax(i do not think it is), // it's just because TS won't infer the arg is X bit export const isFulfilled = (arg: PromiseSettledResult): arg is PromiseFulfilledResult => diff --git a/packages/keystone/src/scripts/tests/__snapshots__/artifacts.test.ts.snap b/packages/keystone/src/scripts/tests/__snapshots__/artifacts.test.ts.snap index 65ad7753dfc..9a42f31b22e 100644 --- a/packages/keystone/src/scripts/tests/__snapshots__/artifacts.test.ts.snap +++ b/packages/keystone/src/scripts/tests/__snapshots__/artifacts.test.ts.snap @@ -47,8 +47,6 @@ export type TodoWhereUniqueInput = { readonly id?: Scalars['ID'] | null; }; -export type SortTodosBy = 'id_ASC' | 'id_DESC' | 'title_ASC' | 'title_DESC'; - export type TodoOrderByInput = { readonly id?: OrderDirection | null; readonly title?: OrderDirection | null; @@ -99,7 +97,6 @@ export type TodoListTypeInfo = { args: { listQuery: { readonly where?: TodoWhereInput; - readonly sortBy?: ReadonlyArray | SortTodosBy | null; readonly orderBy?: ReadonlyArray | TodoOrderByInput; readonly first?: Scalars['Int'] | null; readonly skip?: Scalars['Int']; diff --git a/packages/keystone/src/scripts/tests/fixtures/basic-project/schema.graphql b/packages/keystone/src/scripts/tests/fixtures/basic-project/schema.graphql index 198276054cd..4092898e2b7 100644 --- a/packages/keystone/src/scripts/tests/fixtures/basic-project/schema.graphql +++ b/packages/keystone/src/scripts/tests/fixtures/basic-project/schema.graphql @@ -26,13 +26,6 @@ input TodoWhereUniqueInput { id: ID } -enum SortTodosBy { - id_ASC - id_DESC - title_ASC - title_DESC -} - input TodoOrderByInput { id: OrderDirection title: OrderDirection @@ -68,10 +61,6 @@ scalar JSON url: "http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf" ) -type _QueryMeta { - count: Int -} - type Mutation { createTodo(data: TodoCreateInput): Todo createTodos(data: [TodosCreateInput]): [Todo] @@ -84,26 +73,11 @@ type Mutation { type Query { allTodos( where: TodoWhereInput! = {} - search: String - sortBy: [SortTodosBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") orderBy: [TodoOrderByInput!]! = [] first: Int skip: Int! = 0 ): [Todo!] Todo(where: TodoWhereUniqueInput!): Todo - _allTodosMeta( - where: TodoWhereInput! = {} - search: String - sortBy: [SortTodosBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") - orderBy: [TodoOrderByInput!]! = [] - first: Int - skip: Int! = 0 - ): _QueryMeta - @deprecated( - reason: "This query will be removed in a future version. Please use todosCount instead." - ) todosCount(where: TodoWhereInput! = {}): Int keystone: KeystoneMeta! } diff --git a/packages/types/src/config/lists.ts b/packages/types/src/config/lists.ts index c53b706c34f..5c44eef13c0 100644 --- a/packages/types/src/config/lists.ts +++ b/packages/types/src/config/lists.ts @@ -199,11 +199,6 @@ export type ListGraphQLConfig = { export type CacheHintArgs = { results: any; operationName?: string; meta: boolean }; export type ListDBConfig = { - /** - * The name of the field to use for `search` filter operations. - * @default "name"" - */ - searchField?: string; /** * The kind of id to use. * @default { kind: "cuid" } diff --git a/packages/types/src/context.ts b/packages/types/src/context.ts index 8258cb874ba..89c77a518d3 100644 --- a/packages/types/src/context.ts +++ b/packages/types/src/context.ts @@ -38,7 +38,9 @@ export type KeystoneListsAPI>; - count(args?: KeystoneListsTypeInfo[Key]['args']['listQuery']): Promise; + count(args?: { + readonly where?: KeystoneListsTypeInfo[Key]['inputs']['where']; + }): Promise; updateOne( args: { readonly id: string; @@ -92,7 +94,9 @@ export type KeystoneDbAPI; - count(args?: KeystoneListsTypeInfo[Key]['args']['listQuery']): Promise; + count(args?: { + readonly where?: KeystoneListsTypeInfo[Key]['inputs']['where']; + }): Promise; updateOne(args: { readonly id: string; readonly data: KeystoneListsTypeInfo[Key]['inputs']['update']; diff --git a/packages/types/src/core.ts b/packages/types/src/core.ts index b334a7af1f1..c353c1e02d8 100644 --- a/packages/types/src/core.ts +++ b/packages/types/src/core.ts @@ -54,9 +54,7 @@ export function getGqlNames({ outputTypeName: listKey, itemQueryName: listKey, listQueryName: `all${pluralGraphQLName}`, - listQueryMetaName: `_all${pluralGraphQLName}Meta`, listQueryCountName: `${_lowerListName}Count`, - listSortName: `Sort${pluralGraphQLName}By`, listOrderName: `${listKey}OrderByInput`, deleteMutationName: `delete${listKey}`, updateMutationName: `update${listKey}`, diff --git a/packages/types/src/next-fields.ts b/packages/types/src/next-fields.ts index 293b89c6be8..02f4aaf9567 100644 --- a/packages/types/src/next-fields.ts +++ b/packages/types/src/next-fields.ts @@ -7,18 +7,6 @@ import { AdminMetaRootVal, JSONValue, KeystoneContext, MaybePromise } from '.'; export { Decimal }; -export const QueryMeta = schema.object<{ getCount: () => Promise }>()({ - name: '_QueryMeta', - fields: { - count: schema.field({ - type: schema.Int, - resolve({ getCount }) { - return getCount(); - }, - }), - }, -}); - // CacheScope and CacheHint are sort of duplicated from apollo-cache-control // because they use an enum which means TS users have to import the CacheScope enum from apollo-cache-control which isn't great // so we have a copy of it but using a union of string literals instead of an enum @@ -206,7 +194,7 @@ type DBFieldToOutputValue = TDBField extends ScalarDBF one: () => Promise; many: { findMany(args: FindManyArgsValue): Promise; - count(args: FindManyArgsValue): Promise; + count(args: { where: FindManyArgsValue['where'] }): Promise; }; }[Mode] : TDBField extends EnumDBField @@ -409,10 +397,6 @@ export type FindManyArgs = { schema.NonNullType>>, Record[] >; - search: schema.Arg; - sortBy: schema.Arg< - schema.ListType>>>> - >; first: schema.Arg; skip: schema.Arg, number>; }; diff --git a/packages/types/src/utils.ts b/packages/types/src/utils.ts index a5d7e4b27f4..ab5e373f11b 100644 --- a/packages/types/src/utils.ts +++ b/packages/types/src/utils.ts @@ -11,13 +11,11 @@ export type BaseGeneratedListTypes = { args: { listQuery: { readonly where?: GraphQLInput | null; - readonly search?: string | null; readonly first?: number | null; - readonly skip?: number | null; + readonly skip?: number; readonly orderBy?: | Record | readonly Record[]; - readonly sortBy?: string | ReadonlyArray | null; }; }; }; @@ -38,9 +36,7 @@ export type GqlNames = { outputTypeName: string; itemQueryName: string; listQueryName: string; - listQueryMetaName: string; listQueryCountName: string; - listSortName: string; listOrderName: string; deleteMutationName: string; updateMutationName: string; diff --git a/tests/api-tests/queries/cache-hints.test.ts b/tests/api-tests/queries/cache-hints.test.ts index 184d86988fd..fa7a17adbba 100644 --- a/tests/api-tests/queries/cache-hints.test.ts +++ b/tests/api-tests/queries/cache-hints.test.ts @@ -244,9 +244,7 @@ describe('cache hints', () => { query: ` query { allPosts { - _authorMeta { - count - } + authorCount } } `, diff --git a/tests/api-tests/queries/search.test.ts b/tests/api-tests/queries/search.test.ts deleted file mode 100644 index 15f2a9c3d20..00000000000 --- a/tests/api-tests/queries/search.test.ts +++ /dev/null @@ -1,246 +0,0 @@ -import { text, integer } from '@keystone-next/fields'; -import { createSchema, list } from '@keystone-next/keystone/schema'; -import { setupTestRunner } from '@keystone-next/testing'; -import { apiTestConfig } from '../utils'; - -const runner = setupTestRunner({ - config: apiTestConfig({ - lists: createSchema({ - Test: list({ - fields: { - name: text(), - }, - }), - Number: list({ - fields: { - name: integer(), - }, - }), - Custom: list({ - fields: { - other: text(), - }, - db: { searchField: 'other' }, - }), - }), - }), -}); - -test( - 'users', - runner(async ({ context }) => { - const create = async (listKey: string, data: any) => context.lists[listKey].createOne({ data }); - await Promise.all([ - create('Test', { name: 'one' }), - create('Test', { name: '%islikelike%' }), - create('Test', { name: 'three' }), - create('Number', { name: 12345 }), - ]); - - const data = await context.graphql.run({ - query: ` - query { - allTests( - search: "one", - ) { - name - } - } - `, - }); - expect(data).toHaveProperty('allTests'); - expect(data.allTests).toEqual([{ name: 'one' }]); - }) -); - -test( - 'users - case sensitive', - runner(async ({ context }) => { - const create = async (listKey: string, data: any) => context.lists[listKey].createOne({ data }); - await Promise.all([ - create('Test', { name: 'one' }), - create('Test', { name: '%islikelike%' }), - create('Test', { name: 'three' }), - create('Number', { name: 12345 }), - ]); - - const data = await context.graphql.run({ - query: ` - query { - allTests( - search: "ONE", - ) { - name - } - } - `, - }); - expect(data).toHaveProperty('allTests'); - expect(data.allTests).toEqual([{ name: 'one' }]); - }) -); - -test( - 'users - partial case sensitive', - runner(async ({ context }) => { - const create = async (listKey: string, data: any) => context.lists[listKey].createOne({ data }); - await Promise.all([ - create('Test', { name: 'one' }), - create('Test', { name: '%islikelike%' }), - create('Test', { name: 'three' }), - create('Number', { name: 12345 }), - ]); - - const data = await context.graphql.run({ - query: ` - query { - allTests( - search: "N", - ) { - name - } - } - `, - }); - expect(data).toHaveProperty('allTests'); - expect(data.allTests).toEqual([{ name: 'one' }]); - }) -); - -test( - 'users - like escapes', - runner(async ({ context }) => { - const create = async (listKey: string, data: any) => context.lists[listKey].createOne({ data }); - await Promise.all([ - create('Test', { name: 'one' }), - create('Test', { name: '%islikelike%' }), - create('Test', { name: 'three' }), - create('Number', { name: 12345 }), - ]); - - const data = await context.graphql.run({ - query: ` - query { - allTests( - search: ${JSON.stringify(`%islikelike%`)}, - ) { - name - } - } - `, - }); - expect(data).toHaveProperty('allTests'); - expect(data.allTests).toEqual([{ name: '%islikelike%' }]); - }) -); - -test( - 'users - regex', - runner(async ({ context }) => { - const create = async (listKey: string, data: any) => context.lists[listKey].createOne({ data }); - - await Promise.all([ - create('Test', { name: 'one' }), - create('Test', { name: '%islikelike%' }), - create('Test', { name: 'three' }), - create('Number', { name: 12345 }), - ]); - - const data = await context.graphql.run({ - query: ` - query { - allTests( - search: ${JSON.stringify(`/thr(.*)/`)}, - ) { - name - } - } - `, - }); - expect(data).toHaveProperty('allTests'); - expect(data.allTests).toEqual([]); // No results - }) -); - -test( - 'users - numbers', - runner(async ({ context }) => { - const create = async (listKey: string, data: any) => context.lists[listKey].createOne({ data }); - await Promise.all([ - create('Test', { name: 'one' }), - create('Test', { name: '%islikelike%' }), - create('Test', { name: 'three' }), - create('Number', { name: 12345 }), - ]); - - const data = await context.graphql.run({ - query: ` - query { - allNumbers( - search: "12345", - ) { - name - } - } - `, - }); - expect(data).toHaveProperty('allNumbers'); - expect(data.allNumbers).toEqual([]); // No results - }) -); - -test( - 'empty string', - runner(async ({ context }) => { - const create = async (listKey: string, data: any) => context.lists[listKey].createOne({ data }); - await Promise.all([ - create('Test', { name: 'one' }), - create('Test', { name: '%islikelike%' }), - create('Test', { name: 'three' }), - create('Number', { name: 12345 }), - ]); - - const data = await context.graphql.run({ - query: ` - query { - allTests( - orderBy: { name: asc }, - search: "", - ) { - name - } - } - `, - }); - expect(data).toHaveProperty('allTests'); - expect(data.allTests).toEqual([{ name: '%islikelike%' }, { name: 'one' }, { name: 'three' }]); // All results - }) -); -test( - 'custom', - runner(async ({ context }) => { - const create = async (listKey: string, data: any) => context.lists[listKey].createOne({ data }); - await Promise.all([ - create('Test', { name: 'one' }), - create('Test', { name: '%islikelike%' }), - create('Test', { name: 'three' }), - create('Number', { name: 12345 }), - create('Custom', { other: 'one' }), - create('Custom', { other: 'two' }), - ]); - - const data = await context.graphql.run({ - query: ` - query { - allCustoms( - search: "one", - ) { - other - } - } - `, - }); - expect(data).toHaveProperty('allCustoms'); - expect(data.allCustoms).toEqual([{ other: 'one' }]); - }) -); diff --git a/tests/api-tests/queries/sortBy.test.ts b/tests/api-tests/queries/sortBy.test.ts deleted file mode 100644 index 1b4a0a1dc74..00000000000 --- a/tests/api-tests/queries/sortBy.test.ts +++ /dev/null @@ -1,242 +0,0 @@ -import { integer } from '@keystone-next/fields'; -import { createSchema, list } from '@keystone-next/keystone/schema'; -import { setupTestRunner } from '@keystone-next/testing'; -import { KeystoneContext } from '@keystone-next/types'; -import { apiTestConfig } from '../utils'; - -const runner = setupTestRunner({ - config: apiTestConfig({ - lists: createSchema({ - User: list({ - fields: { - a: integer(), - b: integer(), - }, - }), - }), - }), -}); - -const initialiseData = async ({ context }: { context: KeystoneContext }) => { - // Use shuffled data to ensure that sorting is actually happening. - await context.lists.User.createMany({ - data: [ - { data: { a: 1, b: 10 } }, - { data: { a: 1, b: 30 } }, - { data: { a: 1, b: 20 } }, - { data: { a: 3, b: 30 } }, - { data: { a: 3, b: 10 } }, - { data: { a: 3, b: 20 } }, - { data: { a: 2, b: 30 } }, - { data: { a: 2, b: 20 } }, - { data: { a: 2, b: 10 } }, - ], - }); -}; - -describe('Sorting by a single field', () => { - test( - 'Single ascending filter - a', - runner(async ({ context }) => { - await initialiseData({ context }); - const users = await context.lists.User.findMany({ sortBy: ['a_ASC'], query: 'a' }); - expect(users.map(({ a }) => a)).toEqual([1, 1, 1, 2, 2, 2, 3, 3, 3]); - }) - ); - test( - 'Single descending filter - a', - runner(async ({ context }) => { - await initialiseData({ context }); - const users = await context.lists.User.findMany({ sortBy: ['a_DESC'], query: 'a' }); - expect(users.map(({ a }) => a)).toEqual([3, 3, 3, 2, 2, 2, 1, 1, 1]); - }) - ); - test( - 'Single ascending filter - b', - runner(async ({ context }) => { - await initialiseData({ context }); - const users = await context.lists.User.findMany({ sortBy: ['b_ASC'], query: 'b' }); - expect(users.map(({ b }) => b)).toEqual([10, 10, 10, 20, 20, 20, 30, 30, 30]); - }) - ); - test( - 'Single descending filter - b', - runner(async ({ context }) => { - await initialiseData({ context }); - const users = await context.lists.User.findMany({ sortBy: ['b_DESC'], query: 'b' }); - expect(users.map(({ b }) => b)).toEqual([30, 30, 30, 20, 20, 20, 10, 10, 10]); - }) - ); - - test( - 'Multi ascending/ascending filter - a,b ', - runner(async ({ context }) => { - await initialiseData({ context }); - const users = await context.lists.User.findMany({ - sortBy: ['a_ASC', 'b_ASC'], - query: 'a b', - }); - expect(users.map(({ a, b }) => [a, b])).toEqual([ - [1, 10], - [1, 20], - [1, 30], - [2, 10], - [2, 20], - [2, 30], - [3, 10], - [3, 20], - [3, 30], - ]); - }) - ); - test( - 'Multi ascending/ascending filter - b,a ', - runner(async ({ context }) => { - await initialiseData({ context }); - const users = await context.lists.User.findMany({ - sortBy: ['b_ASC', 'a_ASC'], - query: 'a b', - }); - expect(users.map(({ a, b }) => [a, b])).toEqual([ - [1, 10], - [2, 10], - [3, 10], - [1, 20], - [2, 20], - [3, 20], - [1, 30], - [2, 30], - [3, 30], - ]); - }) - ); - - test( - 'Multi ascending/descending filter - a,b ', - runner(async ({ context }) => { - await initialiseData({ context }); - const users = await context.lists.User.findMany({ - sortBy: ['a_ASC', 'b_DESC'], - query: 'a b', - }); - expect(users.map(({ a, b }) => [a, b])).toEqual([ - [1, 30], - [1, 20], - [1, 10], - [2, 30], - [2, 20], - [2, 10], - [3, 30], - [3, 20], - [3, 10], - ]); - }) - ); - test( - 'Multi ascending/descending filter - b,a ', - runner(async ({ context }) => { - await initialiseData({ context }); - const users = await context.lists.User.findMany({ - sortBy: ['b_ASC', 'a_DESC'], - query: 'a b', - }); - expect(users.map(({ a, b }) => [a, b])).toEqual([ - [3, 10], - [2, 10], - [1, 10], - [3, 20], - [2, 20], - [1, 20], - [3, 30], - [2, 30], - [1, 30], - ]); - }) - ); - - test( - 'Multi descending/ascending filter - a,b ', - runner(async ({ context }) => { - await initialiseData({ context }); - const users = await context.lists.User.findMany({ - sortBy: ['a_DESC', 'b_ASC'], - query: 'a b', - }); - expect(users.map(({ a, b }) => [a, b])).toEqual([ - [3, 10], - [3, 20], - [3, 30], - [2, 10], - [2, 20], - [2, 30], - [1, 10], - [1, 20], - [1, 30], - ]); - }) - ); - test( - 'Multi descending/ascending filter - b,a ', - runner(async ({ context }) => { - await initialiseData({ context }); - const users = await context.lists.User.findMany({ - sortBy: ['b_DESC', 'a_ASC'], - query: 'a b', - }); - expect(users.map(({ a, b }) => [a, b])).toEqual([ - [1, 30], - [2, 30], - [3, 30], - [1, 20], - [2, 20], - [3, 20], - [1, 10], - [2, 10], - [3, 10], - ]); - }) - ); - - test( - 'Multi descending/descending filter - a,b ', - runner(async ({ context }) => { - await initialiseData({ context }); - const users = await context.lists.User.findMany({ - sortBy: ['a_DESC', 'b_DESC'], - query: 'a b', - }); - expect(users.map(({ a, b }) => [a, b])).toEqual([ - [3, 30], - [3, 20], - [3, 10], - [2, 30], - [2, 20], - [2, 10], - [1, 30], - [1, 20], - [1, 10], - ]); - }) - ); - test( - 'Multi descending/descending filter - b,a ', - runner(async ({ context }) => { - await initialiseData({ context }); - const users = await context.lists.User.findMany({ - sortBy: ['b_DESC', 'a_DESC'], - query: 'a b', - }); - expect(users.map(({ a, b }) => [a, b])).toEqual([ - [3, 30], - [2, 30], - [1, 30], - [3, 20], - [2, 20], - [1, 20], - [3, 10], - [2, 10], - [1, 10], - ]); - }) - ); -}); diff --git a/tests/api-tests/relationships/filtering/nested.test.ts b/tests/api-tests/relationships/filtering/nested.test.ts index d2709da47da..21a56b645b9 100644 --- a/tests/api-tests/relationships/filtering/nested.test.ts +++ b/tests/api-tests/relationships/filtering/nested.test.ts @@ -172,10 +172,10 @@ describe('relationship meta filtering', () => { ], }); - const users = await context.lists.User.findMany({ query: 'id _postsMeta { count }' }); + const users = await context.lists.User.findMany({ query: 'id postsCount' }); expect(users).toHaveLength(2); - expect(users).toContainEqual({ id: user.id, _postsMeta: { count: 3 } }); - expect(users).toContainEqual({ id: user2.id, _postsMeta: { count: 1 } }); + expect(users).toContainEqual({ id: user.id, postsCount: 3 }); + expect(users).toContainEqual({ id: user2.id, postsCount: 1 }); }) ); @@ -198,38 +198,11 @@ describe('relationship meta filtering', () => { }); const users = await context.lists.User.findMany({ - query: 'id _postsMeta(where: { content_contains: "hi" }){ count }', + query: 'id postsCount(where: { content_contains: "hi" })', }); expect(users).toHaveLength(2); - expect(users).toContainEqual({ id: user.id, _postsMeta: { count: 2 } }); - expect(users).toContainEqual({ id: user2.id, _postsMeta: { count: 0 } }); - }) - ); - - test( - 'nested to-many relationship meta can be limited', - runner(async ({ context }) => { - const ids = await context.lists.Post.createMany({ - data: [ - { data: { content: 'Hello world' } }, - { data: { content: 'hi world' } }, - { data: { content: 'Hello? Or hi?' } }, - ], - }); - - const [user, user2] = await context.lists.User.createMany({ - data: [ - { data: { posts: { connect: ids } } }, - { data: { posts: { connect: [ids[0]] } } }, // Create a dummy user to make sure we're actually filtering it out - ], - }); - - const users = await context.lists.User.findMany({ - query: 'id _postsMeta(first: 1) { count }', - }); - expect(users).toHaveLength(2); - expect(users).toContainEqual({ id: user.id, _postsMeta: { count: 1 } }); - expect(users).toContainEqual({ id: user2.id, _postsMeta: { count: 1 } }); + expect(users).toContainEqual({ id: user.id, postsCount: 2 }); + expect(users).toContainEqual({ id: user2.id, postsCount: 0 }); }) ); @@ -252,12 +225,12 @@ describe('relationship meta filtering', () => { }); const users = await context.lists.User.findMany({ - query: `id _postsMeta(where: { AND: [{ content_contains: "hi" }, { content_contains: "lo" }] }) { count }`, + query: `id postsCount(where: { AND: [{ content_contains: "hi" }, { content_contains: "lo" }] })`, }); expect(users).toHaveLength(2); - expect(users).toContainEqual({ id: user.id, _postsMeta: { count: 1 } }); - expect(users).toContainEqual({ id: user2.id, _postsMeta: { count: 0 } }); + expect(users).toContainEqual({ id: user.id, postsCount: 1 }); + expect(users).toContainEqual({ id: user2.id, postsCount: 0 }); }) ); @@ -281,11 +254,11 @@ describe('relationship meta filtering', () => { const users = await context.lists.User.findMany({ query: - 'id _postsMeta(where: { OR: [{ content_contains: "i w" }, { content_contains: "? O" }] }){ count }', + 'id postsCount(where: { OR: [{ content_contains: "i w" }, { content_contains: "? O" }] })', }); expect(users).toHaveLength(2); - expect(users).toContainEqual({ id: user.id, _postsMeta: { count: 2 } }); - expect(users).toContainEqual({ id: user2.id, _postsMeta: { count: 0 } }); + expect(users).toContainEqual({ id: user.id, postsCount: 2 }); + expect(users).toContainEqual({ id: user2.id, postsCount: 0 }); }) ); }); diff --git a/tests/test-projects/basic/schema.graphql b/tests/test-projects/basic/schema.graphql index 46ad01e07c4..73415451e79 100644 --- a/tests/test-projects/basic/schema.graphql +++ b/tests/test-projects/basic/schema.graphql @@ -1,6 +1,3 @@ -""" - A keystone list -""" type Task { id: ID! label: String @@ -55,19 +52,6 @@ input TaskWhereUniqueInput { id: ID } -enum SortTasksBy { - id_ASC - id_DESC - label_ASC - label_DESC - priority_ASC - priority_DESC - isComplete_ASC - isComplete_DESC - finishBy_ASC - finishBy_DESC -} - input TaskOrderByInput { id: OrderDirection label: OrderDirection @@ -113,40 +97,18 @@ input TasksCreateInput { data: TaskCreateInput } -""" - A keystone list -""" type Person { id: ID! name: String tasks( where: TaskWhereInput! = {} - search: String - sortBy: [SortTasksBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") orderBy: [TaskOrderByInput!]! = [] first: Int skip: Int! = 0 ): [Task!] - _tasksMeta( - where: TaskWhereInput! = {} - search: String - sortBy: [SortTasksBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") - orderBy: [TaskOrderByInput!]! = [] - first: Int - skip: Int! = 0 - ): _QueryMeta - @deprecated( - reason: "This query will be removed in a future version. Please use tasksCount instead." - ) tasksCount(where: TaskWhereInput! = {}): Int } -type _QueryMeta { - count: Int -} - input PersonWhereInput { AND: [PersonWhereInput!] OR: [PersonWhereInput!] @@ -164,20 +126,8 @@ input PersonWhereInput { name_not_contains: String name_in: [String] name_not_in: [String] - - """ - condition must be true for all nodes - """ tasks_every: TaskWhereInput - - """ - condition must be true for at least 1 node - """ tasks_some: TaskWhereInput - - """ - condition must be false for all nodes - """ tasks_none: TaskWhereInput } @@ -185,13 +135,6 @@ input PersonWhereUniqueInput { id: ID } -enum SortPeopleBy { - id_ASC - id_DESC - name_ASC - name_DESC -} - input PersonOrderByInput { id: OrderDirection name: OrderDirection @@ -232,136 +175,36 @@ scalar JSON ) type Mutation { - """ - Create a single Task item. - """ createTask(data: TaskCreateInput): Task - - """ - Create multiple Task items. - """ createTasks(data: [TasksCreateInput]): [Task] - - """ - Update a single Task item by ID. - """ updateTask(id: ID!, data: TaskUpdateInput): Task - - """ - Update multiple Task items by ID. - """ updateTasks(data: [TasksUpdateInput]): [Task] - - """ - Delete a single Task item by ID. - """ deleteTask(id: ID!): Task - - """ - Delete multiple Task items by ID. - """ deleteTasks(ids: [ID!]): [Task] - - """ - Create a single Person item. - """ createPerson(data: PersonCreateInput): Person - - """ - Create multiple Person items. - """ createPeople(data: [PeopleCreateInput]): [Person] - - """ - Update a single Person item by ID. - """ updatePerson(id: ID!, data: PersonUpdateInput): Person - - """ - Update multiple Person items by ID. - """ updatePeople(data: [PeopleUpdateInput]): [Person] - - """ - Delete a single Person item by ID. - """ deletePerson(id: ID!): Person - - """ - Delete multiple Person items by ID. - """ deletePeople(ids: [ID!]): [Person] } type Query { - """ - Search for all Task items which match the where clause. - """ allTasks( where: TaskWhereInput! = {} - search: String - sortBy: [SortTasksBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") orderBy: [TaskOrderByInput!]! = [] first: Int skip: Int! = 0 ): [Task!] - - """ - Search for the Task item with the matching ID. - """ Task(where: TaskWhereUniqueInput!): Task - - """ - Perform a meta-query on all Task items which match the where clause. - """ - _allTasksMeta( - where: TaskWhereInput! = {} - search: String - sortBy: [SortTasksBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") - orderBy: [TaskOrderByInput!]! = [] - first: Int - skip: Int! = 0 - ): _QueryMeta - @deprecated( - reason: "This query will be removed in a future version. Please use tasksCount instead." - ) tasksCount(where: TaskWhereInput! = {}): Int - - """ - Search for all Person items which match the where clause. - """ allPeople( where: PersonWhereInput! = {} - search: String - sortBy: [SortPeopleBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") orderBy: [PersonOrderByInput!]! = [] first: Int skip: Int! = 0 ): [Person!] - - """ - Search for the Person item with the matching ID. - """ Person(where: PersonWhereUniqueInput!): Person - - """ - Perform a meta-query on all Person items which match the where clause. - """ - _allPeopleMeta( - where: PersonWhereInput! = {} - search: String - sortBy: [SortPeopleBy!] - @deprecated(reason: "sortBy has been deprecated in favour of orderBy") - orderBy: [PersonOrderByInput!]! = [] - first: Int - skip: Int! = 0 - ): _QueryMeta - @deprecated( - reason: "This query will be removed in a future version. Please use peopleCount instead." - ) peopleCount(where: PersonWhereInput! = {}): Int keystone: KeystoneMeta! } @@ -406,6 +249,7 @@ type KeystoneAdminUIFieldMeta { createView: KeystoneAdminUIFieldMetaCreateView! listView: KeystoneAdminUIFieldMetaListView! itemView(id: ID!): KeystoneAdminUIFieldMetaItemView + search: QueryMode } type KeystoneAdminUIFieldMetaCreateView { @@ -436,6 +280,11 @@ enum KeystoneAdminUIFieldMetaItemViewFieldMode { hidden } +enum QueryMode { + default + insensitive +} + type KeystoneAdminUISort { field: String! direction: KeystoneAdminUISortDirection!