From 902f0c79f0391db78bc7facbe30fe8510cf90a68 Mon Sep 17 00:00:00 2001 From: Emma Hamilton Date: Mon, 3 Feb 2025 14:59:41 +1000 Subject: [PATCH 1/7] Update @graphql-ts/schema and @graphql-ts/extend --- packages/core/package.json | 4 ++-- pnpm-lock.yaml | 22 +++++++++++----------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/packages/core/package.json b/packages/core/package.json index 4c8c1cf54fd..e0ef5f63826 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -220,8 +220,8 @@ "@aws-sdk/lib-storage": "^3.83.0", "@aws-sdk/s3-request-presigner": "^3.83.0", "@babel/runtime": "^7.24.7", - "@graphql-ts/extend": "^1.0.0", - "@graphql-ts/schema": "^0.6.0", + "@graphql-ts/extend": "^1.0.1", + "@graphql-ts/schema": "^0.6.1", "@graphql-typed-document-node/core": "^3.1.2", "@hapi/iron": "^7.0.0", "@internationalized/date": "^3.5.5", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e89141c5dc0..7f436e274b4 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1606,11 +1606,11 @@ importers: specifier: ^7.24.7 version: 7.26.7 '@graphql-ts/extend': - specifier: ^1.0.0 - version: 1.0.0(@graphql-ts/schema@0.6.0(graphql@16.10.0))(graphql@16.10.0) + specifier: ^1.0.1 + version: 1.0.1(@graphql-ts/schema@0.6.1(graphql@16.10.0))(graphql@16.10.0) '@graphql-ts/schema': - specifier: ^0.6.0 - version: 0.6.0(graphql@16.10.0) + specifier: ^0.6.1 + version: 0.6.1(graphql@16.10.0) '@graphql-typed-document-node/core': specifier: ^3.1.2 version: 3.2.0(graphql@16.10.0) @@ -4045,14 +4045,14 @@ packages: peerDependencies: graphql: ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0 - '@graphql-ts/extend@1.0.0': - resolution: {integrity: sha512-KdBgOEcTp08h86IVNZR6+DRrmqX8uRplB6qpcB3Jq9cC6tzjtGifIrkQOSx/GivuiWeE0kt8r+uxA+U86nERjw==} + '@graphql-ts/extend@1.0.1': + resolution: {integrity: sha512-cZ42snN+1UDYeD49YqnWrNGnRUKD8uoizM4yf2aIHudtZUdaR07eFDdwrr0wWzob53hPf3d3a73EnRTudwf5Dg==} peerDependencies: '@graphql-ts/schema': ^0.6.0 graphql: 15 || 16 - '@graphql-ts/schema@0.6.0': - resolution: {integrity: sha512-MO99ZdQ6GeLcW5up+hbGx8cLZhVrzl9/1kDH/FRyipq5isB0je6WKMdyzx2hnKrCPqVGIWsXykYzHxuIHJGb5A==} + '@graphql-ts/schema@0.6.1': + resolution: {integrity: sha512-ybYOJ4akmRKttA57nyi5/m6MRfcyXs5lirMVp0WOqXvSa3nGiIRP8106cGEvA8jMa33nE0hk+OqNJUIJmku1EA==} peerDependencies: graphql: 15 || 16 @@ -14381,13 +14381,13 @@ snapshots: graphql: 16.10.0 tslib: 2.8.1 - '@graphql-ts/extend@1.0.0(@graphql-ts/schema@0.6.0(graphql@16.10.0))(graphql@16.10.0)': + '@graphql-ts/extend@1.0.1(@graphql-ts/schema@0.6.1(graphql@16.10.0))(graphql@16.10.0)': dependencies: '@babel/runtime': 7.26.7 - '@graphql-ts/schema': 0.6.0(graphql@16.10.0) + '@graphql-ts/schema': 0.6.1(graphql@16.10.0) graphql: 16.10.0 - '@graphql-ts/schema@0.6.0(graphql@16.10.0)': + '@graphql-ts/schema@0.6.1(graphql@16.10.0)': dependencies: '@babel/runtime': 7.26.7 graphql: 16.10.0 From 0a1fddd95f5c22e1a6995c50e194402a97f5dc17 Mon Sep 17 00:00:00 2001 From: Emma Hamilton Date: Mon, 3 Feb 2025 15:00:07 +1000 Subject: [PATCH 2/7] Rename `graphql` export to `g` and add deprecated alias --- packages/core/src/index.ts | 8 +++++- packages/core/src/types/schema/index.ts | 3 +- .../core/src/types/schema/legacy-alias.d.ts | 28 +++++++++++++++++++ .../core/src/types/schema/legacy-alias.js | 1 + 4 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 packages/core/src/types/schema/legacy-alias.d.ts create mode 100644 packages/core/src/types/schema/legacy-alias.js diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index 19f535dc7e7..3dd160b4d67 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -1,3 +1,9 @@ export { list, config, group } from './schema' export type { ListConfig, BaseFields } from './types' -export { graphql } from './types/schema' +// this re-exports `g` and `graphql` +// note the usage of export * over explicitly listing the exports +// is intentional here so that users can use "Rename Symbol" to +// change their usage of `graphql` to `g` in their project +// if this was an explicit list, it would change the re-export here +// rather than the usage in their project +export * from './types/schema' diff --git a/packages/core/src/types/schema/index.ts b/packages/core/src/types/schema/index.ts index c7e07016692..0ab2a35a8c9 100644 --- a/packages/core/src/types/schema/index.ts +++ b/packages/core/src/types/schema/index.ts @@ -1 +1,2 @@ -export * as graphql from './graphql-ts-schema' +export * as g from './graphql-ts-schema' +export * from './legacy-alias' diff --git a/packages/core/src/types/schema/legacy-alias.d.ts b/packages/core/src/types/schema/legacy-alias.d.ts new file mode 100644 index 00000000000..dd3bd147a8f --- /dev/null +++ b/packages/core/src/types/schema/legacy-alias.d.ts @@ -0,0 +1,28 @@ +import * as _graphql from './graphql-ts-schema' + +/** + * The `graphql` export has been renamed to `g`. + * + * To quickly update usages of `graphql` in your project to `g`: + * + * 1. Navigate to + * `node_modules/@keystone-6/core/dist/declarations/src/types/schema/legacy-alias.d.ts` + * in your editor ("Go to Definition" will not take you to the correct file) + * 2. Use "Rename Symbol" to rename `graphql` to `g`, this will update usages of + * `graphql` to `g` + * 3. Change this deprecated alias back from `g` to `graphql` using normal text + * editing (avoid using "Rename Symbol" again because you want to preserve + * the updates you made in step 2) + * + * You can also use "Rename Symbol" to quickly rename your own custom defined + * `graphql` export to `g`. + * + * @deprecated + */ +// this is what you should run "Rename Symbol" on +// when that is done, you should change it back to `export import graphql = _graphql;` +// avoid using "Rename Symbol" to revert it because you want to +// preserve the updates you made to the usages of `graphql` +// ||||||| +// vvvvvvv +export import graphql = _graphql diff --git a/packages/core/src/types/schema/legacy-alias.js b/packages/core/src/types/schema/legacy-alias.js new file mode 100644 index 00000000000..c7e07016692 --- /dev/null +++ b/packages/core/src/types/schema/legacy-alias.js @@ -0,0 +1 @@ +export * as graphql from './graphql-ts-schema' From d137db9be653ea616b5bdb1ee303158b52df095a Mon Sep 17 00:00:00 2001 From: Emma Hamilton Date: Mon, 3 Feb 2025 15:01:32 +1000 Subject: [PATCH 3/7] Update usages with Rename Symbol --- examples/custom-field/1-text-field/index.ts | 12 +- examples/custom-field/2-stars-field/index.ts | 12 +- .../custom-field/3-pair-field-json/index.ts | 26 +- .../custom-field/3-pair-field-nested/index.ts | 26 +- examples/custom-field/3-pair-field/index.ts | 18 +- .../4-conditional-field/index.tsx | 12 +- .../schema.ts | 36 +- examples/graphql-ts-gql/schema.ts | 28 +- examples/number-fields/schema.ts | 6 +- examples/transactions/schema.ts | 10 +- examples/usecase-relationship-union/schema.ts | 6 +- examples/virtual-field/schema.ts | 32 +- packages/auth/src/gql/getBaseAuthSchema.ts | 28 +- .../auth/src/gql/getInitFirstItemSchema.ts | 20 +- packages/auth/src/schema.ts | 6 +- packages/cloudinary/src/index.ts | 102 +-- .../core/src/fields/filters/enum-filter.ts | 68 +- .../src/fields/filters/providers/mysql.ts | 580 ++++++++--------- .../fields/filters/providers/postgresql.ts | 586 +++++++++--------- .../src/fields/filters/providers/sqlite.ts | 580 ++++++++--------- .../core/src/fields/types/bigInt/index.ts | 16 +- .../src/fields/types/calendarDay/index.ts | 60 +- .../core/src/fields/types/checkbox/index.ts | 14 +- .../core/src/fields/types/decimal/index.ts | 18 +- packages/core/src/fields/types/file/index.ts | 22 +- packages/core/src/fields/types/float/index.ts | 16 +- packages/core/src/fields/types/image/index.ts | 32 +- .../core/src/fields/types/integer/index.ts | 16 +- packages/core/src/fields/types/json/index.ts | 8 +- .../src/fields/types/multiselect/index.ts | 22 +- .../core/src/fields/types/password/index.ts | 18 +- .../src/fields/types/relationship/index.ts | 28 +- .../core/src/fields/types/select/index.ts | 46 +- packages/core/src/fields/types/text/index.ts | 18 +- .../core/src/fields/types/timestamp/index.ts | 20 +- .../core/src/fields/types/virtual/index.ts | 10 +- .../core/src/lib/core/field-assertions.ts | 6 +- .../core/src/lib/core/initialise-lists.ts | 104 ++-- packages/core/src/lib/core/mutations/index.ts | 56 +- .../nested-mutation-many-input-resolvers.ts | 10 +- .../nested-mutation-one-input-resolvers.ts | 12 +- packages/core/src/lib/core/queries/index.ts | 20 +- .../core/src/lib/core/queries/output-field.ts | 4 +- packages/core/src/lib/createGraphQLSchema.ts | 20 +- packages/core/src/lib/id-field.ts | 36 +- packages/core/src/lib/resolve-admin-meta.ts | 2 +- .../json-field-type-polyfill-for-sqlite.ts | 24 +- packages/core/src/types/next-fields.ts | 164 ++--- .../component-blocks/api-shared.ts | 10 +- .../DocumentEditor/component-blocks/api.tsx | 36 +- packages/fields-document/src/index.ts | 18 +- .../src/structure-graphql-input.ts | 56 +- .../src/structure-graphql-output.ts | 48 +- packages/fields-document/src/structure.ts | 20 +- tests/api-tests/extend-graphql-schema.test.ts | 22 +- tests/api-tests/fields/types/Virtual.test.ts | 24 +- tests/api-tests/queries/cache-hints.test.ts | 20 +- tests/sandbox/configs/all-the-things.ts | 6 +- tests/test-projects/live-reloading/schema.ts | 8 +- .../schemas/changed-prisma-schema.ts | 8 +- .../live-reloading/schemas/initial.ts | 8 +- .../live-reloading/schemas/second.ts | 12 +- 62 files changed, 1656 insertions(+), 1656 deletions(-) diff --git a/examples/custom-field/1-text-field/index.ts b/examples/custom-field/1-text-field/index.ts index 208343b72d3..d30ee5e5a6f 100644 --- a/examples/custom-field/1-text-field/index.ts +++ b/examples/custom-field/1-text-field/index.ts @@ -5,7 +5,7 @@ import { fieldType, orderDirectionEnum, } from '@keystone-6/core/types' -import { graphql } from '@keystone-6/core' +import { g } from '@keystone-6/core' type TextFieldConfig = CommonFieldConfig & { isIndexed?: boolean | 'unique' @@ -25,16 +25,16 @@ export function text ({ ...config, input: { create: { - arg: graphql.arg({ type: graphql.String }), + arg: g.arg({ type: g.String }), resolve (value, context) { return value }, }, - update: { arg: graphql.arg({ type: graphql.String }) }, - orderBy: { arg: graphql.arg({ type: orderDirectionEnum }) }, + update: { arg: g.arg({ type: g.String }) }, + orderBy: { arg: g.arg({ type: orderDirectionEnum }) }, }, - output: graphql.field({ - type: graphql.String, + output: g.field({ + type: g.String, resolve ({ value, item }, args, context, info) { return value }, diff --git a/examples/custom-field/2-stars-field/index.ts b/examples/custom-field/2-stars-field/index.ts index d13e7e49803..3f2bcb6bbef 100644 --- a/examples/custom-field/2-stars-field/index.ts +++ b/examples/custom-field/2-stars-field/index.ts @@ -5,7 +5,7 @@ import { fieldType, orderDirectionEnum, } from '@keystone-6/core/types' -import { graphql } from '@keystone-6/core' +import { g } from '@keystone-6/core' // this field is based on the integer field // but with validation to ensure the value is within an expected range @@ -47,7 +47,7 @@ export function stars ({ // all of these inputs are optional if they don't make sense for a particular field type input: { create: { - arg: graphql.arg({ type: graphql.Int }), + arg: g.arg({ type: g.Int }), // this field type doesn't need to do anything special // but field types can specify resolvers for inputs like they can for their output GraphQL field // this function can be omitted, it is here purely to show how you could change it @@ -67,11 +67,11 @@ export function stars ({ return val }, }, - update: { arg: graphql.arg({ type: graphql.Int }) }, - orderBy: { arg: graphql.arg({ type: orderDirectionEnum }) }, + update: { arg: g.arg({ type: g.Int }) }, + orderBy: { arg: g.arg({ type: orderDirectionEnum }) }, }, - output: graphql.field({ - type: graphql.Int, + output: g.field({ + type: g.Int, // like the input resolvers, providing the resolver is unnecessary if you're just returning the value // it is shown here to show what you could do resolve ({ value, item }, args, context, info) { diff --git a/examples/custom-field/3-pair-field-json/index.ts b/examples/custom-field/3-pair-field-json/index.ts index 97d62b11540..4a37901c7de 100644 --- a/examples/custom-field/3-pair-field-json/index.ts +++ b/examples/custom-field/3-pair-field-json/index.ts @@ -4,7 +4,7 @@ import { type FieldTypeFunc, fieldType, } from '@keystone-6/core/types' -import { graphql } from '@keystone-6/core' +import { g } from '@keystone-6/core' type PairFieldConfig = CommonFieldConfig @@ -14,26 +14,26 @@ type PairInput = { } type PairOutput = PairInput -const PairInput = graphql.inputObject({ +const PairInput = g.inputObject({ name: 'PairJsonInput', fields: { - left: graphql.arg({ type: graphql.String }), - right: graphql.arg({ type: graphql.String }), + left: g.arg({ type: g.String }), + right: g.arg({ type: g.String }), }, }) -const PairOutput = graphql.object()({ +const PairOutput = g.object()({ name: 'PairJsonOutput', fields: { - left: graphql.field({ type: graphql.String }), - right: graphql.field({ type: graphql.String }), + left: g.field({ type: g.String }), + right: g.field({ type: g.String }), }, }) -const PairFilter = graphql.inputObject({ +const PairFilter = g.inputObject({ name: 'PairJsonFilter', fields: { - equals: graphql.arg({ + equals: g.arg({ type: PairInput, }), }, @@ -71,25 +71,25 @@ export function pair ( ...config, input: { where: { - arg: graphql.arg({ type: PairFilter }), + arg: g.arg({ type: PairFilter }), resolve (value, context) { return resolveWhere(value) }, }, create: { - arg: graphql.arg({ type: PairInput }), + arg: g.arg({ type: PairInput }), resolve (value, context) { return resolveInput(value) }, }, update: { - arg: graphql.arg({ type: PairInput }), + arg: g.arg({ type: PairInput }), resolve (value, context) { return resolveInput(value) }, }, }, - output: graphql.field({ + output: g.field({ type: PairOutput, resolve ({ value, item }, args, context, info) { return resolveOutput(value) diff --git a/examples/custom-field/3-pair-field-nested/index.ts b/examples/custom-field/3-pair-field-nested/index.ts index 249ee89c436..8ba834b0c6a 100644 --- a/examples/custom-field/3-pair-field-nested/index.ts +++ b/examples/custom-field/3-pair-field-nested/index.ts @@ -4,7 +4,7 @@ import { type FieldTypeFunc, fieldType, } from '@keystone-6/core/types' -import { graphql } from '@keystone-6/core' +import { g } from '@keystone-6/core' type PairFieldConfig = CommonFieldConfig @@ -14,26 +14,26 @@ type PairInput = { } type PairOutput = PairInput -const PairInput = graphql.inputObject({ +const PairInput = g.inputObject({ name: 'PairNestedInput', fields: { - left: graphql.arg({ type: graphql.String }), - right: graphql.arg({ type: graphql.String }), + left: g.arg({ type: g.String }), + right: g.arg({ type: g.String }), }, }) -const PairOutput = graphql.object()({ +const PairOutput = g.object()({ name: 'PairNestedOutput', fields: { - left: graphql.field({ type: graphql.String }), - right: graphql.field({ type: graphql.String }), + left: g.field({ type: g.String }), + right: g.field({ type: g.String }), }, }) -const PairFilter = graphql.inputObject({ +const PairFilter = g.inputObject({ name: 'PairNestedFilter', fields: { - equals: graphql.arg({ + equals: g.arg({ type: PairInput, }), }, @@ -81,25 +81,25 @@ export function pair ( ...config, input: { where: { - arg: graphql.arg({ type: PairFilter }), + arg: g.arg({ type: PairFilter }), resolve (value, context) { return resolveWhere(value) }, }, create: { - arg: graphql.arg({ type: PairInput }), + arg: g.arg({ type: PairInput }), resolve (value, context) { return resolveInput(value) }, }, update: { - arg: graphql.arg({ type: PairInput }), + arg: g.arg({ type: PairInput }), resolve (value, context) { return resolveInput(value) }, }, }, - output: graphql.field({ + output: g.field({ type: PairOutput, resolve ({ value, item }, args, context, info) { return resolveOutput(value) diff --git a/examples/custom-field/3-pair-field/index.ts b/examples/custom-field/3-pair-field/index.ts index 3ff8cc8cec2..0dc593c0f62 100644 --- a/examples/custom-field/3-pair-field/index.ts +++ b/examples/custom-field/3-pair-field/index.ts @@ -4,20 +4,20 @@ import { type FieldTypeFunc, fieldType, } from '@keystone-6/core/types' -import { graphql } from '@keystone-6/core' +import { g } from '@keystone-6/core' type PairFieldConfig = CommonFieldConfig type PairInput = string type PairOutput = string -const PairInput = graphql.String -const PairOutput = graphql.String +const PairInput = g.String +const PairOutput = g.String -const PairFilter = graphql.inputObject({ +const PairFilter = g.inputObject({ name: 'PairFilter', fields: { - equals: graphql.arg({ type: graphql.String }), + equals: g.arg({ type: g.String }), }, }) @@ -68,25 +68,25 @@ export function pair ( ...config, input: { where: { - arg: graphql.arg({ type: PairFilter }), + arg: g.arg({ type: PairFilter }), resolve (value, context) { return resolveWhere(value) }, }, create: { - arg: graphql.arg({ type: PairInput }), + arg: g.arg({ type: PairInput }), resolve (value, context) { return resolveInput(value) }, }, update: { - arg: graphql.arg({ type: PairInput }), + arg: g.arg({ type: PairInput }), resolve (value, context) { return resolveInput(value) }, }, }, - output: graphql.field({ + output: g.field({ type: PairOutput, resolve ({ value, item }, args, context, info) { return resolveOutput(value) diff --git a/examples/custom-field/4-conditional-field/index.tsx b/examples/custom-field/4-conditional-field/index.tsx index 336c08cc01e..9c632ab62d6 100644 --- a/examples/custom-field/4-conditional-field/index.tsx +++ b/examples/custom-field/4-conditional-field/index.tsx @@ -5,7 +5,7 @@ import { fieldType, orderDirectionEnum, } from '@keystone-6/core/types' -import { graphql } from '@keystone-6/core' +import { g } from '@keystone-6/core' type TextFieldConfig = CommonFieldConfig & { isIndexed?: boolean | 'unique' @@ -30,16 +30,16 @@ export function feedback ({ ...config, input: { create: { - arg: graphql.arg({ type: graphql.String }), + arg: g.arg({ type: g.String }), resolve (value, context) { return value }, }, - update: { arg: graphql.arg({ type: graphql.String }) }, - orderBy: { arg: graphql.arg({ type: orderDirectionEnum }) }, + update: { arg: g.arg({ type: g.String }) }, + orderBy: { arg: g.arg({ type: orderDirectionEnum }) }, }, - output: graphql.field({ - type: graphql.String, + output: g.field({ + type: g.String, resolve ({ value, item }, args, context, info) { return value }, diff --git a/examples/extend-graphql-schema-graphql-ts/schema.ts b/examples/extend-graphql-schema-graphql-ts/schema.ts index 88fa002334c..cce873cba83 100644 --- a/examples/extend-graphql-schema-graphql-ts/schema.ts +++ b/examples/extend-graphql-schema-graphql-ts/schema.ts @@ -1,4 +1,4 @@ -import { graphql, list } from '@keystone-6/core' +import { g, list } from '@keystone-6/core' import { allowAll } from '@keystone-6/core/access' import { select, relationship, text, timestamp } from '@keystone-6/core/fields' import { type Context, type Lists } from '.keystone/types' @@ -31,27 +31,27 @@ export const lists = { }), } satisfies Lists -export const extendGraphqlSchema = graphql.extend(base => { - const Statistics = graphql.object<{ authorId: string }>()({ +export const extendGraphqlSchema = g.extend(base => { + const Statistics = g.object<{ authorId: string }>()({ name: 'Statistics', fields: { - draft: graphql.field({ - type: graphql.Int, + draft: g.field({ + type: g.Int, resolve ({ authorId }, args, context: Context) { return context.query.Post.count({ where: { author: { id: { equals: authorId } }, status: { equals: 'draft' } }, }) }, }), - published: graphql.field({ - type: graphql.Int, + published: g.field({ + type: g.Int, resolve ({ authorId }, args, context: Context) { return context.query.Post.count({ where: { author: { id: { equals: authorId } }, status: { equals: 'published' } }, }) }, }), - latest: graphql.field({ + latest: g.field({ type: base.object('Post'), async resolve ({ authorId }, args, context: Context) { const [post] = await context.db.Post.findMany({ @@ -67,11 +67,11 @@ export const extendGraphqlSchema = graphql.extend(base => { return { mutation: { - publishPost: graphql.field({ + publishPost: g.field({ // base.object will return an object type from the existing schema // with the name provided or throw if it doesn't exist type: base.object('Post'), - args: { id: graphql.arg({ type: graphql.nonNull(graphql.ID) }) }, + args: { id: g.arg({ type: g.nonNull(g.ID) }) }, resolve (source, { id }, context: Context) { // Note we use `context.db.Post` here as we have a return type // of Post, and this API provides results in the correct format. @@ -87,9 +87,9 @@ export const extendGraphqlSchema = graphql.extend(base => { // only add this mutation for a sudo Context (this is not usable from the API) ...(base.schema.extensions.sudo ? { - banPost: graphql.field({ + banPost: g.field({ type: base.object('Post'), - args: { id: graphql.arg({ type: graphql.nonNull(graphql.ID) }) }, + args: { id: g.arg({ type: g.nonNull(g.ID) }) }, resolve (source, { id }, context: Context) { return context.db.Post.updateOne({ where: { id }, @@ -101,11 +101,11 @@ export const extendGraphqlSchema = graphql.extend(base => { : {}), }, query: { - recentPosts: graphql.field({ - type: graphql.list(graphql.nonNull(base.object('Post'))), + recentPosts: g.field({ + type: g.list(g.nonNull(base.object('Post'))), args: { - id: graphql.arg({ type: graphql.nonNull(graphql.ID) }), - seconds: graphql.arg({ type: graphql.nonNull(graphql.Int), defaultValue: 600 }), + id: g.arg({ type: g.nonNull(g.ID) }), + seconds: g.arg({ type: g.nonNull(g.Int), defaultValue: 600 }), }, resolve (source, { id, seconds }, context: Context) { const cutoff = new Date(Date.now() - seconds * 1000) @@ -119,9 +119,9 @@ export const extendGraphqlSchema = graphql.extend(base => { }) }, }), - stats: graphql.field({ + stats: g.field({ type: Statistics, - args: { id: graphql.arg({ type: graphql.nonNull(graphql.ID) }) }, + args: { id: g.arg({ type: g.nonNull(g.ID) }) }, resolve (source, { id }) { return { authorId: id } }, diff --git a/examples/graphql-ts-gql/schema.ts b/examples/graphql-ts-gql/schema.ts index b32fbae7115..94aaa6dadc7 100644 --- a/examples/graphql-ts-gql/schema.ts +++ b/examples/graphql-ts-gql/schema.ts @@ -1,5 +1,5 @@ /* eslint-disable @typescript-eslint/consistent-type-imports */ -import { list, graphql } from '@keystone-6/core' +import { list, g } from '@keystone-6/core' import { select, relationship, text, timestamp, virtual } from '@keystone-6/core/fields' import { allowAll } from '@keystone-6/core/access' import { gql } from '@ts-gql/tag/no-transform' @@ -20,8 +20,8 @@ export const lists = { }), // A virtual field returning a value derived from the item data. isPublished: virtual({ - field: graphql.field({ - type: graphql.Boolean, + field: g.field({ + type: g.Boolean, resolve (item: any) { return item.status === 'published' }, @@ -34,17 +34,17 @@ export const lists = { itemView: { fieldMode: 'hidden' }, listView: { fieldMode: 'hidden' }, }, - field: graphql.field({ - type: graphql.object<{ + field: g.field({ + type: g.object<{ words: number sentences: number paragraphs: number }>()({ name: 'PostCounts', fields: { - words: graphql.field({ type: graphql.Int }), - sentences: graphql.field({ type: graphql.Int }), - paragraphs: graphql.field({ type: graphql.Int }), + words: g.field({ type: g.Int }), + sentences: g.field({ type: g.Int }), + paragraphs: g.field({ type: g.Int }), }, }), resolve (item) { @@ -59,10 +59,10 @@ export const lists = { }), // A virtual field which accepts GraphQL arguments. excerpt: virtual({ - field: graphql.field({ - type: graphql.String, + field: g.field({ + type: g.String, args: { - length: graphql.arg({ type: graphql.nonNull(graphql.Int), defaultValue: 200 }), + length: g.arg({ type: g.nonNull(g.Int), defaultValue: 200 }), }, resolve (item, { length }) { if (!item.content) { @@ -82,8 +82,8 @@ export const lists = { author: relationship({ ref: 'Author.posts', many: false }), // A virtual field which uses `item` and `context` to query data. authorName: virtual({ - field: graphql.field({ - type: graphql.String, + field: g.field({ + type: g.String, async resolve (item, args, context) { const POST_AUTHOR_QUERY = gql` query POST_AUTHOR_QUERY($id: ID!) { @@ -116,7 +116,7 @@ export const lists = { // A virtual field which returns a type derived from a Keystone list. latestPost: virtual({ field: lists => - graphql.field({ + g.field({ type: lists.Post.types.output, async resolve (item, args, context) { const LATEST_POST_QUERY = gql` diff --git a/examples/number-fields/schema.ts b/examples/number-fields/schema.ts index 207845562b4..53bb9da253c 100644 --- a/examples/number-fields/schema.ts +++ b/examples/number-fields/schema.ts @@ -1,4 +1,4 @@ -import { list, graphql } from '@keystone-6/core' +import { list, g } from '@keystone-6/core' import { bigInt, float, @@ -19,8 +19,8 @@ export const lists = { integer: integer(), integerDefaulted: integer({ defaultValue: 789 }), maximum: virtual({ - field: graphql.field({ - type: graphql.Int, + field: g.field({ + type: g.Int, resolve (x) { return Math.max( x.float ?? 0, diff --git a/examples/transactions/schema.ts b/examples/transactions/schema.ts index 17c3b8d477a..35f701fd98f 100644 --- a/examples/transactions/schema.ts +++ b/examples/transactions/schema.ts @@ -1,4 +1,4 @@ -import { graphql, list } from '@keystone-6/core' +import { g, list } from '@keystone-6/core' import { allowAll } from '@keystone-6/core/access' import { text, integer, relationship, timestamp, virtual } from '@keystone-6/core/fields' import { @@ -6,10 +6,10 @@ import { type Lists } from '.keystone/types' -export const extendGraphqlSchema = graphql.extend(base => { +export const extendGraphqlSchema = g.extend(base => { return { mutation: { - submitOrder: graphql.field({ + submitOrder: g.field({ type: base.object('Order'), args: {}, async resolve (source, {}, context: Context) { @@ -84,8 +84,8 @@ export const lists = { value: integer(), available: virtual({ - field: graphql.field({ - type: graphql.Int, + field: g.field({ + type: g.Int, resolve (item, args, context) { return context.db.Item.count({ where: { diff --git a/examples/usecase-relationship-union/schema.ts b/examples/usecase-relationship-union/schema.ts index bd8d60a52b3..c921543038c 100644 --- a/examples/usecase-relationship-union/schema.ts +++ b/examples/usecase-relationship-union/schema.ts @@ -1,4 +1,4 @@ -import { list, group, graphql } from '@keystone-6/core' +import { list, group, g } from '@keystone-6/core' import { allowAll } from '@keystone-6/core/access' import { text, relationship, virtual } from '@keystone-6/core/fields' import type { Lists } from '.keystone/types' @@ -39,8 +39,8 @@ export const lists: Lists = { }, fields: { label: virtual({ - field: graphql.field({ - type: graphql.String, + field: g.field({ + type: g.String, resolve: async (item, _, context) => { const { postId, linkId } = item if (postId) { diff --git a/examples/virtual-field/schema.ts b/examples/virtual-field/schema.ts index 2dbcd848fce..a24f09cb880 100644 --- a/examples/virtual-field/schema.ts +++ b/examples/virtual-field/schema.ts @@ -1,4 +1,4 @@ -import { list, graphql } from '@keystone-6/core' +import { list, g } from '@keystone-6/core' import { text, checkbox, virtual } from '@keystone-6/core/fields' import { allowAll } from '@keystone-6/core/access' @@ -14,8 +14,8 @@ export const lists = { // primitive GraphQL type isActive: virtual({ - field: graphql.field({ - type: graphql.Boolean, + field: g.field({ + type: g.Boolean, resolve (item) { return item.title.length > 3 && item.content.length > 10 && item.listed === true }, @@ -24,17 +24,17 @@ export const lists = { // object GraphQL type counts: virtual({ - field: graphql.field({ - type: graphql.object<{ + field: g.field({ + type: g.object<{ words: number sentences: number paragraphs: number }>()({ name: 'PostCounts', fields: { - words: graphql.field({ type: graphql.Int }), - sentences: graphql.field({ type: graphql.Int }), - paragraphs: graphql.field({ type: graphql.Int }), + words: g.field({ type: g.Int }), + sentences: g.field({ type: g.Int }), + paragraphs: g.field({ type: g.Int }), }, }), resolve (item) { @@ -54,10 +54,10 @@ export const lists = { // accepts GraphQL arguments excerpt: virtual({ - field: graphql.field({ - type: graphql.String, + field: g.field({ + type: g.String, args: { - length: graphql.arg({ type: graphql.nonNull(graphql.Int), defaultValue: 50 }), + length: g.arg({ type: g.nonNull(g.Int), defaultValue: 50 }), }, resolve (item, { length }) { const { content = '' } = item @@ -70,16 +70,16 @@ export const lists = { // using a context related: virtual({ - field: graphql.field({ - type: graphql.list( - graphql.object<{ + field: g.field({ + type: g.list( + g.object<{ id: string title: string }>()({ name: 'RelatedPosts', fields: { - id: graphql.field({ type: graphql.String }), - title: graphql.field({ type: graphql.String }), + id: g.field({ type: g.String }), + title: g.field({ type: g.String }), }, }) ), diff --git a/packages/auth/src/gql/getBaseAuthSchema.ts b/packages/auth/src/gql/getBaseAuthSchema.ts index 0b3ce1a5671..d93181ff668 100644 --- a/packages/auth/src/gql/getBaseAuthSchema.ts +++ b/packages/auth/src/gql/getBaseAuthSchema.ts @@ -2,7 +2,7 @@ import type { BaseItem, KeystoneContext } from '@keystone-6/core/types' -import { graphql } from '@keystone-6/core' +import { g } from '@keystone-6/core' import type { AuthGqlNames, SecretFieldImpl, @@ -26,25 +26,25 @@ export function getBaseAuthSchema ({ secretField: S gqlNames: AuthGqlNames secretFieldImpl: SecretFieldImpl - base: graphql.BaseSchemaMeta + base: g.BaseSchemaMeta }) { - const ItemAuthenticationWithPasswordSuccess = graphql.object<{ + const ItemAuthenticationWithPasswordSuccess = g.object<{ sessionToken: string item: BaseItem }>()({ name: gqlNames.ItemAuthenticationWithPasswordSuccess, fields: { - sessionToken: graphql.field({ type: graphql.nonNull(graphql.String) }), - item: graphql.field({ type: graphql.nonNull(base.object(listKey)) }), + sessionToken: g.field({ type: g.nonNull(g.String) }), + item: g.field({ type: g.nonNull(base.object(listKey)) }), }, }) - const ItemAuthenticationWithPasswordFailure = graphql.object<{ message: string }>()({ + const ItemAuthenticationWithPasswordFailure = g.object<{ message: string }>()({ name: gqlNames.ItemAuthenticationWithPasswordFailure, fields: { - message: graphql.field({ type: graphql.nonNull(graphql.String) }), + message: g.field({ type: g.nonNull(g.String) }), }, }) - const AuthenticationResult = graphql.union({ + const AuthenticationResult = g.union({ name: gqlNames.ItemAuthenticationWithPasswordResult, types: [ItemAuthenticationWithPasswordSuccess, ItemAuthenticationWithPasswordFailure], resolveType (val) { @@ -55,7 +55,7 @@ export function getBaseAuthSchema ({ const extension = { query: { - authenticatedItem: graphql.field({ + authenticatedItem: g.field({ type: base.object(listKey), resolve (root, args, context: KeystoneContext) { const { session } = context @@ -70,18 +70,18 @@ export function getBaseAuthSchema ({ }), }, mutation: { - endSession: graphql.field({ - type: graphql.nonNull(graphql.Boolean), + endSession: g.field({ + type: g.nonNull(g.Boolean), async resolve (rootVal, args, context) { await context.sessionStrategy?.end({ context }) return true }, }), - [gqlNames.authenticateItemWithPassword]: graphql.field({ + [gqlNames.authenticateItemWithPassword]: g.field({ type: AuthenticationResult, args: { - [identityField]: graphql.arg({ type: graphql.nonNull(graphql.String) }), - [secretField]: graphql.arg({ type: graphql.nonNull(graphql.String) }), + [identityField]: g.arg({ type: g.nonNull(g.String) }), + [secretField]: g.arg({ type: g.nonNull(g.String) }), }, async resolve (root, { [identityField]: identity, diff --git a/packages/auth/src/gql/getInitFirstItemSchema.ts b/packages/auth/src/gql/getInitFirstItemSchema.ts index 8f037cc8f75..a0c0542461f 100644 --- a/packages/auth/src/gql/getInitFirstItemSchema.ts +++ b/packages/auth/src/gql/getInitFirstItemSchema.ts @@ -1,8 +1,8 @@ -import { - type BaseItem, - type KeystoneContext, +import type { + BaseItem, + KeystoneContext } from '@keystone-6/core/types' -import { graphql } from '@keystone-6/core' +import { g } from '@keystone-6/core' import { assertInputObjectType, GraphQLInputObjectType, type GraphQLSchema } from 'graphql' import { type AuthGqlNames, @@ -24,17 +24,17 @@ export function getInitFirstItemSchema ({ defaultItemData: InitFirstItemConfig['itemData'] gqlNames: AuthGqlNames graphQLSchema: GraphQLSchema - ItemAuthenticationWithPasswordSuccess: graphql.ObjectType<{ + ItemAuthenticationWithPasswordSuccess: g.ObjectType<{ item: BaseItem sessionToken: string }> // TODO: return type required by pnpm :( -}): graphql.Extension { +}): g.Extension { const createInputConfig = assertInputObjectType( graphQLSchema.getType(`${listKey}CreateInput`) ).toConfig() const fieldsSet = new Set(fields) - const initialCreateInput = graphql.wrap.inputObject( + const initialCreateInput = g.wrap.inputObject( new GraphQLInputObjectType({ ...createInputConfig, fields: Object.fromEntries(Object.entries(createInputConfig.fields).filter(([fieldKey]) => fieldsSet.has(fieldKey))), @@ -44,9 +44,9 @@ export function getInitFirstItemSchema ({ return { mutation: { - [gqlNames.createInitialItem]: graphql.field({ - type: graphql.nonNull(ItemAuthenticationWithPasswordSuccess), - args: { data: graphql.arg({ type: graphql.nonNull(initialCreateInput) }) }, + [gqlNames.createInitialItem]: g.field({ + type: g.nonNull(ItemAuthenticationWithPasswordSuccess), + args: { data: g.arg({ type: g.nonNull(initialCreateInput) }) }, async resolve (rootVal, { data }, context: KeystoneContext) { if (!context.sessionStrategy) throw new Error('No session strategy on context') diff --git a/packages/auth/src/schema.ts b/packages/auth/src/schema.ts index 4ddf3e74d1d..c4026d93162 100644 --- a/packages/auth/src/schema.ts +++ b/packages/auth/src/schema.ts @@ -7,9 +7,9 @@ import { parse, validate, } from 'graphql' -import { graphql } from '@keystone-6/core' -import { getGqlNames } from '@keystone-6/core/types' +import { g } from '@keystone-6/core' +import { getGqlNames } from '@keystone-6/core/types' import type { AuthGqlNames, AuthTokenTypeConfig, @@ -60,7 +60,7 @@ export const getSchemaExtension = ({ magicAuthLink?: AuthTokenTypeConfig sessionData: string }) => - graphql.extend(base => { + g.extend(base => { const uniqueWhereInputType = assertInputObjectType(base.schema.getType(`${listKey}WhereUniqueInput`)) const identityFieldOnUniqueWhere = uniqueWhereInputType.getFields()[identityField] if ( diff --git a/packages/cloudinary/src/index.ts b/packages/cloudinary/src/index.ts index f8c50dea2e6..e625e796d72 100644 --- a/packages/cloudinary/src/index.ts +++ b/packages/cloudinary/src/index.ts @@ -1,7 +1,7 @@ import { randomBytes } from 'node:crypto' import type { CommonFieldConfig, BaseListTypeInfo, FieldTypeFunc } from '@keystone-6/core/types' import { jsonFieldTypePolyfilledForSQLite } from '@keystone-6/core/types' -import { graphql } from '@keystone-6/core' +import { g } from '@keystone-6/core' import type Cloudinary from 'cloudinary' import { v2 as cloudinary } from 'cloudinary' @@ -25,44 +25,44 @@ type CloudinaryImageFieldConfig = db?: { map?: string } } -const CloudinaryImageFormat = graphql.inputObject({ +const CloudinaryImageFormat = g.inputObject({ name: 'CloudinaryImageFormat', description: 'Mirrors the formatting options [Cloudinary provides](https://cloudinary.com/documentation/image_transformation_reference).\n' + 'All options are strings as they ultimately end up in a URL.', fields: { - prettyName: graphql.arg({ + prettyName: g.arg({ description: ' Rewrites the filename to be this pretty string. Do not include `/` or `.`', - type: graphql.String, + type: g.String, }), - width: graphql.arg({ type: graphql.String }), - height: graphql.arg({ type: graphql.String }), - crop: graphql.arg({ type: graphql.String }), - aspect_ratio: graphql.arg({ type: graphql.String }), - gravity: graphql.arg({ type: graphql.String }), - zoom: graphql.arg({ type: graphql.String }), - x: graphql.arg({ type: graphql.String }), - y: graphql.arg({ type: graphql.String }), - format: graphql.arg({ type: graphql.String }), - fetch_format: graphql.arg({ type: graphql.String }), - quality: graphql.arg({ type: graphql.String }), - radius: graphql.arg({ type: graphql.String }), - angle: graphql.arg({ type: graphql.String }), - effect: graphql.arg({ type: graphql.String }), - opacity: graphql.arg({ type: graphql.String }), - border: graphql.arg({ type: graphql.String }), - background: graphql.arg({ type: graphql.String }), - overlay: graphql.arg({ type: graphql.String }), - underlay: graphql.arg({ type: graphql.String }), - default_image: graphql.arg({ type: graphql.String }), - delay: graphql.arg({ type: graphql.String }), - color: graphql.arg({ type: graphql.String }), - color_space: graphql.arg({ type: graphql.String }), - dpr: graphql.arg({ type: graphql.String }), - page: graphql.arg({ type: graphql.String }), - density: graphql.arg({ type: graphql.String }), - flags: graphql.arg({ type: graphql.String }), - transformation: graphql.arg({ type: graphql.String }), + width: g.arg({ type: g.String }), + height: g.arg({ type: g.String }), + crop: g.arg({ type: g.String }), + aspect_ratio: g.arg({ type: g.String }), + gravity: g.arg({ type: g.String }), + zoom: g.arg({ type: g.String }), + x: g.arg({ type: g.String }), + y: g.arg({ type: g.String }), + format: g.arg({ type: g.String }), + fetch_format: g.arg({ type: g.String }), + quality: g.arg({ type: g.String }), + radius: g.arg({ type: g.String }), + angle: g.arg({ type: g.String }), + effect: g.arg({ type: g.String }), + opacity: g.arg({ type: g.String }), + border: g.arg({ type: g.String }), + background: g.arg({ type: g.String }), + overlay: g.arg({ type: g.String }), + underlay: g.arg({ type: g.String }), + default_image: g.arg({ type: g.String }), + delay: g.arg({ type: g.String }), + color: g.arg({ type: g.String }), + color_space: g.arg({ type: g.String }), + dpr: g.arg({ type: g.String }), + page: g.arg({ type: g.String }), + density: g.arg({ type: g.String }), + flags: g.arg({ type: g.String }), + transformation: g.arg({ type: g.String }), }, }) @@ -74,7 +74,7 @@ type CloudinaryImage_File = { encoding: string publicUrl: string publicUrlTransformed: (args: { - transformation: graphql.InferValueFromArg> + transformation: g.InferValueFromArg> }) => string filesize: number width: number @@ -82,28 +82,28 @@ type CloudinaryImage_File = { } // WARNING: should mimic keystone-6/core native images -const outputType = graphql.object()({ +const outputType = g.object()({ name: 'CloudinaryImage_File', fields: { - id: graphql.field({ type: graphql.nonNull(graphql.ID) }), + id: g.field({ type: g.nonNull(g.ID) }), // path: types.field({ type: types.String }), - filename: graphql.field({ type: graphql.String }), - originalFilename: graphql.field({ type: graphql.String }), - mimetype: graphql.field({ type: graphql.String }), - encoding: graphql.field({ type: graphql.String }), - publicUrl: graphql.field({ type: graphql.String }), - publicUrlTransformed: graphql.field({ + filename: g.field({ type: g.String }), + originalFilename: g.field({ type: g.String }), + mimetype: g.field({ type: g.String }), + encoding: g.field({ type: g.String }), + publicUrl: g.field({ type: g.String }), + publicUrlTransformed: g.field({ args: { - transformation: graphql.arg({ type: CloudinaryImageFormat }), + transformation: g.arg({ type: CloudinaryImageFormat }), }, - type: graphql.String, + type: g.String, resolve (data, args) { return data.publicUrlTransformed(args) }, }), - filesize: graphql.field({ type: graphql.nonNull(graphql.Int) }), - width: graphql.field({ type: graphql.nonNull(graphql.Int) }), - height: graphql.field({ type: graphql.nonNull(graphql.Int) }), + filesize: g.field({ type: g.nonNull(g.Int) }), + width: g.field({ type: g.nonNull(g.Int) }), + height: g.field({ type: g.nonNull(g.Int) }), }, }) @@ -117,9 +117,9 @@ export function cloudinaryImage ({ throw Error("isIndexed: 'unique' is not a supported option for field type cloudinaryImage") } - const inputArg = graphql.arg({ type: graphql.Upload }) + const inputArg = g.arg({ type: g.Upload }) async function resolveInput ( - uploadData: graphql.InferValueFromArg + uploadData: g.InferValueFromArg ): Promise { if (uploadData === null) return null if (uploadData === undefined) return @@ -168,7 +168,7 @@ export function cloudinaryImage ({ create: { arg: inputArg, resolve: resolveInput }, update: { arg: inputArg, resolve: resolveInput }, }, - output: graphql.field({ + output: g.field({ type: outputType, resolve ({ value }) { if (value === null) return null @@ -181,8 +181,8 @@ export function cloudinaryImage ({ publicUrlTransformed: ({ transformation, }: { - transformation: graphql.InferValueFromArg< - graphql.Arg + transformation: g.InferValueFromArg< + g.Arg > }) => { if (!val._meta) return null diff --git a/packages/core/src/fields/filters/enum-filter.ts b/packages/core/src/fields/filters/enum-filter.ts index 090d705a5f8..804add5a1ff 100644 --- a/packages/core/src/fields/filters/enum-filter.ts +++ b/packages/core/src/fields/filters/enum-filter.ts @@ -1,71 +1,71 @@ -import { graphql } from '../../types/schema' +import { g } from '../../types/schema' // yes, these two types have the fields but they're semantically different types // (even though, yes, having EnumFilter by defined as EnumNullableFilter, would be the same type but names would show up differently in editors for example) -export type EnumNullableFilter> = graphql.InputObjectType<{ +export type EnumNullableFilter> = g.InputObjectType<{ // can be null - equals: graphql.Arg + equals: g.Arg // can be null - in: graphql.Arg>> + in: g.Arg>> // can be null - notIn: graphql.Arg>> + notIn: g.Arg>> // can be null - not: graphql.Arg> + not: g.Arg> }> -export type EnumFilter> = graphql.InputObjectType<{ - equals: graphql.Arg - in: graphql.Arg>> - notIn: graphql.Arg>> - not: graphql.Arg> +export type EnumFilter> = g.InputObjectType<{ + equals: g.Arg + in: g.Arg>> + notIn: g.Arg>> + not: g.Arg> }> -type EnumNullableListFilterType> = graphql.InputObjectType<{ +type EnumNullableListFilterType> = g.InputObjectType<{ // can be null - equals: graphql.Arg>> + equals: g.Arg>> // can be null - has: graphql.Arg - hasEvery: graphql.Arg>> - hasSome: graphql.Arg>> - isEmpty: graphql.Arg + has: g.Arg + hasEvery: g.Arg>> + hasSome: g.Arg>> + isEmpty: g.Arg }> -export function enumFilters> ( +export function enumFilters> ( enumType: Enum ): { optional: EnumNullableFilter required: EnumFilter many: EnumNullableListFilterType } { - const optional: EnumNullableFilter = graphql.inputObject({ + const optional: EnumNullableFilter = g.inputObject({ name: `${enumType.graphQLType.name}NullableFilter`, fields: () => ({ - equals: graphql.arg({ type: enumType }), - in: graphql.arg({ type: graphql.list(graphql.nonNull(enumType)) }), - notIn: graphql.arg({ type: graphql.list(graphql.nonNull(enumType)) }), - not: graphql.arg({ type: optional }), + equals: g.arg({ type: enumType }), + in: g.arg({ type: g.list(g.nonNull(enumType)) }), + notIn: g.arg({ type: g.list(g.nonNull(enumType)) }), + not: g.arg({ type: optional }), }), }) - const required: EnumFilter = graphql.inputObject({ + const required: EnumFilter = g.inputObject({ name: `${enumType.graphQLType.name}Filter`, fields: () => ({ - equals: graphql.arg({ type: enumType }), - in: graphql.arg({ type: graphql.list(graphql.nonNull(enumType)) }), - notIn: graphql.arg({ type: graphql.list(graphql.nonNull(enumType)) }), - not: graphql.arg({ type: optional }), + equals: g.arg({ type: enumType }), + in: g.arg({ type: g.list(g.nonNull(enumType)) }), + notIn: g.arg({ type: g.list(g.nonNull(enumType)) }), + not: g.arg({ type: optional }), }), }) - const many: EnumNullableListFilterType = graphql.inputObject({ + const many: EnumNullableListFilterType = g.inputObject({ name: `${enumType.graphQLType.name}NullableListFilter`, fields: () => ({ // can be null - equals: graphql.arg({ type: graphql.list(graphql.nonNull(enumType)) }), + equals: g.arg({ type: g.list(g.nonNull(enumType)) }), // can be null - has: graphql.arg({ type: enumType }), - hasEvery: graphql.arg({ type: graphql.list(graphql.nonNull(enumType)) }), - hasSome: graphql.arg({ type: graphql.list(graphql.nonNull(enumType)) }), - isEmpty: graphql.arg({ type: enumType }), + has: g.arg({ type: enumType }), + hasEvery: g.arg({ type: g.list(g.nonNull(enumType)) }), + hasSome: g.arg({ type: g.list(g.nonNull(enumType)) }), + isEmpty: g.arg({ type: enumType }), }), }) return { diff --git a/packages/core/src/fields/filters/providers/mysql.ts b/packages/core/src/fields/filters/providers/mysql.ts index 762a74e278c..0a59d960fed 100644 --- a/packages/core/src/fields/filters/providers/mysql.ts +++ b/packages/core/src/fields/filters/providers/mysql.ts @@ -1,404 +1,404 @@ // Do not manually modify this file, it is automatically generated by the package at /prisma-utils in this repo. -import { graphql } from '../../../types/schema' - -type StringNullableFilterType = graphql.InputObjectType<{ - equals: graphql.Arg // can be null - in: graphql.Arg>> // can be null - notIn: graphql.Arg>> // can be null - lt: graphql.Arg - lte: graphql.Arg - gt: graphql.Arg - gte: graphql.Arg - contains: graphql.Arg - startsWith: graphql.Arg - endsWith: graphql.Arg - not: graphql.Arg // can be null +import { g } from '../../../types/schema' + +type StringNullableFilterType = g.InputObjectType<{ + equals: g.Arg // can be null + in: g.Arg>> // can be null + notIn: g.Arg>> // can be null + lt: g.Arg + lte: g.Arg + gt: g.Arg + gte: g.Arg + contains: g.Arg + startsWith: g.Arg + endsWith: g.Arg + not: g.Arg // can be null }> -const StringNullableFilter: StringNullableFilterType = graphql.inputObject({ +const StringNullableFilter: StringNullableFilterType = g.inputObject({ name: 'StringNullableFilter', fields: () => ({ - equals: graphql.arg({ type: graphql.String }), // can be null - in: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.String)) }), // can be null - notIn: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.String)) }), // can be null - lt: graphql.arg({ type: graphql.String }), - lte: graphql.arg({ type: graphql.String }), - gt: graphql.arg({ type: graphql.String }), - gte: graphql.arg({ type: graphql.String }), - contains: graphql.arg({ type: graphql.String }), - startsWith: graphql.arg({ type: graphql.String }), - endsWith: graphql.arg({ type: graphql.String }), - not: graphql.arg({ type: StringNullableFilter }), // can be null + equals: g.arg({ type: g.String }), // can be null + in: g.arg({ type: g.list(g.nonNull(g.String)) }), // can be null + notIn: g.arg({ type: g.list(g.nonNull(g.String)) }), // can be null + lt: g.arg({ type: g.String }), + lte: g.arg({ type: g.String }), + gt: g.arg({ type: g.String }), + gte: g.arg({ type: g.String }), + contains: g.arg({ type: g.String }), + startsWith: g.arg({ type: g.String }), + endsWith: g.arg({ type: g.String }), + not: g.arg({ type: StringNullableFilter }), // can be null }), }) -type StringFilterType = graphql.InputObjectType<{ - equals: graphql.Arg - in: graphql.Arg>> - notIn: graphql.Arg>> - lt: graphql.Arg - lte: graphql.Arg - gt: graphql.Arg - gte: graphql.Arg - contains: graphql.Arg - startsWith: graphql.Arg - endsWith: graphql.Arg - not: graphql.Arg +type StringFilterType = g.InputObjectType<{ + equals: g.Arg + in: g.Arg>> + notIn: g.Arg>> + lt: g.Arg + lte: g.Arg + gt: g.Arg + gte: g.Arg + contains: g.Arg + startsWith: g.Arg + endsWith: g.Arg + not: g.Arg }> -const StringFilter: StringFilterType = graphql.inputObject({ +const StringFilter: StringFilterType = g.inputObject({ name: 'StringFilter', fields: () => ({ - equals: graphql.arg({ type: graphql.String }), - in: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.String)) }), - notIn: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.String)) }), - lt: graphql.arg({ type: graphql.String }), - lte: graphql.arg({ type: graphql.String }), - gt: graphql.arg({ type: graphql.String }), - gte: graphql.arg({ type: graphql.String }), - contains: graphql.arg({ type: graphql.String }), - startsWith: graphql.arg({ type: graphql.String }), - endsWith: graphql.arg({ type: graphql.String }), - not: graphql.arg({ type: NestedStringFilter }), + equals: g.arg({ type: g.String }), + in: g.arg({ type: g.list(g.nonNull(g.String)) }), + notIn: g.arg({ type: g.list(g.nonNull(g.String)) }), + lt: g.arg({ type: g.String }), + lte: g.arg({ type: g.String }), + gt: g.arg({ type: g.String }), + gte: g.arg({ type: g.String }), + contains: g.arg({ type: g.String }), + startsWith: g.arg({ type: g.String }), + endsWith: g.arg({ type: g.String }), + not: g.arg({ type: NestedStringFilter }), }), }) -type NestedStringNullableFilterType = graphql.InputObjectType<{ - equals: graphql.Arg // can be null - in: graphql.Arg>> // can be null - notIn: graphql.Arg>> // can be null - lt: graphql.Arg - lte: graphql.Arg - gt: graphql.Arg - gte: graphql.Arg - contains: graphql.Arg - startsWith: graphql.Arg - endsWith: graphql.Arg - not: graphql.Arg // can be null +type NestedStringNullableFilterType = g.InputObjectType<{ + equals: g.Arg // can be null + in: g.Arg>> // can be null + notIn: g.Arg>> // can be null + lt: g.Arg + lte: g.Arg + gt: g.Arg + gte: g.Arg + contains: g.Arg + startsWith: g.Arg + endsWith: g.Arg + not: g.Arg // can be null }> -const NestedStringNullableFilter: NestedStringNullableFilterType = graphql.inputObject({ +const NestedStringNullableFilter: NestedStringNullableFilterType = g.inputObject({ name: 'NestedStringNullableFilter', fields: () => ({ - equals: graphql.arg({ type: graphql.String }), // can be null - in: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.String)) }), // can be null - notIn: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.String)) }), // can be null - lt: graphql.arg({ type: graphql.String }), - lte: graphql.arg({ type: graphql.String }), - gt: graphql.arg({ type: graphql.String }), - gte: graphql.arg({ type: graphql.String }), - contains: graphql.arg({ type: graphql.String }), - startsWith: graphql.arg({ type: graphql.String }), - endsWith: graphql.arg({ type: graphql.String }), - not: graphql.arg({ type: NestedStringNullableFilter }), // can be null + equals: g.arg({ type: g.String }), // can be null + in: g.arg({ type: g.list(g.nonNull(g.String)) }), // can be null + notIn: g.arg({ type: g.list(g.nonNull(g.String)) }), // can be null + lt: g.arg({ type: g.String }), + lte: g.arg({ type: g.String }), + gt: g.arg({ type: g.String }), + gte: g.arg({ type: g.String }), + contains: g.arg({ type: g.String }), + startsWith: g.arg({ type: g.String }), + endsWith: g.arg({ type: g.String }), + not: g.arg({ type: NestedStringNullableFilter }), // can be null }), }) -type NestedStringFilterType = graphql.InputObjectType<{ - equals: graphql.Arg - in: graphql.Arg>> - notIn: graphql.Arg>> - lt: graphql.Arg - lte: graphql.Arg - gt: graphql.Arg - gte: graphql.Arg - contains: graphql.Arg - startsWith: graphql.Arg - endsWith: graphql.Arg - not: graphql.Arg +type NestedStringFilterType = g.InputObjectType<{ + equals: g.Arg + in: g.Arg>> + notIn: g.Arg>> + lt: g.Arg + lte: g.Arg + gt: g.Arg + gte: g.Arg + contains: g.Arg + startsWith: g.Arg + endsWith: g.Arg + not: g.Arg }> -const NestedStringFilter: NestedStringFilterType = graphql.inputObject({ +const NestedStringFilter: NestedStringFilterType = g.inputObject({ name: 'NestedStringFilter', fields: () => ({ - equals: graphql.arg({ type: graphql.String }), - in: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.String)) }), - notIn: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.String)) }), - lt: graphql.arg({ type: graphql.String }), - lte: graphql.arg({ type: graphql.String }), - gt: graphql.arg({ type: graphql.String }), - gte: graphql.arg({ type: graphql.String }), - contains: graphql.arg({ type: graphql.String }), - startsWith: graphql.arg({ type: graphql.String }), - endsWith: graphql.arg({ type: graphql.String }), - not: graphql.arg({ type: NestedStringFilter }), + equals: g.arg({ type: g.String }), + in: g.arg({ type: g.list(g.nonNull(g.String)) }), + notIn: g.arg({ type: g.list(g.nonNull(g.String)) }), + lt: g.arg({ type: g.String }), + lte: g.arg({ type: g.String }), + gt: g.arg({ type: g.String }), + gte: g.arg({ type: g.String }), + contains: g.arg({ type: g.String }), + startsWith: g.arg({ type: g.String }), + endsWith: g.arg({ type: g.String }), + not: g.arg({ type: NestedStringFilter }), }), }) -type BooleanNullableFilterType = graphql.InputObjectType<{ - equals: graphql.Arg // can be null - not: graphql.Arg // can be null +type BooleanNullableFilterType = g.InputObjectType<{ + equals: g.Arg // can be null + not: g.Arg // can be null }> -const BooleanNullableFilter: BooleanNullableFilterType = graphql.inputObject({ +const BooleanNullableFilter: BooleanNullableFilterType = g.inputObject({ name: 'BooleanNullableFilter', fields: () => ({ - equals: graphql.arg({ type: graphql.Boolean }), // can be null - not: graphql.arg({ type: BooleanNullableFilter }), // can be null + equals: g.arg({ type: g.Boolean }), // can be null + not: g.arg({ type: BooleanNullableFilter }), // can be null }), }) -type BooleanFilterType = graphql.InputObjectType<{ - equals: graphql.Arg - not: graphql.Arg +type BooleanFilterType = g.InputObjectType<{ + equals: g.Arg + not: g.Arg }> -const BooleanFilter: BooleanFilterType = graphql.inputObject({ +const BooleanFilter: BooleanFilterType = g.inputObject({ name: 'BooleanFilter', fields: () => ({ - equals: graphql.arg({ type: graphql.Boolean }), - not: graphql.arg({ type: BooleanFilter }), + equals: g.arg({ type: g.Boolean }), + not: g.arg({ type: BooleanFilter }), }), }) -type IntFilterType = graphql.InputObjectType<{ - equals: graphql.Arg - in: graphql.Arg>> - notIn: graphql.Arg>> - lt: graphql.Arg - lte: graphql.Arg - gt: graphql.Arg - gte: graphql.Arg - not: graphql.Arg +type IntFilterType = g.InputObjectType<{ + equals: g.Arg + in: g.Arg>> + notIn: g.Arg>> + lt: g.Arg + lte: g.Arg + gt: g.Arg + gte: g.Arg + not: g.Arg }> -const IntFilter: IntFilterType = graphql.inputObject({ +const IntFilter: IntFilterType = g.inputObject({ name: 'IntFilter', fields: () => ({ - equals: graphql.arg({ type: graphql.Int }), - in: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.Int)) }), - notIn: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.Int)) }), - lt: graphql.arg({ type: graphql.Int }), - lte: graphql.arg({ type: graphql.Int }), - gt: graphql.arg({ type: graphql.Int }), - gte: graphql.arg({ type: graphql.Int }), - not: graphql.arg({ type: IntFilter }), + equals: g.arg({ type: g.Int }), + in: g.arg({ type: g.list(g.nonNull(g.Int)) }), + notIn: g.arg({ type: g.list(g.nonNull(g.Int)) }), + lt: g.arg({ type: g.Int }), + lte: g.arg({ type: g.Int }), + gt: g.arg({ type: g.Int }), + gte: g.arg({ type: g.Int }), + not: g.arg({ type: IntFilter }), }), }) -type IntNullableFilterType = graphql.InputObjectType<{ - equals: graphql.Arg // can be null - in: graphql.Arg>> // can be null - notIn: graphql.Arg>> // can be null - lt: graphql.Arg - lte: graphql.Arg - gt: graphql.Arg - gte: graphql.Arg - not: graphql.Arg // can be null +type IntNullableFilterType = g.InputObjectType<{ + equals: g.Arg // can be null + in: g.Arg>> // can be null + notIn: g.Arg>> // can be null + lt: g.Arg + lte: g.Arg + gt: g.Arg + gte: g.Arg + not: g.Arg // can be null }> -const IntNullableFilter: IntNullableFilterType = graphql.inputObject({ +const IntNullableFilter: IntNullableFilterType = g.inputObject({ name: 'IntNullableFilter', fields: () => ({ - equals: graphql.arg({ type: graphql.Int }), // can be null - in: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.Int)) }), // can be null - notIn: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.Int)) }), // can be null - lt: graphql.arg({ type: graphql.Int }), - lte: graphql.arg({ type: graphql.Int }), - gt: graphql.arg({ type: graphql.Int }), - gte: graphql.arg({ type: graphql.Int }), - not: graphql.arg({ type: IntNullableFilter }), // can be null + equals: g.arg({ type: g.Int }), // can be null + in: g.arg({ type: g.list(g.nonNull(g.Int)) }), // can be null + notIn: g.arg({ type: g.list(g.nonNull(g.Int)) }), // can be null + lt: g.arg({ type: g.Int }), + lte: g.arg({ type: g.Int }), + gt: g.arg({ type: g.Int }), + gte: g.arg({ type: g.Int }), + not: g.arg({ type: IntNullableFilter }), // can be null }), }) -type FloatNullableFilterType = graphql.InputObjectType<{ - equals: graphql.Arg // can be null - in: graphql.Arg>> // can be null - notIn: graphql.Arg>> // can be null - lt: graphql.Arg - lte: graphql.Arg - gt: graphql.Arg - gte: graphql.Arg - not: graphql.Arg // can be null +type FloatNullableFilterType = g.InputObjectType<{ + equals: g.Arg // can be null + in: g.Arg>> // can be null + notIn: g.Arg>> // can be null + lt: g.Arg + lte: g.Arg + gt: g.Arg + gte: g.Arg + not: g.Arg // can be null }> -const FloatNullableFilter: FloatNullableFilterType = graphql.inputObject({ +const FloatNullableFilter: FloatNullableFilterType = g.inputObject({ name: 'FloatNullableFilter', fields: () => ({ - equals: graphql.arg({ type: graphql.Float }), // can be null - in: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.Float)) }), // can be null - notIn: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.Float)) }), // can be null - lt: graphql.arg({ type: graphql.Float }), - lte: graphql.arg({ type: graphql.Float }), - gt: graphql.arg({ type: graphql.Float }), - gte: graphql.arg({ type: graphql.Float }), - not: graphql.arg({ type: FloatNullableFilter }), // can be null + equals: g.arg({ type: g.Float }), // can be null + in: g.arg({ type: g.list(g.nonNull(g.Float)) }), // can be null + notIn: g.arg({ type: g.list(g.nonNull(g.Float)) }), // can be null + lt: g.arg({ type: g.Float }), + lte: g.arg({ type: g.Float }), + gt: g.arg({ type: g.Float }), + gte: g.arg({ type: g.Float }), + not: g.arg({ type: FloatNullableFilter }), // can be null }), }) -type FloatFilterType = graphql.InputObjectType<{ - equals: graphql.Arg - in: graphql.Arg>> - notIn: graphql.Arg>> - lt: graphql.Arg - lte: graphql.Arg - gt: graphql.Arg - gte: graphql.Arg - not: graphql.Arg +type FloatFilterType = g.InputObjectType<{ + equals: g.Arg + in: g.Arg>> + notIn: g.Arg>> + lt: g.Arg + lte: g.Arg + gt: g.Arg + gte: g.Arg + not: g.Arg }> -const FloatFilter: FloatFilterType = graphql.inputObject({ +const FloatFilter: FloatFilterType = g.inputObject({ name: 'FloatFilter', fields: () => ({ - equals: graphql.arg({ type: graphql.Float }), - in: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.Float)) }), - notIn: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.Float)) }), - lt: graphql.arg({ type: graphql.Float }), - lte: graphql.arg({ type: graphql.Float }), - gt: graphql.arg({ type: graphql.Float }), - gte: graphql.arg({ type: graphql.Float }), - not: graphql.arg({ type: FloatFilter }), + equals: g.arg({ type: g.Float }), + in: g.arg({ type: g.list(g.nonNull(g.Float)) }), + notIn: g.arg({ type: g.list(g.nonNull(g.Float)) }), + lt: g.arg({ type: g.Float }), + lte: g.arg({ type: g.Float }), + gt: g.arg({ type: g.Float }), + gte: g.arg({ type: g.Float }), + not: g.arg({ type: FloatFilter }), }), }) -type DateTimeNullableFilterType = graphql.InputObjectType<{ - equals: graphql.Arg // can be null - in: graphql.Arg>> // can be null - notIn: graphql.Arg>> // can be null - lt: graphql.Arg - lte: graphql.Arg - gt: graphql.Arg - gte: graphql.Arg - not: graphql.Arg // can be null +type DateTimeNullableFilterType = g.InputObjectType<{ + equals: g.Arg // can be null + in: g.Arg>> // can be null + notIn: g.Arg>> // can be null + lt: g.Arg + lte: g.Arg + gt: g.Arg + gte: g.Arg + not: g.Arg // can be null }> -const DateTimeNullableFilter: DateTimeNullableFilterType = graphql.inputObject({ +const DateTimeNullableFilter: DateTimeNullableFilterType = g.inputObject({ name: 'DateTimeNullableFilter', fields: () => ({ - equals: graphql.arg({ type: graphql.DateTime }), // can be null - in: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.DateTime)) }), // can be null - notIn: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.DateTime)) }), // can be null - lt: graphql.arg({ type: graphql.DateTime }), - lte: graphql.arg({ type: graphql.DateTime }), - gt: graphql.arg({ type: graphql.DateTime }), - gte: graphql.arg({ type: graphql.DateTime }), - not: graphql.arg({ type: DateTimeNullableFilter }), // can be null + equals: g.arg({ type: g.DateTime }), // can be null + in: g.arg({ type: g.list(g.nonNull(g.DateTime)) }), // can be null + notIn: g.arg({ type: g.list(g.nonNull(g.DateTime)) }), // can be null + lt: g.arg({ type: g.DateTime }), + lte: g.arg({ type: g.DateTime }), + gt: g.arg({ type: g.DateTime }), + gte: g.arg({ type: g.DateTime }), + not: g.arg({ type: DateTimeNullableFilter }), // can be null }), }) -type DateTimeFilterType = graphql.InputObjectType<{ - equals: graphql.Arg - in: graphql.Arg>> - notIn: graphql.Arg>> - lt: graphql.Arg - lte: graphql.Arg - gt: graphql.Arg - gte: graphql.Arg - not: graphql.Arg +type DateTimeFilterType = g.InputObjectType<{ + equals: g.Arg + in: g.Arg>> + notIn: g.Arg>> + lt: g.Arg + lte: g.Arg + gt: g.Arg + gte: g.Arg + not: g.Arg }> -const DateTimeFilter: DateTimeFilterType = graphql.inputObject({ +const DateTimeFilter: DateTimeFilterType = g.inputObject({ name: 'DateTimeFilter', fields: () => ({ - equals: graphql.arg({ type: graphql.DateTime }), - in: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.DateTime)) }), - notIn: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.DateTime)) }), - lt: graphql.arg({ type: graphql.DateTime }), - lte: graphql.arg({ type: graphql.DateTime }), - gt: graphql.arg({ type: graphql.DateTime }), - gte: graphql.arg({ type: graphql.DateTime }), - not: graphql.arg({ type: DateTimeFilter }), + equals: g.arg({ type: g.DateTime }), + in: g.arg({ type: g.list(g.nonNull(g.DateTime)) }), + notIn: g.arg({ type: g.list(g.nonNull(g.DateTime)) }), + lt: g.arg({ type: g.DateTime }), + lte: g.arg({ type: g.DateTime }), + gt: g.arg({ type: g.DateTime }), + gte: g.arg({ type: g.DateTime }), + not: g.arg({ type: DateTimeFilter }), }), }) -type DecimalNullableFilterType = graphql.InputObjectType<{ - equals: graphql.Arg // can be null - in: graphql.Arg>> // can be null - notIn: graphql.Arg>> // can be null - lt: graphql.Arg - lte: graphql.Arg - gt: graphql.Arg - gte: graphql.Arg - not: graphql.Arg // can be null +type DecimalNullableFilterType = g.InputObjectType<{ + equals: g.Arg // can be null + in: g.Arg>> // can be null + notIn: g.Arg>> // can be null + lt: g.Arg + lte: g.Arg + gt: g.Arg + gte: g.Arg + not: g.Arg // can be null }> -const DecimalNullableFilter: DecimalNullableFilterType = graphql.inputObject({ +const DecimalNullableFilter: DecimalNullableFilterType = g.inputObject({ name: 'DecimalNullableFilter', fields: () => ({ - equals: graphql.arg({ type: graphql.Decimal }), // can be null - in: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.Decimal)) }), // can be null - notIn: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.Decimal)) }), // can be null - lt: graphql.arg({ type: graphql.Decimal }), - lte: graphql.arg({ type: graphql.Decimal }), - gt: graphql.arg({ type: graphql.Decimal }), - gte: graphql.arg({ type: graphql.Decimal }), - not: graphql.arg({ type: DecimalNullableFilter }), // can be null + equals: g.arg({ type: g.Decimal }), // can be null + in: g.arg({ type: g.list(g.nonNull(g.Decimal)) }), // can be null + notIn: g.arg({ type: g.list(g.nonNull(g.Decimal)) }), // can be null + lt: g.arg({ type: g.Decimal }), + lte: g.arg({ type: g.Decimal }), + gt: g.arg({ type: g.Decimal }), + gte: g.arg({ type: g.Decimal }), + not: g.arg({ type: DecimalNullableFilter }), // can be null }), }) -type DecimalFilterType = graphql.InputObjectType<{ - equals: graphql.Arg - in: graphql.Arg>> - notIn: graphql.Arg>> - lt: graphql.Arg - lte: graphql.Arg - gt: graphql.Arg - gte: graphql.Arg - not: graphql.Arg +type DecimalFilterType = g.InputObjectType<{ + equals: g.Arg + in: g.Arg>> + notIn: g.Arg>> + lt: g.Arg + lte: g.Arg + gt: g.Arg + gte: g.Arg + not: g.Arg }> -const DecimalFilter: DecimalFilterType = graphql.inputObject({ +const DecimalFilter: DecimalFilterType = g.inputObject({ name: 'DecimalFilter', fields: () => ({ - equals: graphql.arg({ type: graphql.Decimal }), - in: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.Decimal)) }), - notIn: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.Decimal)) }), - lt: graphql.arg({ type: graphql.Decimal }), - lte: graphql.arg({ type: graphql.Decimal }), - gt: graphql.arg({ type: graphql.Decimal }), - gte: graphql.arg({ type: graphql.Decimal }), - not: graphql.arg({ type: DecimalFilter }), + equals: g.arg({ type: g.Decimal }), + in: g.arg({ type: g.list(g.nonNull(g.Decimal)) }), + notIn: g.arg({ type: g.list(g.nonNull(g.Decimal)) }), + lt: g.arg({ type: g.Decimal }), + lte: g.arg({ type: g.Decimal }), + gt: g.arg({ type: g.Decimal }), + gte: g.arg({ type: g.Decimal }), + not: g.arg({ type: DecimalFilter }), }), }) -type BigIntNullableFilterType = graphql.InputObjectType<{ - equals: graphql.Arg // can be null - in: graphql.Arg>> // can be null - notIn: graphql.Arg>> // can be null - lt: graphql.Arg - lte: graphql.Arg - gt: graphql.Arg - gte: graphql.Arg - not: graphql.Arg // can be null +type BigIntNullableFilterType = g.InputObjectType<{ + equals: g.Arg // can be null + in: g.Arg>> // can be null + notIn: g.Arg>> // can be null + lt: g.Arg + lte: g.Arg + gt: g.Arg + gte: g.Arg + not: g.Arg // can be null }> -const BigIntNullableFilter: BigIntNullableFilterType = graphql.inputObject({ +const BigIntNullableFilter: BigIntNullableFilterType = g.inputObject({ name: 'BigIntNullableFilter', fields: () => ({ - equals: graphql.arg({ type: graphql.BigInt }), // can be null - in: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.BigInt)) }), // can be null - notIn: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.BigInt)) }), // can be null - lt: graphql.arg({ type: graphql.BigInt }), - lte: graphql.arg({ type: graphql.BigInt }), - gt: graphql.arg({ type: graphql.BigInt }), - gte: graphql.arg({ type: graphql.BigInt }), - not: graphql.arg({ type: BigIntNullableFilter }), // can be null + equals: g.arg({ type: g.BigInt }), // can be null + in: g.arg({ type: g.list(g.nonNull(g.BigInt)) }), // can be null + notIn: g.arg({ type: g.list(g.nonNull(g.BigInt)) }), // can be null + lt: g.arg({ type: g.BigInt }), + lte: g.arg({ type: g.BigInt }), + gt: g.arg({ type: g.BigInt }), + gte: g.arg({ type: g.BigInt }), + not: g.arg({ type: BigIntNullableFilter }), // can be null }), }) -type BigIntFilterType = graphql.InputObjectType<{ - equals: graphql.Arg - in: graphql.Arg>> - notIn: graphql.Arg>> - lt: graphql.Arg - lte: graphql.Arg - gt: graphql.Arg - gte: graphql.Arg - not: graphql.Arg +type BigIntFilterType = g.InputObjectType<{ + equals: g.Arg + in: g.Arg>> + notIn: g.Arg>> + lt: g.Arg + lte: g.Arg + gt: g.Arg + gte: g.Arg + not: g.Arg }> -const BigIntFilter: BigIntFilterType = graphql.inputObject({ +const BigIntFilter: BigIntFilterType = g.inputObject({ name: 'BigIntFilter', fields: () => ({ - equals: graphql.arg({ type: graphql.BigInt }), - in: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.BigInt)) }), - notIn: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.BigInt)) }), - lt: graphql.arg({ type: graphql.BigInt }), - lte: graphql.arg({ type: graphql.BigInt }), - gt: graphql.arg({ type: graphql.BigInt }), - gte: graphql.arg({ type: graphql.BigInt }), - not: graphql.arg({ type: BigIntFilter }), + equals: g.arg({ type: g.BigInt }), + in: g.arg({ type: g.list(g.nonNull(g.BigInt)) }), + notIn: g.arg({ type: g.list(g.nonNull(g.BigInt)) }), + lt: g.arg({ type: g.BigInt }), + lte: g.arg({ type: g.BigInt }), + gt: g.arg({ type: g.BigInt }), + gte: g.arg({ type: g.BigInt }), + not: g.arg({ type: BigIntFilter }), }), }) diff --git a/packages/core/src/fields/filters/providers/postgresql.ts b/packages/core/src/fields/filters/providers/postgresql.ts index c7b35a7aa62..50de32001be 100644 --- a/packages/core/src/fields/filters/providers/postgresql.ts +++ b/packages/core/src/fields/filters/providers/postgresql.ts @@ -1,410 +1,410 @@ // Do not manually modify this file, it is automatically generated by the package at /prisma-utils in this repo. -import { graphql } from '../../../types/schema' +import { g } from '../../../types/schema' import { QueryMode } from '../../../types/next-fields' -type StringNullableFilterType = graphql.InputObjectType<{ - equals: graphql.Arg // can be null - in: graphql.Arg>> // can be null - notIn: graphql.Arg>> // can be null - lt: graphql.Arg - lte: graphql.Arg - gt: graphql.Arg - gte: graphql.Arg - contains: graphql.Arg - startsWith: graphql.Arg - endsWith: graphql.Arg - mode: graphql.Arg - not: graphql.Arg // can be null +type StringNullableFilterType = g.InputObjectType<{ + equals: g.Arg // can be null + in: g.Arg>> // can be null + notIn: g.Arg>> // can be null + lt: g.Arg + lte: g.Arg + gt: g.Arg + gte: g.Arg + contains: g.Arg + startsWith: g.Arg + endsWith: g.Arg + mode: g.Arg + not: g.Arg // can be null }> -const StringNullableFilter: StringNullableFilterType = graphql.inputObject({ +const StringNullableFilter: StringNullableFilterType = g.inputObject({ name: 'StringNullableFilter', fields: () => ({ - equals: graphql.arg({ type: graphql.String }), // can be null - in: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.String)) }), // can be null - notIn: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.String)) }), // can be null - lt: graphql.arg({ type: graphql.String }), - lte: graphql.arg({ type: graphql.String }), - gt: graphql.arg({ type: graphql.String }), - gte: graphql.arg({ type: graphql.String }), - contains: graphql.arg({ type: graphql.String }), - startsWith: graphql.arg({ type: graphql.String }), - endsWith: graphql.arg({ type: graphql.String }), - mode: graphql.arg({ type: QueryMode }), - not: graphql.arg({ type: StringNullableFilter }), // can be null + equals: g.arg({ type: g.String }), // can be null + in: g.arg({ type: g.list(g.nonNull(g.String)) }), // can be null + notIn: g.arg({ type: g.list(g.nonNull(g.String)) }), // can be null + lt: g.arg({ type: g.String }), + lte: g.arg({ type: g.String }), + gt: g.arg({ type: g.String }), + gte: g.arg({ type: g.String }), + contains: g.arg({ type: g.String }), + startsWith: g.arg({ type: g.String }), + endsWith: g.arg({ type: g.String }), + mode: g.arg({ type: QueryMode }), + not: g.arg({ type: StringNullableFilter }), // can be null }), }) -type StringFilterType = graphql.InputObjectType<{ - equals: graphql.Arg - in: graphql.Arg>> - notIn: graphql.Arg>> - lt: graphql.Arg - lte: graphql.Arg - gt: graphql.Arg - gte: graphql.Arg - contains: graphql.Arg - startsWith: graphql.Arg - endsWith: graphql.Arg - mode: graphql.Arg - not: graphql.Arg +type StringFilterType = g.InputObjectType<{ + equals: g.Arg + in: g.Arg>> + notIn: g.Arg>> + lt: g.Arg + lte: g.Arg + gt: g.Arg + gte: g.Arg + contains: g.Arg + startsWith: g.Arg + endsWith: g.Arg + mode: g.Arg + not: g.Arg }> -const StringFilter: StringFilterType = graphql.inputObject({ +const StringFilter: StringFilterType = g.inputObject({ name: 'StringFilter', fields: () => ({ - equals: graphql.arg({ type: graphql.String }), - in: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.String)) }), - notIn: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.String)) }), - lt: graphql.arg({ type: graphql.String }), - lte: graphql.arg({ type: graphql.String }), - gt: graphql.arg({ type: graphql.String }), - gte: graphql.arg({ type: graphql.String }), - contains: graphql.arg({ type: graphql.String }), - startsWith: graphql.arg({ type: graphql.String }), - endsWith: graphql.arg({ type: graphql.String }), - mode: graphql.arg({ type: QueryMode }), - not: graphql.arg({ type: NestedStringFilter }), + equals: g.arg({ type: g.String }), + in: g.arg({ type: g.list(g.nonNull(g.String)) }), + notIn: g.arg({ type: g.list(g.nonNull(g.String)) }), + lt: g.arg({ type: g.String }), + lte: g.arg({ type: g.String }), + gt: g.arg({ type: g.String }), + gte: g.arg({ type: g.String }), + contains: g.arg({ type: g.String }), + startsWith: g.arg({ type: g.String }), + endsWith: g.arg({ type: g.String }), + mode: g.arg({ type: QueryMode }), + not: g.arg({ type: NestedStringFilter }), }), }) -type NestedStringNullableFilterType = graphql.InputObjectType<{ - equals: graphql.Arg // can be null - in: graphql.Arg>> // can be null - notIn: graphql.Arg>> // can be null - lt: graphql.Arg - lte: graphql.Arg - gt: graphql.Arg - gte: graphql.Arg - contains: graphql.Arg - startsWith: graphql.Arg - endsWith: graphql.Arg - not: graphql.Arg // can be null +type NestedStringNullableFilterType = g.InputObjectType<{ + equals: g.Arg // can be null + in: g.Arg>> // can be null + notIn: g.Arg>> // can be null + lt: g.Arg + lte: g.Arg + gt: g.Arg + gte: g.Arg + contains: g.Arg + startsWith: g.Arg + endsWith: g.Arg + not: g.Arg // can be null }> -const NestedStringNullableFilter: NestedStringNullableFilterType = graphql.inputObject({ +const NestedStringNullableFilter: NestedStringNullableFilterType = g.inputObject({ name: 'NestedStringNullableFilter', fields: () => ({ - equals: graphql.arg({ type: graphql.String }), // can be null - in: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.String)) }), // can be null - notIn: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.String)) }), // can be null - lt: graphql.arg({ type: graphql.String }), - lte: graphql.arg({ type: graphql.String }), - gt: graphql.arg({ type: graphql.String }), - gte: graphql.arg({ type: graphql.String }), - contains: graphql.arg({ type: graphql.String }), - startsWith: graphql.arg({ type: graphql.String }), - endsWith: graphql.arg({ type: graphql.String }), - not: graphql.arg({ type: NestedStringNullableFilter }), // can be null + equals: g.arg({ type: g.String }), // can be null + in: g.arg({ type: g.list(g.nonNull(g.String)) }), // can be null + notIn: g.arg({ type: g.list(g.nonNull(g.String)) }), // can be null + lt: g.arg({ type: g.String }), + lte: g.arg({ type: g.String }), + gt: g.arg({ type: g.String }), + gte: g.arg({ type: g.String }), + contains: g.arg({ type: g.String }), + startsWith: g.arg({ type: g.String }), + endsWith: g.arg({ type: g.String }), + not: g.arg({ type: NestedStringNullableFilter }), // can be null }), }) -type NestedStringFilterType = graphql.InputObjectType<{ - equals: graphql.Arg - in: graphql.Arg>> - notIn: graphql.Arg>> - lt: graphql.Arg - lte: graphql.Arg - gt: graphql.Arg - gte: graphql.Arg - contains: graphql.Arg - startsWith: graphql.Arg - endsWith: graphql.Arg - not: graphql.Arg +type NestedStringFilterType = g.InputObjectType<{ + equals: g.Arg + in: g.Arg>> + notIn: g.Arg>> + lt: g.Arg + lte: g.Arg + gt: g.Arg + gte: g.Arg + contains: g.Arg + startsWith: g.Arg + endsWith: g.Arg + not: g.Arg }> -const NestedStringFilter: NestedStringFilterType = graphql.inputObject({ +const NestedStringFilter: NestedStringFilterType = g.inputObject({ name: 'NestedStringFilter', fields: () => ({ - equals: graphql.arg({ type: graphql.String }), - in: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.String)) }), - notIn: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.String)) }), - lt: graphql.arg({ type: graphql.String }), - lte: graphql.arg({ type: graphql.String }), - gt: graphql.arg({ type: graphql.String }), - gte: graphql.arg({ type: graphql.String }), - contains: graphql.arg({ type: graphql.String }), - startsWith: graphql.arg({ type: graphql.String }), - endsWith: graphql.arg({ type: graphql.String }), - not: graphql.arg({ type: NestedStringFilter }), + equals: g.arg({ type: g.String }), + in: g.arg({ type: g.list(g.nonNull(g.String)) }), + notIn: g.arg({ type: g.list(g.nonNull(g.String)) }), + lt: g.arg({ type: g.String }), + lte: g.arg({ type: g.String }), + gt: g.arg({ type: g.String }), + gte: g.arg({ type: g.String }), + contains: g.arg({ type: g.String }), + startsWith: g.arg({ type: g.String }), + endsWith: g.arg({ type: g.String }), + not: g.arg({ type: NestedStringFilter }), }), }) -type BooleanNullableFilterType = graphql.InputObjectType<{ - equals: graphql.Arg // can be null - not: graphql.Arg // can be null +type BooleanNullableFilterType = g.InputObjectType<{ + equals: g.Arg // can be null + not: g.Arg // can be null }> -const BooleanNullableFilter: BooleanNullableFilterType = graphql.inputObject({ +const BooleanNullableFilter: BooleanNullableFilterType = g.inputObject({ name: 'BooleanNullableFilter', fields: () => ({ - equals: graphql.arg({ type: graphql.Boolean }), // can be null - not: graphql.arg({ type: BooleanNullableFilter }), // can be null + equals: g.arg({ type: g.Boolean }), // can be null + not: g.arg({ type: BooleanNullableFilter }), // can be null }), }) -type BooleanFilterType = graphql.InputObjectType<{ - equals: graphql.Arg - not: graphql.Arg +type BooleanFilterType = g.InputObjectType<{ + equals: g.Arg + not: g.Arg }> -const BooleanFilter: BooleanFilterType = graphql.inputObject({ +const BooleanFilter: BooleanFilterType = g.inputObject({ name: 'BooleanFilter', fields: () => ({ - equals: graphql.arg({ type: graphql.Boolean }), - not: graphql.arg({ type: BooleanFilter }), + equals: g.arg({ type: g.Boolean }), + not: g.arg({ type: BooleanFilter }), }), }) -type IntFilterType = graphql.InputObjectType<{ - equals: graphql.Arg - in: graphql.Arg>> - notIn: graphql.Arg>> - lt: graphql.Arg - lte: graphql.Arg - gt: graphql.Arg - gte: graphql.Arg - not: graphql.Arg +type IntFilterType = g.InputObjectType<{ + equals: g.Arg + in: g.Arg>> + notIn: g.Arg>> + lt: g.Arg + lte: g.Arg + gt: g.Arg + gte: g.Arg + not: g.Arg }> -const IntFilter: IntFilterType = graphql.inputObject({ +const IntFilter: IntFilterType = g.inputObject({ name: 'IntFilter', fields: () => ({ - equals: graphql.arg({ type: graphql.Int }), - in: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.Int)) }), - notIn: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.Int)) }), - lt: graphql.arg({ type: graphql.Int }), - lte: graphql.arg({ type: graphql.Int }), - gt: graphql.arg({ type: graphql.Int }), - gte: graphql.arg({ type: graphql.Int }), - not: graphql.arg({ type: IntFilter }), + equals: g.arg({ type: g.Int }), + in: g.arg({ type: g.list(g.nonNull(g.Int)) }), + notIn: g.arg({ type: g.list(g.nonNull(g.Int)) }), + lt: g.arg({ type: g.Int }), + lte: g.arg({ type: g.Int }), + gt: g.arg({ type: g.Int }), + gte: g.arg({ type: g.Int }), + not: g.arg({ type: IntFilter }), }), }) -type IntNullableFilterType = graphql.InputObjectType<{ - equals: graphql.Arg // can be null - in: graphql.Arg>> // can be null - notIn: graphql.Arg>> // can be null - lt: graphql.Arg - lte: graphql.Arg - gt: graphql.Arg - gte: graphql.Arg - not: graphql.Arg // can be null +type IntNullableFilterType = g.InputObjectType<{ + equals: g.Arg // can be null + in: g.Arg>> // can be null + notIn: g.Arg>> // can be null + lt: g.Arg + lte: g.Arg + gt: g.Arg + gte: g.Arg + not: g.Arg // can be null }> -const IntNullableFilter: IntNullableFilterType = graphql.inputObject({ +const IntNullableFilter: IntNullableFilterType = g.inputObject({ name: 'IntNullableFilter', fields: () => ({ - equals: graphql.arg({ type: graphql.Int }), // can be null - in: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.Int)) }), // can be null - notIn: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.Int)) }), // can be null - lt: graphql.arg({ type: graphql.Int }), - lte: graphql.arg({ type: graphql.Int }), - gt: graphql.arg({ type: graphql.Int }), - gte: graphql.arg({ type: graphql.Int }), - not: graphql.arg({ type: IntNullableFilter }), // can be null + equals: g.arg({ type: g.Int }), // can be null + in: g.arg({ type: g.list(g.nonNull(g.Int)) }), // can be null + notIn: g.arg({ type: g.list(g.nonNull(g.Int)) }), // can be null + lt: g.arg({ type: g.Int }), + lte: g.arg({ type: g.Int }), + gt: g.arg({ type: g.Int }), + gte: g.arg({ type: g.Int }), + not: g.arg({ type: IntNullableFilter }), // can be null }), }) -type FloatNullableFilterType = graphql.InputObjectType<{ - equals: graphql.Arg // can be null - in: graphql.Arg>> // can be null - notIn: graphql.Arg>> // can be null - lt: graphql.Arg - lte: graphql.Arg - gt: graphql.Arg - gte: graphql.Arg - not: graphql.Arg // can be null +type FloatNullableFilterType = g.InputObjectType<{ + equals: g.Arg // can be null + in: g.Arg>> // can be null + notIn: g.Arg>> // can be null + lt: g.Arg + lte: g.Arg + gt: g.Arg + gte: g.Arg + not: g.Arg // can be null }> -const FloatNullableFilter: FloatNullableFilterType = graphql.inputObject({ +const FloatNullableFilter: FloatNullableFilterType = g.inputObject({ name: 'FloatNullableFilter', fields: () => ({ - equals: graphql.arg({ type: graphql.Float }), // can be null - in: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.Float)) }), // can be null - notIn: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.Float)) }), // can be null - lt: graphql.arg({ type: graphql.Float }), - lte: graphql.arg({ type: graphql.Float }), - gt: graphql.arg({ type: graphql.Float }), - gte: graphql.arg({ type: graphql.Float }), - not: graphql.arg({ type: FloatNullableFilter }), // can be null + equals: g.arg({ type: g.Float }), // can be null + in: g.arg({ type: g.list(g.nonNull(g.Float)) }), // can be null + notIn: g.arg({ type: g.list(g.nonNull(g.Float)) }), // can be null + lt: g.arg({ type: g.Float }), + lte: g.arg({ type: g.Float }), + gt: g.arg({ type: g.Float }), + gte: g.arg({ type: g.Float }), + not: g.arg({ type: FloatNullableFilter }), // can be null }), }) -type FloatFilterType = graphql.InputObjectType<{ - equals: graphql.Arg - in: graphql.Arg>> - notIn: graphql.Arg>> - lt: graphql.Arg - lte: graphql.Arg - gt: graphql.Arg - gte: graphql.Arg - not: graphql.Arg +type FloatFilterType = g.InputObjectType<{ + equals: g.Arg + in: g.Arg>> + notIn: g.Arg>> + lt: g.Arg + lte: g.Arg + gt: g.Arg + gte: g.Arg + not: g.Arg }> -const FloatFilter: FloatFilterType = graphql.inputObject({ +const FloatFilter: FloatFilterType = g.inputObject({ name: 'FloatFilter', fields: () => ({ - equals: graphql.arg({ type: graphql.Float }), - in: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.Float)) }), - notIn: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.Float)) }), - lt: graphql.arg({ type: graphql.Float }), - lte: graphql.arg({ type: graphql.Float }), - gt: graphql.arg({ type: graphql.Float }), - gte: graphql.arg({ type: graphql.Float }), - not: graphql.arg({ type: FloatFilter }), + equals: g.arg({ type: g.Float }), + in: g.arg({ type: g.list(g.nonNull(g.Float)) }), + notIn: g.arg({ type: g.list(g.nonNull(g.Float)) }), + lt: g.arg({ type: g.Float }), + lte: g.arg({ type: g.Float }), + gt: g.arg({ type: g.Float }), + gte: g.arg({ type: g.Float }), + not: g.arg({ type: FloatFilter }), }), }) -type DateTimeNullableFilterType = graphql.InputObjectType<{ - equals: graphql.Arg // can be null - in: graphql.Arg>> // can be null - notIn: graphql.Arg>> // can be null - lt: graphql.Arg - lte: graphql.Arg - gt: graphql.Arg - gte: graphql.Arg - not: graphql.Arg // can be null +type DateTimeNullableFilterType = g.InputObjectType<{ + equals: g.Arg // can be null + in: g.Arg>> // can be null + notIn: g.Arg>> // can be null + lt: g.Arg + lte: g.Arg + gt: g.Arg + gte: g.Arg + not: g.Arg // can be null }> -const DateTimeNullableFilter: DateTimeNullableFilterType = graphql.inputObject({ +const DateTimeNullableFilter: DateTimeNullableFilterType = g.inputObject({ name: 'DateTimeNullableFilter', fields: () => ({ - equals: graphql.arg({ type: graphql.DateTime }), // can be null - in: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.DateTime)) }), // can be null - notIn: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.DateTime)) }), // can be null - lt: graphql.arg({ type: graphql.DateTime }), - lte: graphql.arg({ type: graphql.DateTime }), - gt: graphql.arg({ type: graphql.DateTime }), - gte: graphql.arg({ type: graphql.DateTime }), - not: graphql.arg({ type: DateTimeNullableFilter }), // can be null + equals: g.arg({ type: g.DateTime }), // can be null + in: g.arg({ type: g.list(g.nonNull(g.DateTime)) }), // can be null + notIn: g.arg({ type: g.list(g.nonNull(g.DateTime)) }), // can be null + lt: g.arg({ type: g.DateTime }), + lte: g.arg({ type: g.DateTime }), + gt: g.arg({ type: g.DateTime }), + gte: g.arg({ type: g.DateTime }), + not: g.arg({ type: DateTimeNullableFilter }), // can be null }), }) -type DateTimeFilterType = graphql.InputObjectType<{ - equals: graphql.Arg - in: graphql.Arg>> - notIn: graphql.Arg>> - lt: graphql.Arg - lte: graphql.Arg - gt: graphql.Arg - gte: graphql.Arg - not: graphql.Arg +type DateTimeFilterType = g.InputObjectType<{ + equals: g.Arg + in: g.Arg>> + notIn: g.Arg>> + lt: g.Arg + lte: g.Arg + gt: g.Arg + gte: g.Arg + not: g.Arg }> -const DateTimeFilter: DateTimeFilterType = graphql.inputObject({ +const DateTimeFilter: DateTimeFilterType = g.inputObject({ name: 'DateTimeFilter', fields: () => ({ - equals: graphql.arg({ type: graphql.DateTime }), - in: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.DateTime)) }), - notIn: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.DateTime)) }), - lt: graphql.arg({ type: graphql.DateTime }), - lte: graphql.arg({ type: graphql.DateTime }), - gt: graphql.arg({ type: graphql.DateTime }), - gte: graphql.arg({ type: graphql.DateTime }), - not: graphql.arg({ type: DateTimeFilter }), + equals: g.arg({ type: g.DateTime }), + in: g.arg({ type: g.list(g.nonNull(g.DateTime)) }), + notIn: g.arg({ type: g.list(g.nonNull(g.DateTime)) }), + lt: g.arg({ type: g.DateTime }), + lte: g.arg({ type: g.DateTime }), + gt: g.arg({ type: g.DateTime }), + gte: g.arg({ type: g.DateTime }), + not: g.arg({ type: DateTimeFilter }), }), }) -type DecimalNullableFilterType = graphql.InputObjectType<{ - equals: graphql.Arg // can be null - in: graphql.Arg>> // can be null - notIn: graphql.Arg>> // can be null - lt: graphql.Arg - lte: graphql.Arg - gt: graphql.Arg - gte: graphql.Arg - not: graphql.Arg // can be null +type DecimalNullableFilterType = g.InputObjectType<{ + equals: g.Arg // can be null + in: g.Arg>> // can be null + notIn: g.Arg>> // can be null + lt: g.Arg + lte: g.Arg + gt: g.Arg + gte: g.Arg + not: g.Arg // can be null }> -const DecimalNullableFilter: DecimalNullableFilterType = graphql.inputObject({ +const DecimalNullableFilter: DecimalNullableFilterType = g.inputObject({ name: 'DecimalNullableFilter', fields: () => ({ - equals: graphql.arg({ type: graphql.Decimal }), // can be null - in: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.Decimal)) }), // can be null - notIn: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.Decimal)) }), // can be null - lt: graphql.arg({ type: graphql.Decimal }), - lte: graphql.arg({ type: graphql.Decimal }), - gt: graphql.arg({ type: graphql.Decimal }), - gte: graphql.arg({ type: graphql.Decimal }), - not: graphql.arg({ type: DecimalNullableFilter }), // can be null + equals: g.arg({ type: g.Decimal }), // can be null + in: g.arg({ type: g.list(g.nonNull(g.Decimal)) }), // can be null + notIn: g.arg({ type: g.list(g.nonNull(g.Decimal)) }), // can be null + lt: g.arg({ type: g.Decimal }), + lte: g.arg({ type: g.Decimal }), + gt: g.arg({ type: g.Decimal }), + gte: g.arg({ type: g.Decimal }), + not: g.arg({ type: DecimalNullableFilter }), // can be null }), }) -type DecimalFilterType = graphql.InputObjectType<{ - equals: graphql.Arg - in: graphql.Arg>> - notIn: graphql.Arg>> - lt: graphql.Arg - lte: graphql.Arg - gt: graphql.Arg - gte: graphql.Arg - not: graphql.Arg +type DecimalFilterType = g.InputObjectType<{ + equals: g.Arg + in: g.Arg>> + notIn: g.Arg>> + lt: g.Arg + lte: g.Arg + gt: g.Arg + gte: g.Arg + not: g.Arg }> -const DecimalFilter: DecimalFilterType = graphql.inputObject({ +const DecimalFilter: DecimalFilterType = g.inputObject({ name: 'DecimalFilter', fields: () => ({ - equals: graphql.arg({ type: graphql.Decimal }), - in: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.Decimal)) }), - notIn: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.Decimal)) }), - lt: graphql.arg({ type: graphql.Decimal }), - lte: graphql.arg({ type: graphql.Decimal }), - gt: graphql.arg({ type: graphql.Decimal }), - gte: graphql.arg({ type: graphql.Decimal }), - not: graphql.arg({ type: DecimalFilter }), + equals: g.arg({ type: g.Decimal }), + in: g.arg({ type: g.list(g.nonNull(g.Decimal)) }), + notIn: g.arg({ type: g.list(g.nonNull(g.Decimal)) }), + lt: g.arg({ type: g.Decimal }), + lte: g.arg({ type: g.Decimal }), + gt: g.arg({ type: g.Decimal }), + gte: g.arg({ type: g.Decimal }), + not: g.arg({ type: DecimalFilter }), }), }) -type BigIntNullableFilterType = graphql.InputObjectType<{ - equals: graphql.Arg // can be null - in: graphql.Arg>> // can be null - notIn: graphql.Arg>> // can be null - lt: graphql.Arg - lte: graphql.Arg - gt: graphql.Arg - gte: graphql.Arg - not: graphql.Arg // can be null +type BigIntNullableFilterType = g.InputObjectType<{ + equals: g.Arg // can be null + in: g.Arg>> // can be null + notIn: g.Arg>> // can be null + lt: g.Arg + lte: g.Arg + gt: g.Arg + gte: g.Arg + not: g.Arg // can be null }> -const BigIntNullableFilter: BigIntNullableFilterType = graphql.inputObject({ +const BigIntNullableFilter: BigIntNullableFilterType = g.inputObject({ name: 'BigIntNullableFilter', fields: () => ({ - equals: graphql.arg({ type: graphql.BigInt }), // can be null - in: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.BigInt)) }), // can be null - notIn: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.BigInt)) }), // can be null - lt: graphql.arg({ type: graphql.BigInt }), - lte: graphql.arg({ type: graphql.BigInt }), - gt: graphql.arg({ type: graphql.BigInt }), - gte: graphql.arg({ type: graphql.BigInt }), - not: graphql.arg({ type: BigIntNullableFilter }), // can be null + equals: g.arg({ type: g.BigInt }), // can be null + in: g.arg({ type: g.list(g.nonNull(g.BigInt)) }), // can be null + notIn: g.arg({ type: g.list(g.nonNull(g.BigInt)) }), // can be null + lt: g.arg({ type: g.BigInt }), + lte: g.arg({ type: g.BigInt }), + gt: g.arg({ type: g.BigInt }), + gte: g.arg({ type: g.BigInt }), + not: g.arg({ type: BigIntNullableFilter }), // can be null }), }) -type BigIntFilterType = graphql.InputObjectType<{ - equals: graphql.Arg - in: graphql.Arg>> - notIn: graphql.Arg>> - lt: graphql.Arg - lte: graphql.Arg - gt: graphql.Arg - gte: graphql.Arg - not: graphql.Arg +type BigIntFilterType = g.InputObjectType<{ + equals: g.Arg + in: g.Arg>> + notIn: g.Arg>> + lt: g.Arg + lte: g.Arg + gt: g.Arg + gte: g.Arg + not: g.Arg }> -const BigIntFilter: BigIntFilterType = graphql.inputObject({ +const BigIntFilter: BigIntFilterType = g.inputObject({ name: 'BigIntFilter', fields: () => ({ - equals: graphql.arg({ type: graphql.BigInt }), - in: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.BigInt)) }), - notIn: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.BigInt)) }), - lt: graphql.arg({ type: graphql.BigInt }), - lte: graphql.arg({ type: graphql.BigInt }), - gt: graphql.arg({ type: graphql.BigInt }), - gte: graphql.arg({ type: graphql.BigInt }), - not: graphql.arg({ type: BigIntFilter }), + equals: g.arg({ type: g.BigInt }), + in: g.arg({ type: g.list(g.nonNull(g.BigInt)) }), + notIn: g.arg({ type: g.list(g.nonNull(g.BigInt)) }), + lt: g.arg({ type: g.BigInt }), + lte: g.arg({ type: g.BigInt }), + gt: g.arg({ type: g.BigInt }), + gte: g.arg({ type: g.BigInt }), + not: g.arg({ type: BigIntFilter }), }), }) diff --git a/packages/core/src/fields/filters/providers/sqlite.ts b/packages/core/src/fields/filters/providers/sqlite.ts index 762a74e278c..0a59d960fed 100644 --- a/packages/core/src/fields/filters/providers/sqlite.ts +++ b/packages/core/src/fields/filters/providers/sqlite.ts @@ -1,404 +1,404 @@ // Do not manually modify this file, it is automatically generated by the package at /prisma-utils in this repo. -import { graphql } from '../../../types/schema' - -type StringNullableFilterType = graphql.InputObjectType<{ - equals: graphql.Arg // can be null - in: graphql.Arg>> // can be null - notIn: graphql.Arg>> // can be null - lt: graphql.Arg - lte: graphql.Arg - gt: graphql.Arg - gte: graphql.Arg - contains: graphql.Arg - startsWith: graphql.Arg - endsWith: graphql.Arg - not: graphql.Arg // can be null +import { g } from '../../../types/schema' + +type StringNullableFilterType = g.InputObjectType<{ + equals: g.Arg // can be null + in: g.Arg>> // can be null + notIn: g.Arg>> // can be null + lt: g.Arg + lte: g.Arg + gt: g.Arg + gte: g.Arg + contains: g.Arg + startsWith: g.Arg + endsWith: g.Arg + not: g.Arg // can be null }> -const StringNullableFilter: StringNullableFilterType = graphql.inputObject({ +const StringNullableFilter: StringNullableFilterType = g.inputObject({ name: 'StringNullableFilter', fields: () => ({ - equals: graphql.arg({ type: graphql.String }), // can be null - in: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.String)) }), // can be null - notIn: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.String)) }), // can be null - lt: graphql.arg({ type: graphql.String }), - lte: graphql.arg({ type: graphql.String }), - gt: graphql.arg({ type: graphql.String }), - gte: graphql.arg({ type: graphql.String }), - contains: graphql.arg({ type: graphql.String }), - startsWith: graphql.arg({ type: graphql.String }), - endsWith: graphql.arg({ type: graphql.String }), - not: graphql.arg({ type: StringNullableFilter }), // can be null + equals: g.arg({ type: g.String }), // can be null + in: g.arg({ type: g.list(g.nonNull(g.String)) }), // can be null + notIn: g.arg({ type: g.list(g.nonNull(g.String)) }), // can be null + lt: g.arg({ type: g.String }), + lte: g.arg({ type: g.String }), + gt: g.arg({ type: g.String }), + gte: g.arg({ type: g.String }), + contains: g.arg({ type: g.String }), + startsWith: g.arg({ type: g.String }), + endsWith: g.arg({ type: g.String }), + not: g.arg({ type: StringNullableFilter }), // can be null }), }) -type StringFilterType = graphql.InputObjectType<{ - equals: graphql.Arg - in: graphql.Arg>> - notIn: graphql.Arg>> - lt: graphql.Arg - lte: graphql.Arg - gt: graphql.Arg - gte: graphql.Arg - contains: graphql.Arg - startsWith: graphql.Arg - endsWith: graphql.Arg - not: graphql.Arg +type StringFilterType = g.InputObjectType<{ + equals: g.Arg + in: g.Arg>> + notIn: g.Arg>> + lt: g.Arg + lte: g.Arg + gt: g.Arg + gte: g.Arg + contains: g.Arg + startsWith: g.Arg + endsWith: g.Arg + not: g.Arg }> -const StringFilter: StringFilterType = graphql.inputObject({ +const StringFilter: StringFilterType = g.inputObject({ name: 'StringFilter', fields: () => ({ - equals: graphql.arg({ type: graphql.String }), - in: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.String)) }), - notIn: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.String)) }), - lt: graphql.arg({ type: graphql.String }), - lte: graphql.arg({ type: graphql.String }), - gt: graphql.arg({ type: graphql.String }), - gte: graphql.arg({ type: graphql.String }), - contains: graphql.arg({ type: graphql.String }), - startsWith: graphql.arg({ type: graphql.String }), - endsWith: graphql.arg({ type: graphql.String }), - not: graphql.arg({ type: NestedStringFilter }), + equals: g.arg({ type: g.String }), + in: g.arg({ type: g.list(g.nonNull(g.String)) }), + notIn: g.arg({ type: g.list(g.nonNull(g.String)) }), + lt: g.arg({ type: g.String }), + lte: g.arg({ type: g.String }), + gt: g.arg({ type: g.String }), + gte: g.arg({ type: g.String }), + contains: g.arg({ type: g.String }), + startsWith: g.arg({ type: g.String }), + endsWith: g.arg({ type: g.String }), + not: g.arg({ type: NestedStringFilter }), }), }) -type NestedStringNullableFilterType = graphql.InputObjectType<{ - equals: graphql.Arg // can be null - in: graphql.Arg>> // can be null - notIn: graphql.Arg>> // can be null - lt: graphql.Arg - lte: graphql.Arg - gt: graphql.Arg - gte: graphql.Arg - contains: graphql.Arg - startsWith: graphql.Arg - endsWith: graphql.Arg - not: graphql.Arg // can be null +type NestedStringNullableFilterType = g.InputObjectType<{ + equals: g.Arg // can be null + in: g.Arg>> // can be null + notIn: g.Arg>> // can be null + lt: g.Arg + lte: g.Arg + gt: g.Arg + gte: g.Arg + contains: g.Arg + startsWith: g.Arg + endsWith: g.Arg + not: g.Arg // can be null }> -const NestedStringNullableFilter: NestedStringNullableFilterType = graphql.inputObject({ +const NestedStringNullableFilter: NestedStringNullableFilterType = g.inputObject({ name: 'NestedStringNullableFilter', fields: () => ({ - equals: graphql.arg({ type: graphql.String }), // can be null - in: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.String)) }), // can be null - notIn: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.String)) }), // can be null - lt: graphql.arg({ type: graphql.String }), - lte: graphql.arg({ type: graphql.String }), - gt: graphql.arg({ type: graphql.String }), - gte: graphql.arg({ type: graphql.String }), - contains: graphql.arg({ type: graphql.String }), - startsWith: graphql.arg({ type: graphql.String }), - endsWith: graphql.arg({ type: graphql.String }), - not: graphql.arg({ type: NestedStringNullableFilter }), // can be null + equals: g.arg({ type: g.String }), // can be null + in: g.arg({ type: g.list(g.nonNull(g.String)) }), // can be null + notIn: g.arg({ type: g.list(g.nonNull(g.String)) }), // can be null + lt: g.arg({ type: g.String }), + lte: g.arg({ type: g.String }), + gt: g.arg({ type: g.String }), + gte: g.arg({ type: g.String }), + contains: g.arg({ type: g.String }), + startsWith: g.arg({ type: g.String }), + endsWith: g.arg({ type: g.String }), + not: g.arg({ type: NestedStringNullableFilter }), // can be null }), }) -type NestedStringFilterType = graphql.InputObjectType<{ - equals: graphql.Arg - in: graphql.Arg>> - notIn: graphql.Arg>> - lt: graphql.Arg - lte: graphql.Arg - gt: graphql.Arg - gte: graphql.Arg - contains: graphql.Arg - startsWith: graphql.Arg - endsWith: graphql.Arg - not: graphql.Arg +type NestedStringFilterType = g.InputObjectType<{ + equals: g.Arg + in: g.Arg>> + notIn: g.Arg>> + lt: g.Arg + lte: g.Arg + gt: g.Arg + gte: g.Arg + contains: g.Arg + startsWith: g.Arg + endsWith: g.Arg + not: g.Arg }> -const NestedStringFilter: NestedStringFilterType = graphql.inputObject({ +const NestedStringFilter: NestedStringFilterType = g.inputObject({ name: 'NestedStringFilter', fields: () => ({ - equals: graphql.arg({ type: graphql.String }), - in: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.String)) }), - notIn: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.String)) }), - lt: graphql.arg({ type: graphql.String }), - lte: graphql.arg({ type: graphql.String }), - gt: graphql.arg({ type: graphql.String }), - gte: graphql.arg({ type: graphql.String }), - contains: graphql.arg({ type: graphql.String }), - startsWith: graphql.arg({ type: graphql.String }), - endsWith: graphql.arg({ type: graphql.String }), - not: graphql.arg({ type: NestedStringFilter }), + equals: g.arg({ type: g.String }), + in: g.arg({ type: g.list(g.nonNull(g.String)) }), + notIn: g.arg({ type: g.list(g.nonNull(g.String)) }), + lt: g.arg({ type: g.String }), + lte: g.arg({ type: g.String }), + gt: g.arg({ type: g.String }), + gte: g.arg({ type: g.String }), + contains: g.arg({ type: g.String }), + startsWith: g.arg({ type: g.String }), + endsWith: g.arg({ type: g.String }), + not: g.arg({ type: NestedStringFilter }), }), }) -type BooleanNullableFilterType = graphql.InputObjectType<{ - equals: graphql.Arg // can be null - not: graphql.Arg // can be null +type BooleanNullableFilterType = g.InputObjectType<{ + equals: g.Arg // can be null + not: g.Arg // can be null }> -const BooleanNullableFilter: BooleanNullableFilterType = graphql.inputObject({ +const BooleanNullableFilter: BooleanNullableFilterType = g.inputObject({ name: 'BooleanNullableFilter', fields: () => ({ - equals: graphql.arg({ type: graphql.Boolean }), // can be null - not: graphql.arg({ type: BooleanNullableFilter }), // can be null + equals: g.arg({ type: g.Boolean }), // can be null + not: g.arg({ type: BooleanNullableFilter }), // can be null }), }) -type BooleanFilterType = graphql.InputObjectType<{ - equals: graphql.Arg - not: graphql.Arg +type BooleanFilterType = g.InputObjectType<{ + equals: g.Arg + not: g.Arg }> -const BooleanFilter: BooleanFilterType = graphql.inputObject({ +const BooleanFilter: BooleanFilterType = g.inputObject({ name: 'BooleanFilter', fields: () => ({ - equals: graphql.arg({ type: graphql.Boolean }), - not: graphql.arg({ type: BooleanFilter }), + equals: g.arg({ type: g.Boolean }), + not: g.arg({ type: BooleanFilter }), }), }) -type IntFilterType = graphql.InputObjectType<{ - equals: graphql.Arg - in: graphql.Arg>> - notIn: graphql.Arg>> - lt: graphql.Arg - lte: graphql.Arg - gt: graphql.Arg - gte: graphql.Arg - not: graphql.Arg +type IntFilterType = g.InputObjectType<{ + equals: g.Arg + in: g.Arg>> + notIn: g.Arg>> + lt: g.Arg + lte: g.Arg + gt: g.Arg + gte: g.Arg + not: g.Arg }> -const IntFilter: IntFilterType = graphql.inputObject({ +const IntFilter: IntFilterType = g.inputObject({ name: 'IntFilter', fields: () => ({ - equals: graphql.arg({ type: graphql.Int }), - in: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.Int)) }), - notIn: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.Int)) }), - lt: graphql.arg({ type: graphql.Int }), - lte: graphql.arg({ type: graphql.Int }), - gt: graphql.arg({ type: graphql.Int }), - gte: graphql.arg({ type: graphql.Int }), - not: graphql.arg({ type: IntFilter }), + equals: g.arg({ type: g.Int }), + in: g.arg({ type: g.list(g.nonNull(g.Int)) }), + notIn: g.arg({ type: g.list(g.nonNull(g.Int)) }), + lt: g.arg({ type: g.Int }), + lte: g.arg({ type: g.Int }), + gt: g.arg({ type: g.Int }), + gte: g.arg({ type: g.Int }), + not: g.arg({ type: IntFilter }), }), }) -type IntNullableFilterType = graphql.InputObjectType<{ - equals: graphql.Arg // can be null - in: graphql.Arg>> // can be null - notIn: graphql.Arg>> // can be null - lt: graphql.Arg - lte: graphql.Arg - gt: graphql.Arg - gte: graphql.Arg - not: graphql.Arg // can be null +type IntNullableFilterType = g.InputObjectType<{ + equals: g.Arg // can be null + in: g.Arg>> // can be null + notIn: g.Arg>> // can be null + lt: g.Arg + lte: g.Arg + gt: g.Arg + gte: g.Arg + not: g.Arg // can be null }> -const IntNullableFilter: IntNullableFilterType = graphql.inputObject({ +const IntNullableFilter: IntNullableFilterType = g.inputObject({ name: 'IntNullableFilter', fields: () => ({ - equals: graphql.arg({ type: graphql.Int }), // can be null - in: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.Int)) }), // can be null - notIn: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.Int)) }), // can be null - lt: graphql.arg({ type: graphql.Int }), - lte: graphql.arg({ type: graphql.Int }), - gt: graphql.arg({ type: graphql.Int }), - gte: graphql.arg({ type: graphql.Int }), - not: graphql.arg({ type: IntNullableFilter }), // can be null + equals: g.arg({ type: g.Int }), // can be null + in: g.arg({ type: g.list(g.nonNull(g.Int)) }), // can be null + notIn: g.arg({ type: g.list(g.nonNull(g.Int)) }), // can be null + lt: g.arg({ type: g.Int }), + lte: g.arg({ type: g.Int }), + gt: g.arg({ type: g.Int }), + gte: g.arg({ type: g.Int }), + not: g.arg({ type: IntNullableFilter }), // can be null }), }) -type FloatNullableFilterType = graphql.InputObjectType<{ - equals: graphql.Arg // can be null - in: graphql.Arg>> // can be null - notIn: graphql.Arg>> // can be null - lt: graphql.Arg - lte: graphql.Arg - gt: graphql.Arg - gte: graphql.Arg - not: graphql.Arg // can be null +type FloatNullableFilterType = g.InputObjectType<{ + equals: g.Arg // can be null + in: g.Arg>> // can be null + notIn: g.Arg>> // can be null + lt: g.Arg + lte: g.Arg + gt: g.Arg + gte: g.Arg + not: g.Arg // can be null }> -const FloatNullableFilter: FloatNullableFilterType = graphql.inputObject({ +const FloatNullableFilter: FloatNullableFilterType = g.inputObject({ name: 'FloatNullableFilter', fields: () => ({ - equals: graphql.arg({ type: graphql.Float }), // can be null - in: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.Float)) }), // can be null - notIn: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.Float)) }), // can be null - lt: graphql.arg({ type: graphql.Float }), - lte: graphql.arg({ type: graphql.Float }), - gt: graphql.arg({ type: graphql.Float }), - gte: graphql.arg({ type: graphql.Float }), - not: graphql.arg({ type: FloatNullableFilter }), // can be null + equals: g.arg({ type: g.Float }), // can be null + in: g.arg({ type: g.list(g.nonNull(g.Float)) }), // can be null + notIn: g.arg({ type: g.list(g.nonNull(g.Float)) }), // can be null + lt: g.arg({ type: g.Float }), + lte: g.arg({ type: g.Float }), + gt: g.arg({ type: g.Float }), + gte: g.arg({ type: g.Float }), + not: g.arg({ type: FloatNullableFilter }), // can be null }), }) -type FloatFilterType = graphql.InputObjectType<{ - equals: graphql.Arg - in: graphql.Arg>> - notIn: graphql.Arg>> - lt: graphql.Arg - lte: graphql.Arg - gt: graphql.Arg - gte: graphql.Arg - not: graphql.Arg +type FloatFilterType = g.InputObjectType<{ + equals: g.Arg + in: g.Arg>> + notIn: g.Arg>> + lt: g.Arg + lte: g.Arg + gt: g.Arg + gte: g.Arg + not: g.Arg }> -const FloatFilter: FloatFilterType = graphql.inputObject({ +const FloatFilter: FloatFilterType = g.inputObject({ name: 'FloatFilter', fields: () => ({ - equals: graphql.arg({ type: graphql.Float }), - in: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.Float)) }), - notIn: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.Float)) }), - lt: graphql.arg({ type: graphql.Float }), - lte: graphql.arg({ type: graphql.Float }), - gt: graphql.arg({ type: graphql.Float }), - gte: graphql.arg({ type: graphql.Float }), - not: graphql.arg({ type: FloatFilter }), + equals: g.arg({ type: g.Float }), + in: g.arg({ type: g.list(g.nonNull(g.Float)) }), + notIn: g.arg({ type: g.list(g.nonNull(g.Float)) }), + lt: g.arg({ type: g.Float }), + lte: g.arg({ type: g.Float }), + gt: g.arg({ type: g.Float }), + gte: g.arg({ type: g.Float }), + not: g.arg({ type: FloatFilter }), }), }) -type DateTimeNullableFilterType = graphql.InputObjectType<{ - equals: graphql.Arg // can be null - in: graphql.Arg>> // can be null - notIn: graphql.Arg>> // can be null - lt: graphql.Arg - lte: graphql.Arg - gt: graphql.Arg - gte: graphql.Arg - not: graphql.Arg // can be null +type DateTimeNullableFilterType = g.InputObjectType<{ + equals: g.Arg // can be null + in: g.Arg>> // can be null + notIn: g.Arg>> // can be null + lt: g.Arg + lte: g.Arg + gt: g.Arg + gte: g.Arg + not: g.Arg // can be null }> -const DateTimeNullableFilter: DateTimeNullableFilterType = graphql.inputObject({ +const DateTimeNullableFilter: DateTimeNullableFilterType = g.inputObject({ name: 'DateTimeNullableFilter', fields: () => ({ - equals: graphql.arg({ type: graphql.DateTime }), // can be null - in: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.DateTime)) }), // can be null - notIn: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.DateTime)) }), // can be null - lt: graphql.arg({ type: graphql.DateTime }), - lte: graphql.arg({ type: graphql.DateTime }), - gt: graphql.arg({ type: graphql.DateTime }), - gte: graphql.arg({ type: graphql.DateTime }), - not: graphql.arg({ type: DateTimeNullableFilter }), // can be null + equals: g.arg({ type: g.DateTime }), // can be null + in: g.arg({ type: g.list(g.nonNull(g.DateTime)) }), // can be null + notIn: g.arg({ type: g.list(g.nonNull(g.DateTime)) }), // can be null + lt: g.arg({ type: g.DateTime }), + lte: g.arg({ type: g.DateTime }), + gt: g.arg({ type: g.DateTime }), + gte: g.arg({ type: g.DateTime }), + not: g.arg({ type: DateTimeNullableFilter }), // can be null }), }) -type DateTimeFilterType = graphql.InputObjectType<{ - equals: graphql.Arg - in: graphql.Arg>> - notIn: graphql.Arg>> - lt: graphql.Arg - lte: graphql.Arg - gt: graphql.Arg - gte: graphql.Arg - not: graphql.Arg +type DateTimeFilterType = g.InputObjectType<{ + equals: g.Arg + in: g.Arg>> + notIn: g.Arg>> + lt: g.Arg + lte: g.Arg + gt: g.Arg + gte: g.Arg + not: g.Arg }> -const DateTimeFilter: DateTimeFilterType = graphql.inputObject({ +const DateTimeFilter: DateTimeFilterType = g.inputObject({ name: 'DateTimeFilter', fields: () => ({ - equals: graphql.arg({ type: graphql.DateTime }), - in: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.DateTime)) }), - notIn: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.DateTime)) }), - lt: graphql.arg({ type: graphql.DateTime }), - lte: graphql.arg({ type: graphql.DateTime }), - gt: graphql.arg({ type: graphql.DateTime }), - gte: graphql.arg({ type: graphql.DateTime }), - not: graphql.arg({ type: DateTimeFilter }), + equals: g.arg({ type: g.DateTime }), + in: g.arg({ type: g.list(g.nonNull(g.DateTime)) }), + notIn: g.arg({ type: g.list(g.nonNull(g.DateTime)) }), + lt: g.arg({ type: g.DateTime }), + lte: g.arg({ type: g.DateTime }), + gt: g.arg({ type: g.DateTime }), + gte: g.arg({ type: g.DateTime }), + not: g.arg({ type: DateTimeFilter }), }), }) -type DecimalNullableFilterType = graphql.InputObjectType<{ - equals: graphql.Arg // can be null - in: graphql.Arg>> // can be null - notIn: graphql.Arg>> // can be null - lt: graphql.Arg - lte: graphql.Arg - gt: graphql.Arg - gte: graphql.Arg - not: graphql.Arg // can be null +type DecimalNullableFilterType = g.InputObjectType<{ + equals: g.Arg // can be null + in: g.Arg>> // can be null + notIn: g.Arg>> // can be null + lt: g.Arg + lte: g.Arg + gt: g.Arg + gte: g.Arg + not: g.Arg // can be null }> -const DecimalNullableFilter: DecimalNullableFilterType = graphql.inputObject({ +const DecimalNullableFilter: DecimalNullableFilterType = g.inputObject({ name: 'DecimalNullableFilter', fields: () => ({ - equals: graphql.arg({ type: graphql.Decimal }), // can be null - in: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.Decimal)) }), // can be null - notIn: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.Decimal)) }), // can be null - lt: graphql.arg({ type: graphql.Decimal }), - lte: graphql.arg({ type: graphql.Decimal }), - gt: graphql.arg({ type: graphql.Decimal }), - gte: graphql.arg({ type: graphql.Decimal }), - not: graphql.arg({ type: DecimalNullableFilter }), // can be null + equals: g.arg({ type: g.Decimal }), // can be null + in: g.arg({ type: g.list(g.nonNull(g.Decimal)) }), // can be null + notIn: g.arg({ type: g.list(g.nonNull(g.Decimal)) }), // can be null + lt: g.arg({ type: g.Decimal }), + lte: g.arg({ type: g.Decimal }), + gt: g.arg({ type: g.Decimal }), + gte: g.arg({ type: g.Decimal }), + not: g.arg({ type: DecimalNullableFilter }), // can be null }), }) -type DecimalFilterType = graphql.InputObjectType<{ - equals: graphql.Arg - in: graphql.Arg>> - notIn: graphql.Arg>> - lt: graphql.Arg - lte: graphql.Arg - gt: graphql.Arg - gte: graphql.Arg - not: graphql.Arg +type DecimalFilterType = g.InputObjectType<{ + equals: g.Arg + in: g.Arg>> + notIn: g.Arg>> + lt: g.Arg + lte: g.Arg + gt: g.Arg + gte: g.Arg + not: g.Arg }> -const DecimalFilter: DecimalFilterType = graphql.inputObject({ +const DecimalFilter: DecimalFilterType = g.inputObject({ name: 'DecimalFilter', fields: () => ({ - equals: graphql.arg({ type: graphql.Decimal }), - in: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.Decimal)) }), - notIn: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.Decimal)) }), - lt: graphql.arg({ type: graphql.Decimal }), - lte: graphql.arg({ type: graphql.Decimal }), - gt: graphql.arg({ type: graphql.Decimal }), - gte: graphql.arg({ type: graphql.Decimal }), - not: graphql.arg({ type: DecimalFilter }), + equals: g.arg({ type: g.Decimal }), + in: g.arg({ type: g.list(g.nonNull(g.Decimal)) }), + notIn: g.arg({ type: g.list(g.nonNull(g.Decimal)) }), + lt: g.arg({ type: g.Decimal }), + lte: g.arg({ type: g.Decimal }), + gt: g.arg({ type: g.Decimal }), + gte: g.arg({ type: g.Decimal }), + not: g.arg({ type: DecimalFilter }), }), }) -type BigIntNullableFilterType = graphql.InputObjectType<{ - equals: graphql.Arg // can be null - in: graphql.Arg>> // can be null - notIn: graphql.Arg>> // can be null - lt: graphql.Arg - lte: graphql.Arg - gt: graphql.Arg - gte: graphql.Arg - not: graphql.Arg // can be null +type BigIntNullableFilterType = g.InputObjectType<{ + equals: g.Arg // can be null + in: g.Arg>> // can be null + notIn: g.Arg>> // can be null + lt: g.Arg + lte: g.Arg + gt: g.Arg + gte: g.Arg + not: g.Arg // can be null }> -const BigIntNullableFilter: BigIntNullableFilterType = graphql.inputObject({ +const BigIntNullableFilter: BigIntNullableFilterType = g.inputObject({ name: 'BigIntNullableFilter', fields: () => ({ - equals: graphql.arg({ type: graphql.BigInt }), // can be null - in: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.BigInt)) }), // can be null - notIn: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.BigInt)) }), // can be null - lt: graphql.arg({ type: graphql.BigInt }), - lte: graphql.arg({ type: graphql.BigInt }), - gt: graphql.arg({ type: graphql.BigInt }), - gte: graphql.arg({ type: graphql.BigInt }), - not: graphql.arg({ type: BigIntNullableFilter }), // can be null + equals: g.arg({ type: g.BigInt }), // can be null + in: g.arg({ type: g.list(g.nonNull(g.BigInt)) }), // can be null + notIn: g.arg({ type: g.list(g.nonNull(g.BigInt)) }), // can be null + lt: g.arg({ type: g.BigInt }), + lte: g.arg({ type: g.BigInt }), + gt: g.arg({ type: g.BigInt }), + gte: g.arg({ type: g.BigInt }), + not: g.arg({ type: BigIntNullableFilter }), // can be null }), }) -type BigIntFilterType = graphql.InputObjectType<{ - equals: graphql.Arg - in: graphql.Arg>> - notIn: graphql.Arg>> - lt: graphql.Arg - lte: graphql.Arg - gt: graphql.Arg - gte: graphql.Arg - not: graphql.Arg +type BigIntFilterType = g.InputObjectType<{ + equals: g.Arg + in: g.Arg>> + notIn: g.Arg>> + lt: g.Arg + lte: g.Arg + gt: g.Arg + gte: g.Arg + not: g.Arg }> -const BigIntFilter: BigIntFilterType = graphql.inputObject({ +const BigIntFilter: BigIntFilterType = g.inputObject({ name: 'BigIntFilter', fields: () => ({ - equals: graphql.arg({ type: graphql.BigInt }), - in: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.BigInt)) }), - notIn: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.BigInt)) }), - lt: graphql.arg({ type: graphql.BigInt }), - lte: graphql.arg({ type: graphql.BigInt }), - gt: graphql.arg({ type: graphql.BigInt }), - gte: graphql.arg({ type: graphql.BigInt }), - not: graphql.arg({ type: BigIntFilter }), + equals: g.arg({ type: g.BigInt }), + in: g.arg({ type: g.list(g.nonNull(g.BigInt)) }), + notIn: g.arg({ type: g.list(g.nonNull(g.BigInt)) }), + lt: g.arg({ type: g.BigInt }), + lte: g.arg({ type: g.BigInt }), + gt: g.arg({ type: g.BigInt }), + gte: g.arg({ type: g.BigInt }), + not: g.arg({ type: BigIntFilter }), }), }) diff --git a/packages/core/src/fields/types/bigInt/index.ts b/packages/core/src/fields/types/bigInt/index.ts index fe7cba88177..8d243078fa4 100644 --- a/packages/core/src/fields/types/bigInt/index.ts +++ b/packages/core/src/fields/types/bigInt/index.ts @@ -5,7 +5,7 @@ import { fieldType, orderDirectionEnum, } from '../../../types' -import { graphql } from '../../..' +import { g } from '../../..' import { filters } from '../../filters' import { resolveDbNullable, @@ -124,14 +124,14 @@ export function bigInt (config: BigIntFi ...config, hooks: mergeFieldHooks({ validate }, config.hooks), input: { - uniqueWhere: isIndexed === 'unique' ? { arg: graphql.arg({ type: graphql.BigInt }) } : undefined, + uniqueWhere: isIndexed === 'unique' ? { arg: g.arg({ type: g.BigInt }) } : undefined, where: { - arg: graphql.arg({ type: filters[meta.provider].BigInt[mode] }), + arg: g.arg({ type: filters[meta.provider].BigInt[mode] }), resolve: mode === 'optional' ? filters.resolveCommon : undefined, }, create: { - arg: graphql.arg({ - type: graphql.BigInt, + arg: g.arg({ + type: g.BigInt, defaultValue: typeof defaultValue === 'bigint' ? defaultValue : undefined, }), resolve (value) { @@ -142,10 +142,10 @@ export function bigInt (config: BigIntFi return value }, }, - update: { arg: graphql.arg({ type: graphql.BigInt }) }, - orderBy: { arg: graphql.arg({ type: orderDirectionEnum }) }, + update: { arg: g.arg({ type: g.BigInt }) }, + orderBy: { arg: g.arg({ type: orderDirectionEnum }) }, }, - output: graphql.field({ type: graphql.BigInt, }), + output: g.field({ type: g.BigInt, }), __ksTelemetryFieldTypeName: '@keystone-6/bigInt', views: '@keystone-6/core/fields/types/bigInt/views', getAdminMeta () { diff --git a/packages/core/src/fields/types/calendarDay/index.ts b/packages/core/src/fields/types/calendarDay/index.ts index 4e541516ca5..b9705c505fa 100644 --- a/packages/core/src/fields/types/calendarDay/index.ts +++ b/packages/core/src/fields/types/calendarDay/index.ts @@ -6,7 +6,7 @@ import { orderDirectionEnum, } from '../../../types' import { type CalendarDayFieldMeta } from './views' -import { graphql } from '../../..' +import { g } from '../../..' import { filters } from '../../filters' import { makeValidateHook } from '../../non-null-graphql' import { mergeFieldHooks } from '../../resolve-hooks' @@ -34,7 +34,7 @@ export function calendarDay (config: Cal return (meta) => { if (typeof defaultValue === 'string') { try { - graphql.CalendarDay.graphQLType.parseValue(defaultValue) + g.CalendarDay.graphQLType.parseValue(defaultValue) } catch (err) { throw new Error( `The calendarDay field at ${meta.listKey}.${meta.fieldKey} specifies defaultValue: ${defaultValue} but values must be provided as a full-date ISO8601 string such as 1970-01-01` @@ -79,12 +79,12 @@ export function calendarDay (config: Cal uniqueWhere: isIndexed === 'unique' ? { - arg: graphql.arg({ type: graphql.CalendarDay }), + arg: g.arg({ type: g.CalendarDay }), resolve: usesNativeDateType ? dateStringToDateObjectInUTC : undefined, } : undefined, where: { - arg: graphql.arg({ + arg: g.arg({ type: mode === 'optional' ? CalendarDayNullableFilter : CalendarDayFilter, }), resolve: usesNativeDateType @@ -92,8 +92,8 @@ export function calendarDay (config: Cal : commonResolveFilter, }, create: { - arg: graphql.arg({ - type: graphql.CalendarDay, + arg: g.arg({ + type: g.CalendarDay, defaultValue, }), resolve (val: string | null | undefined) { @@ -103,11 +103,11 @@ export function calendarDay (config: Cal return resolveInput(val) }, }, - update: { arg: graphql.arg({ type: graphql.CalendarDay }), resolve: resolveInput }, - orderBy: { arg: graphql.arg({ type: orderDirectionEnum }) }, + update: { arg: g.arg({ type: g.CalendarDay }), resolve: resolveInput }, + orderBy: { arg: g.arg({ type: orderDirectionEnum }) }, }, - output: graphql.field({ - type: graphql.CalendarDay, + output: g.field({ + type: g.CalendarDay, resolve ({ value }) { if (value instanceof Date) { return value.toISOString().slice(0, 10) @@ -131,19 +131,19 @@ function dateStringToDateObjectInUTC (value: string) { return new Date(`${value}T00:00Z`) } -type CalendarDayFilterType = graphql.InputObjectType<{ - equals: graphql.Arg - in: graphql.Arg>> - notIn: graphql.Arg>> - lt: graphql.Arg - lte: graphql.Arg - gt: graphql.Arg - gte: graphql.Arg - not: graphql.Arg +type CalendarDayFilterType = g.InputObjectType<{ + equals: g.Arg + in: g.Arg>> + notIn: g.Arg>> + lt: g.Arg + lte: g.Arg + gt: g.Arg + gte: g.Arg + not: g.Arg }> function transformFilterDateStringsToDateObjects ( - filter: graphql.InferValueFromInputType + filter: g.InferValueFromInputType ): Parameters[0] { if (filter === null) { return filter @@ -165,22 +165,22 @@ function transformFilterDateStringsToDateObjects ( } const filterFields = (nestedType: CalendarDayFilterType) => ({ - equals: graphql.arg({ type: graphql.CalendarDay }), - in: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.CalendarDay)) }), - notIn: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.CalendarDay)) }), - lt: graphql.arg({ type: graphql.CalendarDay }), - lte: graphql.arg({ type: graphql.CalendarDay }), - gt: graphql.arg({ type: graphql.CalendarDay }), - gte: graphql.arg({ type: graphql.CalendarDay }), - not: graphql.arg({ type: nestedType }), + equals: g.arg({ type: g.CalendarDay }), + in: g.arg({ type: g.list(g.nonNull(g.CalendarDay)) }), + notIn: g.arg({ type: g.list(g.nonNull(g.CalendarDay)) }), + lt: g.arg({ type: g.CalendarDay }), + lte: g.arg({ type: g.CalendarDay }), + gt: g.arg({ type: g.CalendarDay }), + gte: g.arg({ type: g.CalendarDay }), + not: g.arg({ type: nestedType }), }) -const CalendarDayNullableFilter: CalendarDayFilterType = graphql.inputObject({ +const CalendarDayNullableFilter: CalendarDayFilterType = g.inputObject({ name: 'CalendarDayNullableFilter', fields: () => filterFields(CalendarDayNullableFilter), }) -const CalendarDayFilter: CalendarDayFilterType = graphql.inputObject({ +const CalendarDayFilter: CalendarDayFilterType = g.inputObject({ name: 'CalendarDayFilter', fields: () => filterFields(CalendarDayFilter), }) diff --git a/packages/core/src/fields/types/checkbox/index.ts b/packages/core/src/fields/types/checkbox/index.ts index 117ba249b94..87dafe7e91c 100644 --- a/packages/core/src/fields/types/checkbox/index.ts +++ b/packages/core/src/fields/types/checkbox/index.ts @@ -6,7 +6,7 @@ import { fieldType, orderDirectionEnum, } from '../../../types' -import { graphql } from '../../..' +import { g } from '../../..' import { assertReadIsNonNullAllowed } from '../../non-null-graphql' import { filters } from '../../filters' @@ -43,10 +43,10 @@ export function checkbox ( })({ ...config, input: { - where: { arg: graphql.arg({ type: filters[meta.provider].Boolean.required }) }, + where: { arg: g.arg({ type: filters[meta.provider].Boolean.required }) }, create: { - arg: graphql.arg({ - type: graphql.Boolean, + arg: g.arg({ + type: g.Boolean, defaultValue: typeof defaultValue === 'boolean' ? defaultValue : undefined, }), resolve (val) { @@ -55,15 +55,15 @@ export function checkbox ( }, }, update: { - arg: graphql.arg({ type: graphql.Boolean }), + arg: g.arg({ type: g.Boolean }), resolve (val) { if (val === null) throw userInputError('Checkbox fields cannot be set to null') return val }, }, - orderBy: { arg: graphql.arg({ type: orderDirectionEnum }) }, + orderBy: { arg: g.arg({ type: orderDirectionEnum }) }, }, - output: graphql.field({ type: graphql.Boolean, }), + output: g.field({ type: g.Boolean, }), __ksTelemetryFieldTypeName: '@keystone-6/checkbox', views: '@keystone-6/core/fields/types/checkbox/views', getAdminMeta: () => ({ defaultValue }), diff --git a/packages/core/src/fields/types/decimal/index.ts b/packages/core/src/fields/types/decimal/index.ts index a7e62cc6e8d..669b484d2ee 100644 --- a/packages/core/src/fields/types/decimal/index.ts +++ b/packages/core/src/fields/types/decimal/index.ts @@ -6,7 +6,7 @@ import { orderDirectionEnum, Decimal, } from '../../../types' -import { graphql } from '../../..' +import { g } from '../../..' import { filters } from '../../filters' import { makeValidateHook } from '../../non-null-graphql' import { mergeFieldHooks } from '../../resolve-hooks' @@ -126,14 +126,14 @@ export function decimal (config: Decimal ...config, hooks: mergeFieldHooks({ validate }, config.hooks), input: { - uniqueWhere: isIndexed === 'unique' ? { arg: graphql.arg({ type: graphql.Decimal }) } : undefined, + uniqueWhere: isIndexed === 'unique' ? { arg: g.arg({ type: g.Decimal }) } : undefined, where: { - arg: graphql.arg({ type: filters[meta.provider].Decimal[mode] }), + arg: g.arg({ type: filters[meta.provider].Decimal[mode] }), resolve: mode === 'optional' ? filters.resolveCommon : undefined, }, create: { - arg: graphql.arg({ - type: graphql.Decimal, + arg: g.arg({ + type: g.Decimal, defaultValue: parsedDefaultValue, }), resolve (val) { @@ -141,11 +141,11 @@ export function decimal (config: Decimal return val }, }, - update: { arg: graphql.arg({ type: graphql.Decimal }), }, - orderBy: { arg: graphql.arg({ type: orderDirectionEnum }) }, + update: { arg: g.arg({ type: g.Decimal }), }, + orderBy: { arg: g.arg({ type: orderDirectionEnum }) }, }, - output: graphql.field({ - type: graphql.Decimal, + output: g.field({ + type: g.Decimal, resolve ({ value }) { if (value === null) return null const val: Decimal & { scaleToPrint?: number } = new Decimal(value) diff --git a/packages/core/src/fields/types/file/index.ts b/packages/core/src/fields/types/file/index.ts index 021f7939d9e..a8471cabfd7 100644 --- a/packages/core/src/fields/types/file/index.ts +++ b/packages/core/src/fields/types/file/index.ts @@ -6,7 +6,7 @@ import { type FileMetadata, fieldType, } from '../../../types' -import { graphql } from '../../..' +import { g } from '../../..' import { type InternalFieldHooks, mergeFieldHooks, @@ -20,22 +20,22 @@ export type FileFieldConfig = } } -const FileFieldInput = graphql.inputObject({ +const FileFieldInput = g.inputObject({ name: 'FileFieldInput', fields: { - upload: graphql.arg({ type: graphql.nonNull(graphql.Upload) }), + upload: g.arg({ type: g.nonNull(g.Upload) }), }, }) -const inputArg = graphql.arg({ type: FileFieldInput }) +const inputArg = g.arg({ type: FileFieldInput }) -const FileFieldOutput = graphql.object()({ +const FileFieldOutput = g.object()({ name: 'FileFieldOutput', fields: { - filename: graphql.field({ type: graphql.nonNull(graphql.String) }), - filesize: graphql.field({ type: graphql.nonNull(graphql.Int) }), - url: graphql.field({ - type: graphql.nonNull(graphql.String), + filename: g.field({ type: g.nonNull(g.String) }), + filesize: g.field({ type: g.nonNull(g.Int) }), + url: g.field({ + type: g.nonNull(g.String), resolve (data, args, context) { return context.files(data.storage).getUrl(data.filename) }, @@ -45,7 +45,7 @@ const FileFieldOutput = graphql.object()({ async function inputResolver ( storage: string, - data: graphql.InferValueFromArg, + data: g.InferValueFromArg, context: KeystoneContext ) { if (data === null || data === undefined) return { filename: data, filesize: data } @@ -107,7 +107,7 @@ export function file (config: FileFieldC resolve: (data, context) => inputResolver(config.storage, data, context), }, }, - output: graphql.field({ + output: g.field({ type: FileFieldOutput, resolve ({ value: { filesize, filename } }) { if (filename === null) return null diff --git a/packages/core/src/fields/types/float/index.ts b/packages/core/src/fields/types/float/index.ts index c3d8b341d59..29ceb0048a8 100644 --- a/packages/core/src/fields/types/float/index.ts +++ b/packages/core/src/fields/types/float/index.ts @@ -5,7 +5,7 @@ import { fieldType, orderDirectionEnum, } from '../../../types' -import { graphql } from '../../..' +import { g } from '../../..' import { filters } from '../../filters' import { makeValidateHook } from '../../non-null-graphql' import { mergeFieldHooks } from '../../resolve-hooks' @@ -92,14 +92,14 @@ export function float (config: FloatFiel ...config, hooks: mergeFieldHooks({ validate }, config.hooks), input: { - uniqueWhere: isIndexed === 'unique' ? { arg: graphql.arg({ type: graphql.Float }) } : undefined, + uniqueWhere: isIndexed === 'unique' ? { arg: g.arg({ type: g.Float }) } : undefined, where: { - arg: graphql.arg({ type: filters[meta.provider].Float[mode] }), + arg: g.arg({ type: filters[meta.provider].Float[mode] }), resolve: mode === 'optional' ? filters.resolveCommon : undefined, }, create: { - arg: graphql.arg({ - type: graphql.Float, + arg: g.arg({ + type: g.Float, defaultValue: typeof defaultValue === 'number' ? defaultValue : undefined, }), resolve (value) { @@ -107,10 +107,10 @@ export function float (config: FloatFiel return value }, }, - update: { arg: graphql.arg({ type: graphql.Float }) }, - orderBy: { arg: graphql.arg({ type: orderDirectionEnum }) }, + update: { arg: g.arg({ type: g.Float }) }, + orderBy: { arg: g.arg({ type: orderDirectionEnum }) }, }, - output: graphql.field({ type: graphql.Float, }), + output: g.field({ type: g.Float, }), __ksTelemetryFieldTypeName: '@keystone-6/float', views: '@keystone-6/core/fields/types/float/views', getAdminMeta () { diff --git a/packages/core/src/fields/types/image/index.ts b/packages/core/src/fields/types/image/index.ts index d555974af63..2d1f087207d 100644 --- a/packages/core/src/fields/types/image/index.ts +++ b/packages/core/src/fields/types/image/index.ts @@ -7,7 +7,7 @@ import type { KeystoneContext, } from '../../../types' import { fieldType, } from '../../../types' -import { graphql } from '../../..' +import { g } from '../../..' import { SUPPORTED_IMAGE_EXTENSIONS } from './utils' import { type InternalFieldHooks, @@ -23,40 +23,40 @@ export type ImageFieldConfig = } // TODO: dynamic -const ImageExtensionEnum = graphql.enum({ +const ImageExtensionEnum = g.enum({ name: 'ImageExtension', - values: graphql.enumValues(SUPPORTED_IMAGE_EXTENSIONS), + values: g.enumValues(SUPPORTED_IMAGE_EXTENSIONS), }) -const ImageFieldInput = graphql.inputObject({ +const ImageFieldInput = g.inputObject({ name: 'ImageFieldInput', fields: { - upload: graphql.arg({ type: graphql.nonNull(graphql.Upload) }), + upload: g.arg({ type: g.nonNull(g.Upload) }), }, }) -const inputArg = graphql.arg({ type: ImageFieldInput }) +const inputArg = g.arg({ type: ImageFieldInput }) -const ImageFieldOutput = graphql.object()({ +const ImageFieldOutput = g.object()({ name: 'ImageFieldOutput', fields: { - id: graphql.field({ type: graphql.nonNull(graphql.ID) }), - url: graphql.field({ - type: graphql.nonNull(graphql.String), + id: g.field({ type: g.nonNull(g.ID) }), + url: g.field({ + type: g.nonNull(g.String), resolve (data, args, context) { return context.images(data.storage).getUrl(data.id, data.extension) }, }), - extension: graphql.field({ type: graphql.nonNull(ImageExtensionEnum) }), - filesize: graphql.field({ type: graphql.nonNull(graphql.Int) }), - width: graphql.field({ type: graphql.nonNull(graphql.Int) }), - height: graphql.field({ type: graphql.nonNull(graphql.Int) }), + extension: g.field({ type: g.nonNull(ImageExtensionEnum) }), + filesize: g.field({ type: g.nonNull(g.Int) }), + width: g.field({ type: g.nonNull(g.Int) }), + height: g.field({ type: g.nonNull(g.Int) }), }, }) async function inputResolver ( storage: string, - data: graphql.InferValueFromArg, + data: g.InferValueFromArg, context: KeystoneContext ) { if (data === null || data === undefined) { @@ -140,7 +140,7 @@ export function image (config: ImageFiel resolve: (data, context) => inputResolver(config.storage, data, context), }, }, - output: graphql.field({ + output: g.field({ type: ImageFieldOutput, resolve ({ value: { diff --git a/packages/core/src/fields/types/integer/index.ts b/packages/core/src/fields/types/integer/index.ts index d9e13abecf1..9d531cd6741 100644 --- a/packages/core/src/fields/types/integer/index.ts +++ b/packages/core/src/fields/types/integer/index.ts @@ -5,7 +5,7 @@ import { fieldType, orderDirectionEnum, } from '../../../types' -import { graphql } from '../../..' +import { g } from '../../..' import { filters } from '../../filters' import { resolveDbNullable, @@ -120,14 +120,14 @@ export function integer (config: Integer ...config, hooks: mergeFieldHooks({ validate }, config.hooks), input: { - uniqueWhere: isIndexed === 'unique' ? { arg: graphql.arg({ type: graphql.Int }) } : undefined, + uniqueWhere: isIndexed === 'unique' ? { arg: g.arg({ type: g.Int }) } : undefined, where: { - arg: graphql.arg({ type: filters[meta.provider].Int[mode] }), + arg: g.arg({ type: filters[meta.provider].Int[mode] }), resolve: mode === 'optional' ? filters.resolveCommon : undefined, }, create: { - arg: graphql.arg({ - type: graphql.Int, + arg: g.arg({ + type: g.Int, defaultValue: typeof defaultValue === 'number' ? defaultValue : undefined, }), resolve (value) { @@ -138,10 +138,10 @@ export function integer (config: Integer return value }, }, - update: { arg: graphql.arg({ type: graphql.Int }) }, - orderBy: { arg: graphql.arg({ type: orderDirectionEnum }) }, + update: { arg: g.arg({ type: g.Int }) }, + orderBy: { arg: g.arg({ type: orderDirectionEnum }) }, }, - output: graphql.field({ type: graphql.Int, }), + output: g.field({ type: g.Int, }), __ksTelemetryFieldTypeName: '@keystone-6/integer', views: '@keystone-6/core/fields/types/integer/views', getAdminMeta () { diff --git a/packages/core/src/fields/types/json/index.ts b/packages/core/src/fields/types/json/index.ts index da6406917ec..21de13332d0 100644 --- a/packages/core/src/fields/types/json/index.ts +++ b/packages/core/src/fields/types/json/index.ts @@ -5,7 +5,7 @@ import { type CommonFieldConfig, jsonFieldTypePolyfilledForSQLite, } from '../../../types' -import { graphql } from '../../..' +import { g } from '../../..' export type JsonFieldConfig = CommonFieldConfig & { @@ -30,14 +30,14 @@ export const json = __ksTelemetryFieldTypeName: '@keystone-6/json', input: { create: { - arg: graphql.arg({ type: graphql.JSON }), + arg: g.arg({ type: g.JSON }), resolve (val) { return val === undefined ? defaultValue : val }, }, - update: { arg: graphql.arg({ type: graphql.JSON }) }, + update: { arg: g.arg({ type: g.JSON }) }, }, - output: graphql.field({ type: graphql.JSON }), + output: g.field({ type: g.JSON }), views: '@keystone-6/core/fields/types/json/views', getAdminMeta: () => ({ defaultValue }), }, diff --git a/packages/core/src/fields/types/multiselect/index.ts b/packages/core/src/fields/types/multiselect/index.ts index 258535f2cb3..53025a03917 100644 --- a/packages/core/src/fields/types/multiselect/index.ts +++ b/packages/core/src/fields/types/multiselect/index.ts @@ -7,7 +7,7 @@ import { type FieldData, jsonFieldTypePolyfilledForSQLite, } from '../../../types' -import { graphql } from '../../..' +import { g } from '../../..' import { makeValidateHook } from '../../non-null-graphql' import { mergeFieldHooks } from '../../resolve-hooks' @@ -63,9 +63,9 @@ export function multiselect ( throw TypeError("isIndexed: 'unique' is not a supported option for field type multiselect") } - const output = (type: T) => nonNullList(type) - const create = (type: T) => { - return graphql.arg({ type: nonNullList(type) }) + const output = (type: T) => nonNullList(type) + const create = (type: T) => { + return g.arg({ type: nonNullList(type) }) } const resolveCreate = (val: T[] | null | undefined): T[] | null => { @@ -124,11 +124,11 @@ export function multiselect ( input: { create: { arg: create(transformedConfig.graphqlType), resolve: resolveCreate }, update: { - arg: graphql.arg({ type: nonNullList(transformedConfig.graphqlType) }), + arg: g.arg({ type: nonNullList(transformedConfig.graphqlType) }), resolve: resolveUpdate, }, }, - output: graphql.field({ + output: g.field({ type: output(transformedConfig.graphqlType), resolve ({ value }) { return value as any @@ -162,7 +162,7 @@ function configToOptionsAndGraphQLType ( } return { type: 'integer' as const, - graphqlType: graphql.Int, + graphqlType: g.Int, options: config.options, } } @@ -179,9 +179,9 @@ function configToOptionsAndGraphQLType ( if (config.type === 'enum') { const enumName = `${meta.listKey}${classify(meta.fieldKey)}Type` - const graphqlType = graphql.enum({ + const graphqlType = g.enum({ name: enumName, - values: graphql.enumValues(options.map(x => x.value)), + values: g.enumValues(options.map(x => x.value)), }) return { type: 'enum' as const, @@ -191,9 +191,9 @@ function configToOptionsAndGraphQLType ( } return { type: 'string' as const, - graphqlType: graphql.String, + graphqlType: g.String, options, } } -const nonNullList = (type: T) => graphql.list(graphql.nonNull(type)) +const nonNullList = (type: T) => g.list(g.nonNull(type)) diff --git a/packages/core/src/fields/types/password/index.ts b/packages/core/src/fields/types/password/index.ts index 02f392c72cc..c7c20fc30ba 100644 --- a/packages/core/src/fields/types/password/index.ts +++ b/packages/core/src/fields/types/password/index.ts @@ -8,7 +8,7 @@ import { type FieldTypeFunc, fieldType, } from '../../../types' -import { graphql } from '../../..' +import { g } from '../../..' import { type PasswordFieldMeta } from './views' import { makeValidateHook } from '../../non-null-graphql' import { mergeFieldHooks } from '../../resolve-hooks' @@ -37,17 +37,17 @@ export type PasswordFieldConfig = bcrypt?: Pick } -const PasswordState = graphql.object<{ isSet: boolean }>()({ +const PasswordState = g.object<{ isSet: boolean }>()({ name: 'PasswordState', fields: { - isSet: graphql.field({ type: graphql.nonNull(graphql.Boolean) }), + isSet: g.field({ type: g.nonNull(g.Boolean) }), }, }) -const PasswordFilter = graphql.inputObject({ +const PasswordFilter = g.inputObject({ name: 'PasswordFilter', fields: { - isSet: graphql.arg({ type: graphql.nonNull(graphql.Boolean) }), + isSet: g.arg({ type: g.nonNull(g.Boolean) }), }, }) @@ -143,7 +143,7 @@ export function password (config: Passwo mode === 'required' ? undefined : { - arg: graphql.arg({ type: PasswordFilter }), + arg: g.arg({ type: PasswordFilter }), resolve (val) { if (val === null) throw userInputError('Password filters cannot be set to null') if (val.isSet) return { not: null } @@ -151,14 +151,14 @@ export function password (config: Passwo }, }, create: { - arg: graphql.arg({ type: graphql.String }), + arg: g.arg({ type: g.String }), resolve (val) { if (val === undefined) return null return inputResolver(val) }, }, update: { - arg: graphql.arg({ type: graphql.String }), + arg: g.arg({ type: g.String }), resolve: inputResolver, }, }, @@ -182,7 +182,7 @@ export function password (config: Passwo }, }, }), - output: graphql.field({ + output: g.field({ type: PasswordState, resolve (val) { return { isSet: val.value !== null && bcryptHashRegex.test(val.value) } diff --git a/packages/core/src/fields/types/relationship/index.ts b/packages/core/src/fields/types/relationship/index.ts index 25556e62463..9c2b323d6ff 100644 --- a/packages/core/src/fields/types/relationship/index.ts +++ b/packages/core/src/fields/types/relationship/index.ts @@ -4,7 +4,7 @@ import { type CommonFieldConfig, fieldType } from '../../../types' -import { graphql } from '../../..' +import { g } from '../../..' import { type ListMetaRootVal, getAdminMetaForRelationshipField @@ -151,37 +151,37 @@ export function relationship ({ ...commonConfig, input: { where: { - arg: graphql.arg({ type: foreignListTypes.relateTo.many.where }), + arg: g.arg({ type: foreignListTypes.relateTo.many.where }), resolve (value, context, resolve) { return resolve(value) }, }, create: { - arg: graphql.arg({ type: foreignListTypes.relateTo.many.create }), + arg: g.arg({ type: foreignListTypes.relateTo.many.create }), async resolve (value, context, resolve) { return resolve(value) }, }, update: { - arg: graphql.arg({ type: foreignListTypes.relateTo.many.update }), + arg: g.arg({ type: foreignListTypes.relateTo.many.update }), async resolve (value, context, resolve) { return resolve(value) }, }, }, - output: graphql.field({ + output: g.field({ args: foreignListTypes.findManyArgs, - type: graphql.list(graphql.nonNull(foreignListTypes.output)), + type: g.list(g.nonNull(foreignListTypes.output)), resolve ({ value }, args) { return value.findMany(args) }, }), extraOutputFields: { - [`${fieldKey}Count`]: graphql.field({ - type: graphql.Int, + [`${fieldKey}Count`]: g.field({ + type: g.Int, args: { - where: graphql.arg({ - type: graphql.nonNull(foreignListTypes.where), + where: g.arg({ + type: g.nonNull(foreignListTypes.where), defaultValue: {}, }), }, @@ -206,26 +206,26 @@ export function relationship ({ ...commonConfig, input: { where: { - arg: graphql.arg({ type: foreignListTypes.where }), + arg: g.arg({ type: foreignListTypes.where }), resolve (value, context, resolve) { return resolve(value) }, }, create: foreignListTypes.relateTo.one.create && { - arg: graphql.arg({ type: foreignListTypes.relateTo.one.create }), + arg: g.arg({ type: foreignListTypes.relateTo.one.create }), async resolve (value, context, resolve) { return resolve(value) }, }, update: foreignListTypes.relateTo.one.update && { - arg: graphql.arg({ type: foreignListTypes.relateTo.one.update }), + arg: g.arg({ type: foreignListTypes.relateTo.one.update }), async resolve (value, context, resolve) { return resolve(value) }, }, }, - output: graphql.field({ + output: g.field({ type: foreignListTypes.output, resolve ({ value }) { return value() diff --git a/packages/core/src/fields/types/select/index.ts b/packages/core/src/fields/types/select/index.ts index eb3d14543a0..eaf7f4e61c5 100644 --- a/packages/core/src/fields/types/select/index.ts +++ b/packages/core/src/fields/types/select/index.ts @@ -7,7 +7,7 @@ import { fieldType, orderDirectionEnum, } from '../../../types' -import { graphql } from '../../..' +import { g } from '../../..' import { filters } from '../../filters' import { makeValidateHook } from '../../non-null-graphql' import { mergeFieldHooks } from '../../resolve-hooks' @@ -140,22 +140,22 @@ export function select (config: SelectFi })({ ...commonConfig, input: { - uniqueWhere: isIndexed === 'unique' ? { arg: graphql.arg({ type: graphql.Int }) } : undefined, + uniqueWhere: isIndexed === 'unique' ? { arg: g.arg({ type: g.Int }) } : undefined, where: { - arg: graphql.arg({ type: filters[meta.provider].Int[mode] }), + arg: g.arg({ type: filters[meta.provider].Int[mode] }), resolve: mode === 'required' ? undefined : filters.resolveCommon, }, create: { - arg: graphql.arg({ - type: graphql.Int, + arg: g.arg({ + type: g.Int, defaultValue: typeof defaultValue === 'number' ? defaultValue : undefined, }), resolve: resolveCreate, }, - update: { arg: graphql.arg({ type: graphql.Int }) }, - orderBy: { arg: graphql.arg({ type: orderDirectionEnum }) }, + update: { arg: g.arg({ type: g.Int }) }, + orderBy: { arg: g.arg({ type: orderDirectionEnum }) }, }, - output: graphql.field({ type: graphql.Int }), + output: g.field({ type: g.Int }), }) } @@ -163,9 +163,9 @@ export function select (config: SelectFi const enumName = `${meta.listKey}${classify(meta.fieldKey)}Type` const enumValues = options.map(x => `${x.value}`) - const graphQLType = graphql.enum({ + const graphQLType = g.enum({ name: enumName, - values: graphql.enumValues(enumValues), + values: g.enumValues(enumValues), }) return fieldType( meta.provider === 'sqlite' @@ -180,22 +180,22 @@ export function select (config: SelectFi ...commonConfig, input: { uniqueWhere: - isIndexed === 'unique' ? { arg: graphql.arg({ type: graphQLType }) } : undefined, + isIndexed === 'unique' ? { arg: g.arg({ type: graphQLType }) } : undefined, where: { - arg: graphql.arg({ type: filters[meta.provider].enum(graphQLType).optional }), + arg: g.arg({ type: filters[meta.provider].enum(graphQLType).optional }), resolve: mode === 'required' ? undefined : filters.resolveCommon, }, create: { - arg: graphql.arg({ + arg: g.arg({ type: graphQLType, defaultValue: typeof defaultValue === 'string' ? defaultValue : undefined, }), resolve: resolveCreate, }, - update: { arg: graphql.arg({ type: graphQLType }) }, - orderBy: { arg: graphql.arg({ type: orderDirectionEnum }) }, + update: { arg: g.arg({ type: graphQLType }) }, + orderBy: { arg: g.arg({ type: orderDirectionEnum }) }, }, - output: graphql.field({ type: graphQLType }), + output: g.field({ type: graphQLType }), }) } @@ -203,22 +203,22 @@ export function select (config: SelectFi ...commonConfig, input: { uniqueWhere: - isIndexed === 'unique' ? { arg: graphql.arg({ type: graphql.String }) } : undefined, + isIndexed === 'unique' ? { arg: g.arg({ type: g.String }) } : undefined, where: { - arg: graphql.arg({ type: filters[meta.provider].String[mode] }), + arg: g.arg({ type: filters[meta.provider].String[mode] }), resolve: mode === 'required' ? undefined : filters.resolveString, }, create: { - arg: graphql.arg({ - type: graphql.String, + arg: g.arg({ + type: g.String, defaultValue: typeof defaultValue === 'string' ? defaultValue : undefined, }), resolve: resolveCreate, }, - update: { arg: graphql.arg({ type: graphql.String }) }, - orderBy: { arg: graphql.arg({ type: orderDirectionEnum }) }, + update: { arg: g.arg({ type: g.String }) }, + orderBy: { arg: g.arg({ type: orderDirectionEnum }) }, }, - output: graphql.field({ type: graphql.String }), + output: g.field({ type: g.String }), }) } } diff --git a/packages/core/src/fields/types/text/index.ts b/packages/core/src/fields/types/text/index.ts index 426908a2763..a02ef3d9636 100644 --- a/packages/core/src/fields/types/text/index.ts +++ b/packages/core/src/fields/types/text/index.ts @@ -5,7 +5,7 @@ import { fieldType, orderDirectionEnum, } from '../../../types' -import { graphql } from '../../..' +import { g } from '../../..' import { makeValidateHook } from '../../non-null-graphql' import { filters } from '../../filters' import { mergeFieldHooks } from '../../resolve-hooks' @@ -144,16 +144,16 @@ export function text ( ...config, hooks: mergeFieldHooks({ validate }, config.hooks), input: { - uniqueWhere: isIndexed === 'unique' ? { arg: graphql.arg({ type: graphql.String }) } : undefined, + uniqueWhere: isIndexed === 'unique' ? { arg: g.arg({ type: g.String }) } : undefined, where: { - arg: graphql.arg({ + arg: g.arg({ type: filters[meta.provider].String[mode], }), resolve: mode === 'required' ? undefined : filters.resolveString, }, create: { - arg: graphql.arg({ - type: graphql.String, + arg: g.arg({ + type: g.String, defaultValue: typeof defaultValue === 'string' ? defaultValue : undefined, }), resolve (val) { @@ -161,11 +161,11 @@ export function text ( return defaultValue ?? null }, }, - update: { arg: graphql.arg({ type: graphql.String }) }, - orderBy: { arg: graphql.arg({ type: orderDirectionEnum }) }, + update: { arg: g.arg({ type: g.String }) }, + orderBy: { arg: g.arg({ type: orderDirectionEnum }) }, }, - output: graphql.field({ - type: graphql.String, + output: g.field({ + type: g.String, }), __ksTelemetryFieldTypeName: '@keystone-6/text', views: '@keystone-6/core/fields/types/text/views', diff --git a/packages/core/src/fields/types/timestamp/index.ts b/packages/core/src/fields/types/timestamp/index.ts index d2cdd55d8ac..9aed981f77f 100644 --- a/packages/core/src/fields/types/timestamp/index.ts +++ b/packages/core/src/fields/types/timestamp/index.ts @@ -5,7 +5,7 @@ import { fieldType, orderDirectionEnum, } from '../../../types' -import { graphql } from '../../..' +import { g } from '../../..' import { filters } from '../../filters' import { makeValidateHook } from '../../non-null-graphql' import { mergeFieldHooks } from '../../resolve-hooks' @@ -39,7 +39,7 @@ export function timestamp ( return (meta) => { if (typeof defaultValue === 'string') { try { - graphql.DateTime.graphQLType.parseValue(defaultValue) + g.DateTime.graphQLType.parseValue(defaultValue) } catch (err) { throw new Error(`${meta.listKey}.${meta.fieldKey}.defaultValue is required to be an ISO8601 date-time string such as ${new Date().toISOString()}`) } @@ -47,7 +47,7 @@ export function timestamp ( const parsedDefaultValue = typeof defaultValue === 'string' - ? (graphql.DateTime.graphQLType.parseValue(defaultValue) as Date) + ? (g.DateTime.graphQLType.parseValue(defaultValue) as Date) : defaultValue const { mode, @@ -75,14 +75,14 @@ export function timestamp ( ...config, hooks: mergeFieldHooks({ validate }, config.hooks), input: { - uniqueWhere: isIndexed === 'unique' ? { arg: graphql.arg({ type: graphql.DateTime }) } : undefined, + uniqueWhere: isIndexed === 'unique' ? { arg: g.arg({ type: g.DateTime }) } : undefined, where: { - arg: graphql.arg({ type: filters[meta.provider].DateTime[mode] }), + arg: g.arg({ type: filters[meta.provider].DateTime[mode] }), resolve: mode === 'optional' ? filters.resolveCommon : undefined, }, create: { - arg: graphql.arg({ - type: graphql.DateTime, + arg: g.arg({ + type: g.DateTime, // TODO: add support for defaultValue of { kind: 'now' } in the GraphQL API defaultValue: parsedDefaultValue instanceof Date ? parsedDefaultValue : undefined, }), @@ -98,10 +98,10 @@ export function timestamp ( return val }, }, - update: { arg: graphql.arg({ type: graphql.DateTime }) }, - orderBy: { arg: graphql.arg({ type: orderDirectionEnum }) }, + update: { arg: g.arg({ type: g.DateTime }) }, + orderBy: { arg: g.arg({ type: orderDirectionEnum }) }, }, - output: graphql.field({ type: graphql.DateTime }), + output: g.field({ type: g.DateTime }), __ksTelemetryFieldTypeName: '@keystone-6/timestamp', views: '@keystone-6/core/fields/types/timestamp/views', getAdminMeta (): TimestampFieldMeta { diff --git a/packages/core/src/fields/types/virtual/index.ts b/packages/core/src/fields/types/virtual/index.ts index e6089feb49c..acb857bf754 100644 --- a/packages/core/src/fields/types/virtual/index.ts +++ b/packages/core/src/fields/types/virtual/index.ts @@ -8,19 +8,19 @@ import { type ListGraphQLTypes, fieldType, } from '../../../types' -import { graphql } from '../../..' +import { g } from '../../..' type VirtualFieldGraphQLField< Item extends BaseItem, Context extends KeystoneContext -> = graphql.Field +> = g.Field export type VirtualFieldConfig = CommonFieldConfig & { field: | VirtualFieldGraphQLField> | ((lists: Record) => VirtualFieldGraphQLField>) - unreferencedConcreteInterfaceImplementations?: readonly graphql.ObjectType[] + unreferencedConcreteInterfaceImplementations?: readonly g.ObjectType[] ui?: { /** * This can be used by the AdminUI to fetch the relevant sub-fields @@ -47,7 +47,7 @@ export function virtual ({ const hasRequiredArgs = usableField.args && Object.values( - usableField.args as Record> + usableField.args as Record> ).some(x => x.type.kind === 'non-null' && x.defaultValue === undefined) if ( @@ -60,7 +60,7 @@ export function virtual ({ return fieldType({ kind: 'none', })({ ...config, - output: graphql.field({ + output: g.field({ ...(usableField as any), resolve ({ item }, ...args) { return usableField.resolve!(item, ...args) diff --git a/packages/core/src/lib/core/field-assertions.ts b/packages/core/src/lib/core/field-assertions.ts index da19b10d3c6..c68536187ee 100644 --- a/packages/core/src/lib/core/field-assertions.ts +++ b/packages/core/src/lib/core/field-assertions.ts @@ -1,4 +1,4 @@ -import { graphql } from '../..' +import { g } from '../..' import { allowAll } from '../../access' import type { InitialisedField } from './initialise-lists' @@ -84,7 +84,7 @@ function assertIdFieldGraphQLTypesCorrect (list: ListForValidation) { `The idField on a list must define a uniqueWhere GraphQL input with the ID GraphQL scalar type but the idField for ${list.listKey} does not define one` ) } - if (idField.input.uniqueWhere.arg.type !== graphql.ID) { + if (idField.input.uniqueWhere.arg.type !== g.ID) { throw new Error( `The idField on a list must define a uniqueWhere GraphQL input with the ID GraphQL scalar type but the idField for ${ list.listKey @@ -107,7 +107,7 @@ function assertIdFieldGraphQLTypesCorrect (list: ListForValidation) { `The idField on a list must not have graphql.isEnabled.read be set to false but ${list.listKey} does` ) } - if (idField.output.type.kind !== 'non-null' || idField.output.type.of !== graphql.ID) { + if (idField.output.type.kind !== 'non-null' || idField.output.type.of !== g.ID) { throw new Error( `The idField on a list must define a GraphQL output field with a non-nullable ID GraphQL scalar type but the idField for ${ list.listKey diff --git a/packages/core/src/lib/core/initialise-lists.ts b/packages/core/src/lib/core/initialise-lists.ts index 4c515aba1e6..cf22a1e09f0 100644 --- a/packages/core/src/lib/core/initialise-lists.ts +++ b/packages/core/src/lib/core/initialise-lists.ts @@ -18,7 +18,7 @@ import { type GraphQLNames, __getNames, } from '../../types/utils' -import { graphql } from '../..' +import { g } from '../..' import type { FieldHooks, ResolvedListHooks, @@ -390,7 +390,7 @@ function getListsWithInitialisedFields ( graphql: { names }, } = __getNames(listKey, listConfig) - const output = graphql.object()({ + const output = g.object()({ name: names.outputTypeName, fields: () => { const { fields } = listsRef[listKey] @@ -429,7 +429,7 @@ function getListsWithInitialisedFields ( }, }) - const uniqueWhere = graphql.inputObject({ + const uniqueWhere = g.inputObject({ name: names.whereUniqueInputName, fields: () => { const { fields } = listsRef[listKey] @@ -448,20 +448,20 @@ function getListsWithInitialisedFields ( ), // this is exactly what the id field will add // but this does it more explicitly so that typescript understands - id: graphql.arg({ type: graphql.ID }), + id: g.arg({ type: g.ID }), } }, }) - const where: GraphQLTypesForList['where'] = graphql.inputObject({ + const where: GraphQLTypesForList['where'] = g.inputObject({ name: names.whereInputName, fields: () => { const { fields } = listsRef[listKey] return Object.assign( { - AND: graphql.arg({ type: graphql.list(graphql.nonNull(where)) }), - OR: graphql.arg({ type: graphql.list(graphql.nonNull(where)) }), - NOT: graphql.arg({ type: graphql.list(graphql.nonNull(where)) }), + AND: g.arg({ type: g.list(g.nonNull(where)) }), + OR: g.arg({ type: g.list(g.nonNull(where)) }), + NOT: g.arg({ type: g.list(g.nonNull(where)) }), }, ...Object.entries(fields).map( ([fieldKey, field]) => @@ -473,11 +473,11 @@ function getListsWithInitialisedFields ( }, }) - const create = graphql.inputObject({ + const create = g.inputObject({ name: names.createInputName, fields: () => { const { fields } = listsRef[listKey] - const ret: Record> = {} + const ret: Record> = {} for (const key in fields) { const arg = graphqlArgForInputField(fields[key], 'create', listsRef) @@ -489,11 +489,11 @@ function getListsWithInitialisedFields ( }, }) - const update = graphql.inputObject({ + const update = g.inputObject({ name: names.updateInputName, fields: () => { const { fields } = listsRef[listKey] - const ret: Record> = {} + const ret: Record> = {} for (const key in fields) { const arg = graphqlArgForInputField(fields[key], 'update', listsRef) @@ -505,7 +505,7 @@ function getListsWithInitialisedFields ( }, }) - const orderBy = graphql.inputObject({ + const orderBy = g.inputObject({ name: names.listOrderName, fields: () => { const { fields } = listsRef[listKey] @@ -524,92 +524,92 @@ function getListsWithInitialisedFields ( }, }) - let take: any = graphql.arg({ type: graphql.Int }) + let take: any = g.arg({ type: g.Int }) if (listConfig.graphql?.maxTake !== undefined) { - take = graphql.arg({ - type: graphql.nonNull(graphql.Int), + take = g.arg({ + type: g.nonNull(g.Int), // WARNING: used by queries/resolvers.ts to enforce the limit defaultValue: listConfig.graphql.maxTake, }) } const findManyArgs: FindManyArgs = { - where: graphql.arg({ - type: graphql.nonNull(where), + where: g.arg({ + type: g.nonNull(where), defaultValue: listConfig.isSingleton ? ({ id: { equals: '1' } } as object) : {}, }), - orderBy: graphql.arg({ - type: graphql.nonNull(graphql.list(graphql.nonNull(orderBy))), + orderBy: g.arg({ + type: g.nonNull(g.list(g.nonNull(orderBy))), defaultValue: [], }), take, - skip: graphql.arg({ - type: graphql.nonNull(graphql.Int), + skip: g.arg({ + type: g.nonNull(g.Int), defaultValue: 0 }), - cursor: graphql.arg({ type: uniqueWhere }), + cursor: g.arg({ type: uniqueWhere }), } - const relateToOneForCreate = graphql.inputObject({ + const relateToOneForCreate = g.inputObject({ name: names.relateToOneForCreateInputName, fields: () => { const listRef = listsRef[listKey] return { ...(listRef.graphql.isEnabled.create && { - create: graphql.arg({ type: listRef.graphql.types.create }) + create: g.arg({ type: listRef.graphql.types.create }) }), - connect: graphql.arg({ type: listRef.graphql.types.uniqueWhere }), + connect: g.arg({ type: listRef.graphql.types.uniqueWhere }), } }, }) - const relateToOneForUpdate = graphql.inputObject({ + const relateToOneForUpdate = g.inputObject({ name: names.relateToOneForUpdateInputName, fields: () => { const listRef = listsRef[listKey] return { ...(listRef.graphql.isEnabled.create && { - create: graphql.arg({ type: listRef.graphql.types.create }) + create: g.arg({ type: listRef.graphql.types.create }) }), - connect: graphql.arg({ type: listRef.graphql.types.uniqueWhere }), - disconnect: graphql.arg({ type: graphql.Boolean }), + connect: g.arg({ type: listRef.graphql.types.uniqueWhere }), + disconnect: g.arg({ type: g.Boolean }), } }, }) - const relateToManyForCreate = graphql.inputObject({ + const relateToManyForCreate = g.inputObject({ name: names.relateToManyForCreateInputName, fields: () => { const listRef = listsRef[listKey] return { ...(listRef.graphql.isEnabled.create && { - create: graphql.arg({ - type: graphql.list(graphql.nonNull(listRef.graphql.types.create)) + create: g.arg({ + type: g.list(g.nonNull(listRef.graphql.types.create)) }), }), - connect: graphql.arg({ - type: graphql.list(graphql.nonNull(listRef.graphql.types.uniqueWhere)) + connect: g.arg({ + type: g.list(g.nonNull(listRef.graphql.types.uniqueWhere)) }), } }, }) - const relateToManyForUpdate = graphql.inputObject({ + const relateToManyForUpdate = g.inputObject({ name: names.relateToManyForUpdateInputName, fields: () => { const listRef = listsRef[listKey] return { // WARNING: the order of these fields reflects the order of mutations - disconnect: graphql.arg({ - type: graphql.list(graphql.nonNull(listRef.graphql.types.uniqueWhere)) + disconnect: g.arg({ + type: g.list(g.nonNull(listRef.graphql.types.uniqueWhere)) }), - set: graphql.arg({ - type: graphql.list(graphql.nonNull(listRef.graphql.types.uniqueWhere)) + set: g.arg({ + type: g.list(g.nonNull(listRef.graphql.types.uniqueWhere)) }), ...(listRef.graphql.isEnabled.create && { - create: graphql.arg({ type: graphql.list(graphql.nonNull(listRef.graphql.types.create)) }), + create: g.arg({ type: g.list(g.nonNull(listRef.graphql.types.create)) }), }), - connect: graphql.arg({ type: graphql.list(graphql.nonNull(listRef.graphql.types.uniqueWhere)) }), + connect: g.arg({ type: g.list(g.nonNull(listRef.graphql.types.uniqueWhere)) }), } }, }) @@ -629,12 +629,12 @@ function getListsWithInitialisedFields ( update: relateToOneForUpdate }, many: { - where: graphql.inputObject({ + where: g.inputObject({ name: `${listKey}ManyRelationFilter`, fields: { - every: graphql.arg({ type: where }), - some: graphql.arg({ type: where }), - none: graphql.arg({ type: where }), + every: g.arg({ type: where }), + some: g.arg({ type: where }), + none: g.arg({ type: where }), }, }), create: relateToManyForCreate, @@ -843,8 +843,8 @@ function introspectGraphQLTypes (lists: Record) { } } -function stripDefaultValue (thing: graphql.Arg) { - return graphql.arg({ +function stripDefaultValue (thing: g.Arg) { + return g.arg({ ...thing, defaultValue: undefined, }) @@ -859,9 +859,9 @@ function graphqlArgForInputField (field: InitialisedField, operation: 'create' | if (!field.graphql.isNonNull[operation]) return stripDefaultValue(input.arg) if (input.arg.type.kind === 'non-null') return input.arg - return graphql.arg({ + return g.arg({ ...input.arg, - type: graphql.nonNull(input.arg.type), + type: g.nonNull(input.arg.type), }) } @@ -871,9 +871,9 @@ function graphqlForOutputField (field: InitialisedField) { if (!field.graphql.isNonNull.read) return output if (output.type.kind === 'non-null') return output - return graphql.field({ + return g.field({ ...(output as any), - type: graphql.nonNull(output.type), + type: g.nonNull(output.type), }) } diff --git a/packages/core/src/lib/core/mutations/index.ts b/packages/core/src/lib/core/mutations/index.ts index 56fcaf9fc31..4bb819830c9 100644 --- a/packages/core/src/lib/core/mutations/index.ts +++ b/packages/core/src/lib/core/mutations/index.ts @@ -4,7 +4,7 @@ import { } from '../../../types' import { Empty, } from '../../../types/schema/graphql-ts-schema' import { type UniquePrismaFilter } from '../../../types/prisma' -import { graphql } from '../../../types/schema' +import { g } from '../../../types/schema' import { type ResolvedDBField } from '../resolve-relationships' import { type InitialisedList } from '../initialise-lists' import { @@ -607,29 +607,29 @@ function promisesButSettledWhenAllSettledAndInOrder[] }) as T } -function nonNull (t: graphql.NullableInputType) { +function nonNull (t: g.NullableInputType) { if (t === Empty) return t - return graphql.nonNull(t) + return g.nonNull(t) } export function getMutationsForList (list: InitialisedList) { const defaultUniqueWhereInput = list.isSingleton ? { id: '1' } : undefined - const createOne_ = graphql.field({ + const createOne_ = g.field({ type: list.graphql.types.output, args: { - data: graphql.arg({ type: nonNull(list.graphql.types.create) }), + data: g.arg({ type: nonNull(list.graphql.types.create) }), }, resolve (_rootVal, { data }, context) { return createOne(data, list, context) }, }) - const createMany_ = graphql.field({ - type: graphql.list(list.graphql.types.output), + const createMany_ = g.field({ + type: g.list(list.graphql.types.output), args: { - data: graphql.arg({ - type: graphql.nonNull(graphql.list(nonNull(list.graphql.types.create))), + data: g.arg({ + type: g.nonNull(g.list(nonNull(list.graphql.types.create))), }), }, async resolve (_rootVal, { data }, context) { @@ -637,35 +637,35 @@ export function getMutationsForList (list: InitialisedList) { }, }) - const updateOne_ = graphql.field({ + const updateOne_ = g.field({ type: list.graphql.types.output, args: { - where: graphql.arg({ - type: graphql.nonNull(list.graphql.types.uniqueWhere), + where: g.arg({ + type: g.nonNull(list.graphql.types.uniqueWhere), defaultValue: defaultUniqueWhereInput, }), - data: graphql.arg({ type: nonNull(list.graphql.types.update) }), + data: g.arg({ type: nonNull(list.graphql.types.update) }), }, resolve (_rootVal, { where, data }, context) { return updateOne({ where, data }, list, context) }, }) - const updateManyInput = graphql.inputObject({ + const updateManyInput = g.inputObject({ name: list.graphql.names.updateManyInputName, fields: { - where: graphql.arg({ - type: graphql.nonNull(list.graphql.types.uniqueWhere), + where: g.arg({ + type: g.nonNull(list.graphql.types.uniqueWhere), defaultValue: defaultUniqueWhereInput, }), - data: graphql.arg({ type: nonNull(list.graphql.types.update) }), + data: g.arg({ type: nonNull(list.graphql.types.update) }), }, }) - const updateMany_ = graphql.field({ - type: graphql.list(list.graphql.types.output), + const updateMany_ = g.field({ + type: g.list(list.graphql.types.output), args: { - data: graphql.arg({ - type: graphql.nonNull(graphql.list(nonNull(updateManyInput))) + data: g.arg({ + type: g.nonNull(g.list(nonNull(updateManyInput))) }), }, async resolve (_rootVal, { data }, context) { @@ -675,11 +675,11 @@ export function getMutationsForList (list: InitialisedList) { }, }) - const deleteOne_ = graphql.field({ + const deleteOne_ = g.field({ type: list.graphql.types.output, args: { - where: graphql.arg({ - type: graphql.nonNull(list.graphql.types.uniqueWhere), + where: g.arg({ + type: g.nonNull(list.graphql.types.uniqueWhere), defaultValue: defaultUniqueWhereInput, }), }, @@ -688,11 +688,11 @@ export function getMutationsForList (list: InitialisedList) { }, }) - const deleteMany_ = graphql.field({ - type: graphql.list(list.graphql.types.output), + const deleteMany_ = g.field({ + type: g.list(list.graphql.types.output), args: { - where: graphql.arg({ - type: graphql.nonNull(graphql.list(graphql.nonNull(list.graphql.types.uniqueWhere))), + where: g.arg({ + type: g.nonNull(g.list(g.nonNull(list.graphql.types.uniqueWhere))), }), }, async resolve (rootVal, { where }, context) { diff --git a/packages/core/src/lib/core/mutations/nested-mutation-many-input-resolvers.ts b/packages/core/src/lib/core/mutations/nested-mutation-many-input-resolvers.ts index d1fe99e9d19..3d4bf81d0ed 100644 --- a/packages/core/src/lib/core/mutations/nested-mutation-many-input-resolvers.ts +++ b/packages/core/src/lib/core/mutations/nested-mutation-many-input-resolvers.ts @@ -1,5 +1,5 @@ import type { KeystoneContext, GraphQLTypesForList } from '../../../types' -import { type graphql } from '../../..' +import { type g } from '../../..' import type { UniqueInputFilter } from '../where-inputs' import type { InitialisedList } from '../initialise-lists' import { isRejected, isFulfilled } from '../utils' @@ -8,15 +8,15 @@ import type { NestedMutationState } from './' import { checkUniqueItemExists } from '../access-control' type _CreateValueType = Exclude< - graphql.InferValueFromArg< - graphql.Arg> + g.InferValueFromArg< + g.Arg> >, null | undefined > type _UpdateValueType = Exclude< - graphql.InferValueFromArg< - graphql.Arg> + g.InferValueFromArg< + g.Arg> >, null | undefined > diff --git a/packages/core/src/lib/core/mutations/nested-mutation-one-input-resolvers.ts b/packages/core/src/lib/core/mutations/nested-mutation-one-input-resolvers.ts index 7b7b1f87a31..182a846c701 100644 --- a/packages/core/src/lib/core/mutations/nested-mutation-one-input-resolvers.ts +++ b/packages/core/src/lib/core/mutations/nested-mutation-one-input-resolvers.ts @@ -1,20 +1,20 @@ import type { KeystoneContext, GraphQLTypesForList } from '../../../types' -import { type graphql } from '../../..' +import { type g } from '../../..' import type { InitialisedList } from '../initialise-lists' import { userInputError } from '../graphql-errors' import type { NestedMutationState } from './' import { checkUniqueItemExists } from '../access-control' type _CreateValueType = Exclude< - graphql.InferValueFromArg< - graphql.Arg> + g.InferValueFromArg< + g.Arg> >, null | undefined > type _UpdateValueType = Exclude< - graphql.InferValueFromArg< - graphql.Arg< - graphql.NonNullType> + g.InferValueFromArg< + g.Arg< + g.NonNullType> > >, null | undefined diff --git a/packages/core/src/lib/core/queries/index.ts b/packages/core/src/lib/core/queries/index.ts index 1de5e2bf99a..eb40b2a17bb 100644 --- a/packages/core/src/lib/core/queries/index.ts +++ b/packages/core/src/lib/core/queries/index.ts @@ -1,15 +1,15 @@ -import { graphql } from '../../..' +import { g } from '../../..' import type { InitialisedList } from '../initialise-lists' import * as queries from './resolvers' export function getQueriesForList (list: InitialisedList) { if (!list.graphql.isEnabled.query) return {} - const findOne = graphql.field({ + const findOne = g.field({ type: list.graphql.types.output, args: { - where: graphql.arg({ - type: graphql.nonNull(list.graphql.types.uniqueWhere), + where: g.arg({ + type: g.nonNull(list.graphql.types.uniqueWhere), defaultValue: list.isSingleton ? { id: '1' } : undefined, }), }, @@ -18,19 +18,19 @@ export function getQueriesForList (list: InitialisedList) { }, }) - const findMany = graphql.field({ - type: graphql.list(graphql.nonNull(list.graphql.types.output)), + const findMany = g.field({ + type: g.list(g.nonNull(list.graphql.types.output)), args: list.graphql.types.findManyArgs, async resolve (_rootVal, args, context, info) { return queries.findMany(args, list, context, info) }, }) - const countQuery = graphql.field({ - type: graphql.Int, + const countQuery = g.field({ + type: g.Int, args: { - where: graphql.arg({ - type: graphql.nonNull(list.graphql.types.where), + where: g.arg({ + type: g.nonNull(list.graphql.types.where), defaultValue: list.isSingleton ? ({ id: { equals: '1' } } as object) : {}, }), }, diff --git a/packages/core/src/lib/core/queries/output-field.ts b/packages/core/src/lib/core/queries/output-field.ts index 527b8be8c23..e57d2cfff24 100644 --- a/packages/core/src/lib/core/queries/output-field.ts +++ b/packages/core/src/lib/core/queries/output-field.ts @@ -11,7 +11,7 @@ import type { GraphQLTypesForList, FieldReadItemAccessArgs, } from '../../../types' -import { graphql } from '../../..' +import { g } from '../../..' import { getOperationFieldAccess, getOperationAccess, getAccessFilters } from '../access-control' import type { ResolvedDBField, ResolvedRelationDBField } from '../resolve-relationships' import type { InitialisedList } from '../initialise-lists' @@ -162,7 +162,7 @@ export function outputTypeField ( ) { const list = lists[listKey] - return graphql.field({ + return g.field({ type: output.type, deprecationReason: output.deprecationReason, description: output.description, diff --git a/packages/core/src/lib/createGraphQLSchema.ts b/packages/core/src/lib/createGraphQLSchema.ts index 0a317cdadf4..800fbe68069 100644 --- a/packages/core/src/lib/createGraphQLSchema.ts +++ b/packages/core/src/lib/createGraphQLSchema.ts @@ -1,6 +1,6 @@ import { type GraphQLNamedType, GraphQLSchema } from 'graphql' -import { graphql } from '../types/schema' +import { g } from '../types/schema' import type { KeystoneConfig } from '../types' import { KeystoneMeta } from './resolve-admin-meta' import type { AdminMetaRootVal } from './create-admin-meta' @@ -12,12 +12,12 @@ import { getMutationsForList } from './core/mutations' function getGraphQLSchema ( lists: Record, extraFields: { - query: Record> - mutation: Record> + query: Record> + mutation: Record> }, sudo: boolean ) { - const query = graphql.object()({ + const query = g.object()({ name: 'Query', fields: Object.assign( {}, @@ -26,8 +26,8 @@ function getGraphQLSchema ( ), }) - const updateManyByList: Record> = {} - const mutation = graphql.object()({ + const updateManyByList: Record> = {} + const mutation = g.object()({ name: 'Mutation', fields: Object.assign( {}, @@ -53,7 +53,7 @@ function getGraphQLSchema ( function collectTypes ( lists: Record, - updateManyByList: Record> + updateManyByList: Record> ) { const collectedTypes: GraphQLNamedType[] = [] for (const list of Object.values(lists)) { @@ -91,7 +91,7 @@ function collectTypes ( } } // this is not necessary, just about ordering - collectedTypes.push(graphql.JSON.graphQLType) + collectedTypes.push(g.JSON.graphQLType) return collectedTypes } @@ -107,8 +107,8 @@ export function createGraphQLSchema ( mutation: {}, query: adminMeta ? { - keystone: graphql.field({ - type: graphql.nonNull(KeystoneMeta), + keystone: g.field({ + type: g.nonNull(KeystoneMeta), resolve: () => ({ adminMeta }), }), } diff --git a/packages/core/src/lib/id-field.ts b/packages/core/src/lib/id-field.ts index d5166476aba..58df6edf0bd 100644 --- a/packages/core/src/lib/id-field.ts +++ b/packages/core/src/lib/id-field.ts @@ -6,7 +6,7 @@ import { fieldType, orderDirectionEnum, } from '../types' -import { graphql } from '../types/schema' +import { g } from '../types/schema' import { userInputError } from './core/graphql-errors' type IDType = string | number | null @@ -40,33 +40,33 @@ function isUuid (x: IDType) { } const nonCircularFields = { - equals: graphql.arg({ type: graphql.ID }), - in: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.ID)) }), - notIn: graphql.arg({ type: graphql.list(graphql.nonNull(graphql.ID)) }), - lt: graphql.arg({ type: graphql.ID }), - lte: graphql.arg({ type: graphql.ID }), - gt: graphql.arg({ type: graphql.ID }), - gte: graphql.arg({ type: graphql.ID }), + equals: g.arg({ type: g.ID }), + in: g.arg({ type: g.list(g.nonNull(g.ID)) }), + notIn: g.arg({ type: g.list(g.nonNull(g.ID)) }), + lt: g.arg({ type: g.ID }), + lte: g.arg({ type: g.ID }), + gt: g.arg({ type: g.ID }), + gte: g.arg({ type: g.ID }), } -type IDFilterType = graphql.InputObjectType< +type IDFilterType = g.InputObjectType< typeof nonCircularFields & { - not: graphql.Arg + not: g.Arg } > -const IDFilter: IDFilterType = graphql.inputObject({ +const IDFilter: IDFilterType = g.inputObject({ name: 'IDFilter', fields: () => ({ ...nonCircularFields, - not: graphql.arg({ type: IDFilter }), + not: g.arg({ type: IDFilter }), }), }) -const filterArg = graphql.arg({ type: IDFilter }) +const filterArg = g.arg({ type: IDFilter }) function resolveInput ( - input: Exclude, undefined>, + input: Exclude, undefined>, parseId: (x: IDType) => unknown ) { const where: any = {} @@ -177,11 +177,11 @@ export function idFieldType (config: IdFieldConfig): FieldTypeFunc>, any, 'value'> + field: g.Field<{ value: JSONValue, item: BaseItem }, Record>, any, 'value'> ) { const innerResolver = field.resolve || (({ value }) => value) - return graphql.fields<{ + return g.fields<{ value: string | null item: BaseItem }>()({ - value: graphql.field({ + value: g.field({ type: field.type, args: field.args, deprecationReason: field.deprecationReason, @@ -40,7 +40,7 @@ function mapOutputFieldToSQLite ( }).value } -function mapUpdateInputArgToSQLite> ( +function mapUpdateInputArgToSQLite> ( arg: UpdateFieldInputArg, Arg> | undefined ): UpdateFieldInputArg, Arg> | undefined { if (arg === undefined) { @@ -49,7 +49,7 @@ function mapUpdateInputArgToSQLite, + input: g.InferValueFromArg, context: KeystoneContext, relationshipInputResolver: any ) { @@ -65,7 +65,7 @@ function mapUpdateInputArgToSQLite> ( +function mapCreateInputArgToSQLite> ( arg: CreateFieldInputArg, Arg> | undefined ): CreateFieldInputArg, Arg> | undefined { if (arg === undefined) { @@ -74,7 +74,7 @@ function mapCreateInputArgToSQLite, + input: g.InferValueFromArg, context: KeystoneContext, relationshipInputResolver: any ) { @@ -91,16 +91,16 @@ function mapCreateInputArgToSQLite, - UpdateArg extends graphql.Arg + CreateArg extends g.Arg, + UpdateArg extends g.Arg > ( provider: DatabaseProvider, config: FieldTypeWithoutDBField< ScalarDBField<'Json', 'optional'>, CreateArg, UpdateArg, - graphql.Arg, - graphql.Arg + g.Arg, + g.Arg > & { input?: { uniqueWhere?: undefined diff --git a/packages/core/src/types/next-fields.ts b/packages/core/src/types/next-fields.ts index f4c19240262..9aa851e26a8 100644 --- a/packages/core/src/types/next-fields.ts +++ b/packages/core/src/types/next-fields.ts @@ -1,5 +1,5 @@ import Decimal from 'decimal.js' -import { graphql } from '../types/schema' +import { g } from '../types/schema' import type { BaseListTypeInfo } from './type-info' import type { CommonFieldConfig } from './config' import type { DatabaseProvider } from './core' @@ -28,30 +28,30 @@ export type FieldTypeFunc = ( data: FieldData ) => NextFieldType< DBField, - graphql.Arg | undefined, - graphql.Arg, - graphql.Arg, - graphql.Arg, - graphql.Arg, + g.Arg | undefined, + g.Arg, + g.Arg, + g.Arg, + g.Arg, ListTypeInfo > export type NextFieldType< TDBField extends DBField = DBField, - CreateArg extends graphql.Arg | undefined = - | graphql.Arg + CreateArg extends g.Arg | undefined = + | g.Arg | undefined, - UpdateArg extends graphql.Arg = graphql.Arg, - UniqueWhereArg extends graphql.Arg = graphql.Arg< - graphql.NullableInputType, + UpdateArg extends g.Arg = g.Arg, + UniqueWhereArg extends g.Arg = g.Arg< + g.NullableInputType, false >, - OrderByArg extends graphql.Arg = graphql.Arg< - graphql.NullableInputType, + OrderByArg extends g.Arg = g.Arg< + g.NullableInputType, false >, - FilterArg extends graphql.Arg = graphql.Arg< - graphql.NullableInputType, + FilterArg extends g.Arg = g.Arg< + g.NullableInputType, false >, ListTypeInfo extends BaseListTypeInfo = BaseListTypeInfo @@ -143,14 +143,14 @@ export type EnumDBField = TDBField extends ScalarDBF ? { [Key in keyof Fields]: DBFieldToOutputValue } : never -export type OrderByFieldInputArg> = { +export type OrderByFieldInputArg> = { arg: TArg } & ResolveFunc< ( - value: Exclude, null | undefined>, + value: Exclude, null | undefined>, context: KeystoneContext ) => MaybePromise > @@ -265,12 +265,12 @@ type DBFieldFilters = export type WhereFieldInputArg< TDBField extends DBField, - TArg extends graphql.Arg + TArg extends g.Arg > = { arg: TArg } & ResolveFunc< FieldInputResolver< - Exclude, undefined>, + Exclude, undefined>, DBFieldFilters, any // i think this is broken because variance? @@ -287,12 +287,12 @@ export type WhereFieldInputArg< export type UpdateFieldInputArg< TDBField extends DBField, - TArg extends graphql.Arg + TArg extends g.Arg > = { arg: TArg } & ResolveFunc< FieldInputResolver< - graphql.InferValueFromArg, + g.InferValueFromArg, DBFieldToInputValue, any // i think this is broken because variance? @@ -318,16 +318,16 @@ type CreateFieldInputResolver = FieldInputResol export type CreateFieldInputArg< TDBField extends DBField, - TArg extends graphql.Arg | undefined + TArg extends g.Arg | undefined > = { arg: TArg -} & (TArg extends graphql.Arg - ? graphql.InferValueFromArg extends DBFieldToInputValue +} & (TArg extends g.Arg + ? g.InferValueFromArg extends DBFieldToInputValue ? { - resolve?: CreateFieldInputResolver, TDBField> + resolve?: CreateFieldInputResolver, TDBField> } : { - resolve: CreateFieldInputResolver, TDBField> + resolve: CreateFieldInputResolver, TDBField> } : { resolve: CreateFieldInputResolver @@ -340,19 +340,19 @@ type ResolveFunc any> = ? { resolve?: Func } : { resolve: Func } -export type UniqueWhereFieldInputArg> = { +export type UniqueWhereFieldInputArg> = { arg: TArg } & ResolveFunc< ( - value: Exclude, undefined | null>, + value: Exclude, undefined | null>, context: KeystoneContext ) => MaybePromise > -type FieldTypeOutputField = graphql.Field< +type FieldTypeOutputField = g.Field< { value: DBFieldToOutputValue, item: BaseItem }, any, - graphql.OutputType, + g.OutputType, 'value' > @@ -366,20 +366,20 @@ type DBFieldToOrderByValue = TDBField extends Scalaris export type FieldTypeWithoutDBField< TDBField extends DBField = DBField, - CreateArg extends graphql.Arg | undefined = - | graphql.Arg + CreateArg extends g.Arg | undefined = + | g.Arg | undefined, - UpdateArg extends graphql.Arg = graphql.Arg, - UniqueWhereArg extends graphql.Arg = graphql.Arg< - graphql.NullableInputType, + UpdateArg extends g.Arg = g.Arg, + UniqueWhereArg extends g.Arg = g.Arg< + g.NullableInputType, false >, - OrderByArg extends graphql.Arg = graphql.Arg< - graphql.NullableInputType, + OrderByArg extends g.Arg = g.Arg< + g.NullableInputType, false >, - FilterArg extends graphql.Arg = graphql.Arg< - graphql.NullableInputType, + FilterArg extends g.Arg = g.Arg< + g.NullableInputType, false >, ListTypeInfo extends BaseListTypeInfo = BaseListTypeInfo @@ -395,78 +395,78 @@ export type FieldTypeWithoutDBField< views: string extraOutputFields?: Record> getAdminMeta?: () => JSONValue - unreferencedConcreteInterfaceImplementations?: readonly graphql.ObjectType[] + unreferencedConcreteInterfaceImplementations?: readonly g.ObjectType[] __ksTelemetryFieldTypeName?: string } & CommonFieldConfig -type AnyInputObj = graphql.InputObjectType>> +type AnyInputObj = g.InputObjectType>> export type GraphQLTypesForList = { - create: graphql.NullableInputType - update: graphql.NullableInputType - uniqueWhere: graphql.InputObjectType<{ - id: graphql.Arg - [key: string]: graphql.Arg + create: g.NullableInputType + update: g.NullableInputType + uniqueWhere: g.InputObjectType<{ + id: g.Arg + [key: string]: g.Arg }> where: AnyInputObj orderBy: AnyInputObj - output: graphql.ObjectType + output: g.ObjectType findManyArgs: FindManyArgs relateTo: { one: { - create: graphql.InputObjectType<{ - create?: graphql.Arg - connect: graphql.Arg + create: g.InputObjectType<{ + create?: g.Arg + connect: g.Arg }> - update: graphql.InputObjectType<{ - create?: graphql.Arg - connect: graphql.Arg - disconnect: graphql.Arg + update: g.InputObjectType<{ + create?: g.Arg + connect: g.Arg + disconnect: g.Arg }> } many: { - where: graphql.InputObjectType<{ - every: graphql.Arg - some: graphql.Arg - none: graphql.Arg + where: g.InputObjectType<{ + every: g.Arg + some: g.Arg + none: g.Arg }> - create: graphql.InputObjectType<{ - create?: graphql.Arg>> - connect: graphql.Arg>> + create: g.InputObjectType<{ + create?: g.Arg>> + connect: g.Arg>> }> - update: graphql.InputObjectType<{ - connect: graphql.Arg>> - create?: graphql.Arg>> - disconnect: graphql.Arg>> - set: graphql.Arg>> + update: g.InputObjectType<{ + connect: g.Arg>> + create?: g.Arg>> + disconnect: g.Arg>> + set: g.Arg>> }> } } } export type FindManyArgs = { - where: graphql.Arg, true> - orderBy: graphql.Arg< - graphql.NonNullType>>, + where: g.Arg, true> + orderBy: g.Arg< + g.NonNullType>>, true > - take: graphql.Arg - skip: graphql.Arg, true> - cursor: graphql.Arg + take: g.Arg + skip: g.Arg, true> + cursor: g.Arg } -export type FindManyArgsValue = graphql.InferValueFromArgs +export type FindManyArgsValue = g.InferValueFromArgs // fieldType(dbField)(fieldInfo) => { ...fieldInfo, dbField }; export function fieldType ( dbField: TDBField ) { return function fieldTypeWrapper< - CreateArg extends graphql.Arg | undefined, - UpdateArg extends graphql.Arg, - UniqueWhereArg extends graphql.Arg, - OrderByArg extends graphql.Arg, - FilterArg extends graphql.Arg + CreateArg extends g.Arg | undefined, + UpdateArg extends g.Arg, + UniqueWhereArg extends g.Arg, + OrderByArg extends g.Arg, + FilterArg extends g.Arg > ( graphQLInfo: FieldTypeWithoutDBField< TDBField, diff --git a/packages/fields-document/src/DocumentEditor/component-blocks/api-shared.ts b/packages/fields-document/src/DocumentEditor/component-blocks/api-shared.ts index 15d9262f793..4fe5d33db48 100644 --- a/packages/fields-document/src/DocumentEditor/component-blocks/api-shared.ts +++ b/packages/fields-document/src/DocumentEditor/component-blocks/api-shared.ts @@ -1,4 +1,4 @@ -import type { graphql } from '@keystone-6/core' +import type { g } from '@keystone-6/core' import type { ReactElement, ReactNode, @@ -43,11 +43,11 @@ export type FormField = { */ validate(value: unknown): boolean graphql?: { - input: graphql.NullableInputType - output: graphql.Field< + input: g.NullableInputType + output: g.Field< { value: Value }, - Record>, - graphql.OutputType, + Record>, + g.OutputType, 'value' > } diff --git a/packages/fields-document/src/DocumentEditor/component-blocks/api.tsx b/packages/fields-document/src/DocumentEditor/component-blocks/api.tsx index 430b676c781..feb77b7cc08 100644 --- a/packages/fields-document/src/DocumentEditor/component-blocks/api.tsx +++ b/packages/fields-document/src/DocumentEditor/component-blocks/api.tsx @@ -1,5 +1,5 @@ import React from 'react' -import { graphql } from '@keystone-6/core' +import { g } from '@keystone-6/core' import type { HTMLAttributes, @@ -64,9 +64,9 @@ export const fields = { defaultValue, validate (value: unknown) { return typeof value === 'string' }, graphql: { - input: graphql.String, - output: graphql.field({ - type: graphql.String, + input: g.String, + output: g.field({ + type: g.String, }), }, } @@ -88,9 +88,9 @@ export const fields = { defaultValue, validate, graphql: { - input: graphql.Int, - output: graphql.field({ - type: graphql.Int, + input: g.Int, + output: g.field({ + type: g.Int, }), }, } @@ -112,9 +112,9 @@ export const fields = { defaultValue, validate, graphql: { - input: graphql.String, - output: graphql.field({ - type: graphql.String, + input: g.String, + output: g.field({ + type: g.String, }), }, } @@ -140,9 +140,9 @@ export const fields = { return typeof value === 'string' && optionValuesSet.has(value) }, graphql: { - input: graphql.String, - output: graphql.field({ - type: graphql.String, + input: g.String, + output: g.field({ + type: g.String, // TODO: FIXME why is this required resolve ({ value }) { return value }, }), @@ -169,9 +169,9 @@ export const fields = { && value.every(value => typeof value === 'string' && valuesToOption.has(value)) }, graphql: { - input: graphql.list(graphql.nonNull(graphql.String)), - output: graphql.field({ - type: graphql.list(graphql.nonNull(graphql.String)), + input: g.list(g.nonNull(g.String)), + output: g.field({ + type: g.list(g.nonNull(g.String)), // TODO: why is this required resolve ({ value }) { return value }, }), @@ -203,8 +203,8 @@ export const fields = { defaultValue, validate (value: unknown) { return typeof value === 'boolean' }, graphql: { - input: graphql.Boolean, - output: graphql.field({ type: graphql.Boolean }), + input: g.Boolean, + output: g.field({ type: g.Boolean }), }, } }, diff --git a/packages/fields-document/src/index.ts b/packages/fields-document/src/index.ts index f0d75744c37..61e6304a2c5 100644 --- a/packages/fields-document/src/index.ts +++ b/packages/fields-document/src/index.ts @@ -7,7 +7,7 @@ import { type JSONValue, jsonFieldTypePolyfilledForSQLite, } from '@keystone-6/core/types' -import { graphql } from '@keystone-6/core' +import { g } from '@keystone-6/core' import type { Relationships } from './DocumentEditor/relationship-shared' import type { ComponentBlock } from './DocumentEditor/component-blocks/api-shared' import { validateAndNormalizeDocument } from './validation' @@ -115,7 +115,7 @@ export function document ({ __ksTelemetryFieldTypeName: '@keystone-6/document', input: { create: { - arg: graphql.arg({ type: graphql.JSON }), + arg: g.arg({ type: g.JSON }), resolve (val) { if (val === undefined) { val = [{ type: 'paragraph', children: [{ text: '' }] }] @@ -123,20 +123,20 @@ export function document ({ return inputResolver(val) }, }, - update: { arg: graphql.arg({ type: graphql.JSON }), resolve: inputResolver }, + update: { arg: g.arg({ type: g.JSON }), resolve: inputResolver }, }, - output: graphql.field({ - type: graphql.object<{ document: JSONValue }>()({ + output: g.field({ + type: g.object<{ document: JSONValue }>()({ name: `${meta.listKey}_${meta.fieldKey}_Document`, fields: { - document: graphql.field({ + document: g.field({ args: { - hydrateRelationships: graphql.arg({ - type: graphql.nonNull(graphql.Boolean), + hydrateRelationships: g.arg({ + type: g.nonNull(g.Boolean), defaultValue: false, }), }, - type: graphql.nonNull(graphql.JSON), + type: g.nonNull(g.JSON), resolve ({ document }, { hydrateRelationships }, context) { return hydrateRelationships ? addRelationshipData(document as any, context, relationships, componentBlocks) diff --git a/packages/fields-document/src/structure-graphql-input.ts b/packages/fields-document/src/structure-graphql-input.ts index 330000b25c8..dc90a64bc01 100644 --- a/packages/fields-document/src/structure-graphql-input.ts +++ b/packages/fields-document/src/structure-graphql-input.ts @@ -1,4 +1,4 @@ -import { graphql } from '@keystone-6/core' +import { g } from '@keystone-6/core' import type { BaseItem, FieldData, @@ -18,7 +18,7 @@ export function getGraphQLInputType ( name: string, schema: ComponentSchema, operation: 'create' | 'update', - cache: Map, + cache: Map, meta: FieldData ) { if (!cache.has(schema)) { @@ -32,9 +32,9 @@ function getGraphQLInputTypeInner ( name: string, schema: ComponentSchema, operation: 'create' | 'update', - cache: Map, + cache: Map, meta: FieldData -): graphql.InputType { +): g.InputType { if (schema.kind === 'form') { if (!schema.graphql) { throw new Error(`Field at ${name} is missing a graphql field`) @@ -42,12 +42,12 @@ function getGraphQLInputTypeInner ( return schema.graphql.input } if (schema.kind === 'object') { - return graphql.inputObject({ + return g.inputObject({ name: `${name}${operation[0].toUpperCase()}${operation.slice(1)}Input`, fields: () => Object.fromEntries( Object.entries(schema.fields).map( - ([key, val]): [string, graphql.Arg] => { + ([key, val]): [string, g.Arg] => { const type = getGraphQLInputType( `${name}${key[0].toUpperCase()}${key.slice(1)}`, val, @@ -55,7 +55,7 @@ function getGraphQLInputTypeInner ( cache, meta ) - return [key, graphql.arg({ type })] + return [key, g.arg({ type })] } ) ), @@ -63,15 +63,15 @@ function getGraphQLInputTypeInner ( } if (schema.kind === 'array') { const innerType = getGraphQLInputType(name, schema.element, operation, cache, meta) - return graphql.list(innerType) + return g.list(innerType) } if (schema.kind === 'conditional') { - return graphql.inputObject({ + return g.inputObject({ name: `${name}${operation[0].toUpperCase()}${operation.slice(1)}Input`, fields: () => Object.fromEntries( Object.entries(schema.values).map( - ([key, val]): [string, graphql.Arg] => { + ([key, val]): [string, g.Arg] => { const type = getGraphQLInputType( `${name}${key[0].toUpperCase()}${key.slice(1)}`, val, @@ -79,7 +79,7 @@ function getGraphQLInputTypeInner ( cache, meta ) - return [key, graphql.arg({ type })] + return [key, g.arg({ type })] } ) ), @@ -143,13 +143,13 @@ export async function getValueForUpdate ( } if (schema.kind === 'relationship') { if (schema.many) { - const val = (value as graphql.InferValueFromArg< - graphql.Arg> + const val = (value as g.InferValueFromArg< + g.Arg> >)! return resolveRelateToManyForUpdateInput(val, context, schema.listKey, prevValue) } else { - const val = (value as graphql.InferValueFromArg< - graphql.Arg> + const val = (value as g.InferValueFromArg< + g.Arg> >)! return resolveRelateToOneForUpdateInput(val, context, schema.listKey) @@ -225,14 +225,14 @@ export async function getValueForCreate ( } if (schema.kind === 'relationship') { if (schema.many) { - const val = (value as graphql.InferValueFromArg< - graphql.Arg> + const val = (value as g.InferValueFromArg< + g.Arg> >)! return resolveRelateToManyForCreateInput(val, context, schema.listKey) } else { - const val = (value as graphql.InferValueFromArg< - graphql.Arg> + const val = (value as g.InferValueFromArg< + g.Arg> >)! return resolveRelateToOneForCreateInput(val, context, schema.listKey) @@ -268,15 +268,15 @@ export async function getValueForCreate ( /** MANY */ type _CreateValueManyType = Exclude< - graphql.InferValueFromArg< - graphql.Arg> + g.InferValueFromArg< + g.Arg> >, null | undefined > type _UpdateValueManyType = Exclude< - graphql.InferValueFromArg< - graphql.Arg> + g.InferValueFromArg< + g.Arg> >, null | undefined > @@ -411,15 +411,15 @@ export async function resolveRelateToManyForUpdateInput ( /** ONE */ type _CreateValueType = Exclude< - graphql.InferValueFromArg< - graphql.Arg> + g.InferValueFromArg< + g.Arg> >, null | undefined > type _UpdateValueType = Exclude< - graphql.InferValueFromArg< - graphql.Arg< - graphql.NonNullType> + g.InferValueFromArg< + g.Arg< + g.NonNullType> > >, null | undefined diff --git a/packages/fields-document/src/structure-graphql-output.ts b/packages/fields-document/src/structure-graphql-output.ts index f9afba64210..2cbf39d564f 100644 --- a/packages/fields-document/src/structure-graphql-output.ts +++ b/packages/fields-document/src/structure-graphql-output.ts @@ -1,23 +1,23 @@ -import { graphql } from '@keystone-6/core' +import { g } from '@keystone-6/core' import { type FieldData } from '@keystone-6/core/types' import { type ComponentSchema } from './DocumentEditor/component-blocks/api-shared' import { assertNever } from './DocumentEditor/component-blocks/utils' function wrapGraphQLFieldInResolver ( - inputField: graphql.Field< + inputField: g.Field< { value: InputSource }, - Record>, - graphql.OutputType, + Record>, + g.OutputType, 'value' >, getVal: (outputSource: OutputSource) => InputSource -): graphql.Field< +): g.Field< OutputSource, - Record>, - graphql.OutputType, + Record>, + g.OutputType, string > { - return graphql.field({ + return g.field({ type: inputField.type, args: inputField.args, deprecationReason: inputField.deprecationReason, @@ -33,17 +33,17 @@ function wrapGraphQLFieldInResolver ( }) } -type OutputField = graphql.Field< +type OutputField = g.Field< { value: unknown }, - Record>, - graphql.OutputType, + Record>, + g.OutputType, string > export function getOutputGraphQLField ( name: string, schema: ComponentSchema, - interfaceImplementations: graphql.ObjectType[], + interfaceImplementations: g.ObjectType[], cache: Map, meta: FieldData ) { @@ -57,7 +57,7 @@ export function getOutputGraphQLField ( function getOutputGraphQLFieldInner ( name: string, schema: ComponentSchema, - interfaceImplementations: graphql.ObjectType[], + interfaceImplementations: g.ObjectType[], cache: Map, meta: FieldData ): OutputField { @@ -68,13 +68,13 @@ function getOutputGraphQLFieldInner ( return wrapGraphQLFieldInResolver(schema.graphql.output, x => x.value) } if (schema.kind === 'object') { - return graphql.field({ - type: graphql.object()({ + return g.field({ + type: g.object()({ name, fields: () => Object.fromEntries( Object.entries(schema.fields).map( - ([key, val]): [string, graphql.Field>, graphql.OutputType, string>] => { + ([key, val]): [string, g.Field>, g.OutputType, string>] => { const field = getOutputGraphQLField( `${name}${key[0].toUpperCase()}${key.slice(1)}`, val, @@ -102,8 +102,8 @@ function getOutputGraphQLFieldInner ( ) const resolve = innerField.resolve - return graphql.field({ - type: graphql.list(innerField.type), + return g.field({ + type: g.list(innerField.type), args: innerField.args, deprecationReason: innerField.deprecationReason, description: innerField.description, @@ -133,7 +133,7 @@ function getOutputGraphQLFieldInner ( } type SourceType = { discriminant: string | boolean, value: unknown } - const interfaceType = graphql.interface()({ + const interfaceType = g.interface()({ name, resolveType: value => { const stringifiedDiscriminant = value.discriminant.toString() @@ -145,9 +145,9 @@ function getOutputGraphQLFieldInner ( }) interfaceImplementations.push( - ...Object.entries(schema.values).map(([key, val]): graphql.ObjectType => { + ...Object.entries(schema.values).map(([key, val]): g.ObjectType => { const innerName = name + key[0].toUpperCase() + key.slice(1) - return graphql.object()({ + return g.object()({ name: innerName, interfaces: [interfaceType], fields: () => ({ @@ -164,7 +164,7 @@ function getOutputGraphQLFieldInner ( }) ) - return graphql.field({ + return g.field({ type: interfaceType, resolve ({ value }) { return value as SourceType @@ -174,8 +174,8 @@ function getOutputGraphQLFieldInner ( if (schema.kind === 'relationship') { const listOutputType = meta.lists[schema.listKey].types.output - return graphql.field({ - type: schema.many ? graphql.list(listOutputType) : listOutputType, + return g.field({ + type: schema.many ? g.list(listOutputType) : listOutputType, resolve ({ value }, args, context) { if (Array.isArray(value)) { return context.db[schema.listKey].findMany({ diff --git a/packages/fields-document/src/structure.ts b/packages/fields-document/src/structure.ts index e3b656d0dcc..45cdec8e635 100644 --- a/packages/fields-document/src/structure.ts +++ b/packages/fields-document/src/structure.ts @@ -5,7 +5,7 @@ import { type JSONValue, jsonFieldTypePolyfilledForSQLite, } from '@keystone-6/core/types' -import { graphql } from '@keystone-6/core' +import { g } from '@keystone-6/core' import { getInitialPropsValue } from './DocumentEditor/component-blocks/initial-values' import { getOutputGraphQLField } from './structure-graphql-output' import type { ComponentSchema } from './DocumentEditor/component-blocks/api' @@ -39,7 +39,7 @@ export function structure ({ } const defaultValue = getInitialPropsValue(schema) - const unreferencedConcreteInterfaceImplementations: graphql.ObjectType[] = [] + const unreferencedConcreteInterfaceImplementations: g.ObjectType[] = [] const name = meta.listKey + meta.fieldKey[0].toUpperCase() + meta.fieldKey.slice(1) return jsonFieldTypePolyfilledForSQLite( @@ -72,7 +72,7 @@ export function structure ({ }, input: { create: { - arg: graphql.arg({ + arg: g.arg({ type: getGraphQLInputType(name, schema, 'create', new Map(), meta), }), async resolve (val, context) { @@ -80,13 +80,13 @@ export function structure ({ }, }, update: { - arg: graphql.arg({ + arg: g.arg({ type: getGraphQLInputType(name, schema, 'update', new Map(), meta), }), }, }, - output: graphql.field({ - type: graphql.object<{ value: JSONValue }>()({ + output: g.field({ + type: g.object<{ value: JSONValue }>()({ name: `${name}Output`, fields: { structure: getOutputGraphQLField( @@ -96,11 +96,11 @@ export function structure ({ new Map(), meta ), - json: graphql.field({ - type: graphql.JSON, + json: g.field({ + type: g.JSON, args: { - hydrateRelationships: graphql.arg({ - type: graphql.nonNull(graphql.Boolean), + hydrateRelationships: g.arg({ + type: g.nonNull(g.Boolean), defaultValue: false, }), }, diff --git a/tests/api-tests/extend-graphql-schema.test.ts b/tests/api-tests/extend-graphql-schema.test.ts index 77b06b98f9a..d8deeaa9fd7 100644 --- a/tests/api-tests/extend-graphql-schema.test.ts +++ b/tests/api-tests/extend-graphql-schema.test.ts @@ -1,4 +1,4 @@ -import { list, graphql } from '@keystone-6/core' +import { list, g } from '@keystone-6/core' import { allowAll } from '@keystone-6/core/access' import { text } from '@keystone-6/core/fields' @@ -33,24 +33,24 @@ const runner = setupTestRunner({ }), }, graphql: { - extendGraphqlSchema: graphql.extend(() => { + extendGraphqlSchema: g.extend(() => { return { mutation: { - triple: graphql.field({ - type: graphql.Int, - args: { x: graphql.arg({ type: graphql.nonNull(graphql.Int) }) }, + triple: g.field({ + type: g.Int, + args: { x: g.arg({ type: g.nonNull(g.Int) }) }, resolve: withAccessCheck(true, (_, { x }: { x: number }) => 3 * x), }), }, query: { - double: graphql.field({ - type: graphql.Int, - args: { x: graphql.arg({ type: graphql.nonNull(graphql.Int) }) }, + double: g.field({ + type: g.Int, + args: { x: g.arg({ type: g.nonNull(g.Int) }) }, resolve: withAccessCheck(true, (_, { x }: { x: number }) => 2 * x), }), - quads: graphql.field({ - type: graphql.Int, - args: { x: graphql.arg({ type: graphql.nonNull(graphql.Int) }) }, + quads: g.field({ + type: g.Int, + args: { x: g.arg({ type: g.nonNull(g.Int) }) }, resolve: withAccessCheck(falseFn, (_, { x }: { x: number }) => 4 * x), }), }, diff --git a/tests/api-tests/fields/types/Virtual.test.ts b/tests/api-tests/fields/types/Virtual.test.ts index 4c39eeaac5b..0b0c6c882b2 100644 --- a/tests/api-tests/fields/types/Virtual.test.ts +++ b/tests/api-tests/fields/types/Virtual.test.ts @@ -1,5 +1,5 @@ import { integer, relationship, text, virtual } from '@keystone-6/core/fields' -import { type BaseFields, list, graphql } from '@keystone-6/core' +import { type BaseFields, list, g } from '@keystone-6/core' import { setupTestEnv, setupTestRunner } from '@keystone-6/api-tests/test-runner' import { allowAll } from '@keystone-6/core/access' @@ -24,8 +24,8 @@ describe('Virtual field type', () => { 'no args', makeRunner({ foo: virtual({ - field: graphql.field({ - type: graphql.Int, + field: g.field({ + type: g.Int, resolve () { return 42 }, @@ -45,11 +45,11 @@ describe('Virtual field type', () => { 'args', makeRunner({ foo: virtual({ - field: graphql.field({ - type: graphql.Int, + field: g.field({ + type: g.Int, args: { - x: graphql.arg({ type: graphql.Int }), - y: graphql.arg({ type: graphql.Int }), + x: g.arg({ type: g.Int }), + y: g.arg({ type: g.Int }), }, resolve: (item, { x = 5, y = 6 }) => x! * y!, }), @@ -91,8 +91,8 @@ describe('Virtual field type', () => { author: virtual({ ui: { listView: { fieldMode: 'hidden' }, itemView: { fieldMode: 'hidden' } }, field: lists => - graphql.field({ - type: graphql.union({ + g.field({ + type: g.union({ name: 'Author', types: [lists.Person.types.output, lists.Organisation.types.output], }), @@ -166,11 +166,11 @@ describe('Virtual field type', () => { access: allowAll, fields: { virtual: virtual({ - field: graphql.field({ - type: graphql.object()({ + field: g.field({ + type: g.object()({ name: 'Something', fields: { - something: graphql.field({ type: graphql.String }), + something: g.field({ type: g.String }), }, }), }), diff --git a/tests/api-tests/queries/cache-hints.test.ts b/tests/api-tests/queries/cache-hints.test.ts index 9ed2aaa658b..5e2b0ba6c6d 100644 --- a/tests/api-tests/queries/cache-hints.test.ts +++ b/tests/api-tests/queries/cache-hints.test.ts @@ -1,6 +1,6 @@ import { maybeCacheControlFromInfo } from '@apollo/cache-control-types' import { text, relationship, integer } from '@keystone-6/core/fields' -import { list, graphql } from '@keystone-6/core' +import { list, g } from '@keystone-6/core' import { setupTestRunner } from '@keystone-6/api-tests/test-runner' import { allowAll } from '@keystone-6/core/access' import { type ContextFromRunner } from '../utils' @@ -45,19 +45,19 @@ const runner = setupTestRunner({ }), }, graphql: { - extendGraphqlSchema: graphql.extend(() => { - const MyType = graphql.object<{ original: number }>()({ + extendGraphqlSchema: g.extend(() => { + const MyType = g.object<{ original: number }>()({ name: 'MyType', fields: { - original: graphql.field({ type: graphql.Int }), - double: graphql.field({ type: graphql.Int, resolve: ({ original }) => original * 2 }), + original: g.field({ type: g.Int }), + double: g.field({ type: g.Int, resolve: ({ original }) => original * 2 }), }, }) return { query: { - double: graphql.field({ + double: g.field({ type: MyType, - args: { x: graphql.arg({ type: graphql.nonNull(graphql.Int) }) }, + args: { x: g.arg({ type: g.nonNull(g.Int) }) }, resolve: (_, { x }, context, info) => { maybeCacheControlFromInfo(info)?.setCacheHint({ maxAge: 100, scope: 'PUBLIC' }) return { original: x, double: x * 2 } @@ -65,9 +65,9 @@ const runner = setupTestRunner({ }), }, mutation: { - triple: graphql.field({ - type: graphql.Int, - args: { x: graphql.arg({ type: graphql.nonNull(graphql.Int) }) }, + triple: g.field({ + type: g.Int, + args: { x: g.arg({ type: g.nonNull(g.Int) }) }, resolve: (_, { x }) => x * 3, }), }, diff --git a/tests/sandbox/configs/all-the-things.ts b/tests/sandbox/configs/all-the-things.ts index 8d250527ec5..4da31fb4433 100644 --- a/tests/sandbox/configs/all-the-things.ts +++ b/tests/sandbox/configs/all-the-things.ts @@ -1,4 +1,4 @@ -import { list, graphql, config, group } from '@keystone-6/core' +import { list, g, config, group } from '@keystone-6/core' import { allowAll } from '@keystone-6/core/access' import { bigInt, @@ -79,8 +79,8 @@ export const lists = { calendarDay: calendarDay({ ui: { description } }), randomNumberVirtual: virtual({ ui: { description }, - field: graphql.field({ - type: graphql.Float, + field: g.field({ + type: g.Float, resolve () { return Math.random() * 1000 }, diff --git a/tests/test-projects/live-reloading/schema.ts b/tests/test-projects/live-reloading/schema.ts index f500c31f75f..f80ad1baff7 100644 --- a/tests/test-projects/live-reloading/schema.ts +++ b/tests/test-projects/live-reloading/schema.ts @@ -1,4 +1,4 @@ -import { graphql, list } from '@keystone-6/core' +import { g, list } from '@keystone-6/core' import { allowAll } from '@keystone-6/core/access' import { text } from '@keystone-6/core/fields' @@ -11,11 +11,11 @@ export const lists = { }), } -export const extendGraphqlSchema = graphql.extend(() => { +export const extendGraphqlSchema = g.extend(() => { return { query: { - someNumber: graphql.field({ - type: graphql.Int, + someNumber: g.field({ + type: g.Int, resolve: () => 1, }), }, diff --git a/tests/test-projects/live-reloading/schemas/changed-prisma-schema.ts b/tests/test-projects/live-reloading/schemas/changed-prisma-schema.ts index 5adb33b3287..a109a4d39e2 100644 --- a/tests/test-projects/live-reloading/schemas/changed-prisma-schema.ts +++ b/tests/test-projects/live-reloading/schemas/changed-prisma-schema.ts @@ -1,4 +1,4 @@ -import { list, graphql } from '@keystone-6/core' +import { list, g } from '@keystone-6/core' import { allowAll } from '@keystone-6/core/access' import { text } from '@keystone-6/core/fields' @@ -12,11 +12,11 @@ export const lists = { }), } -export const extendGraphqlSchema = graphql.extend(() => { +export const extendGraphqlSchema = g.extend(() => { return { query: { - someNumber: graphql.field({ - type: graphql.Int, + someNumber: g.field({ + type: g.Int, resolve: () => 1, }), }, diff --git a/tests/test-projects/live-reloading/schemas/initial.ts b/tests/test-projects/live-reloading/schemas/initial.ts index f500c31f75f..f80ad1baff7 100644 --- a/tests/test-projects/live-reloading/schemas/initial.ts +++ b/tests/test-projects/live-reloading/schemas/initial.ts @@ -1,4 +1,4 @@ -import { graphql, list } from '@keystone-6/core' +import { g, list } from '@keystone-6/core' import { allowAll } from '@keystone-6/core/access' import { text } from '@keystone-6/core/fields' @@ -11,11 +11,11 @@ export const lists = { }), } -export const extendGraphqlSchema = graphql.extend(() => { +export const extendGraphqlSchema = g.extend(() => { return { query: { - someNumber: graphql.field({ - type: graphql.Int, + someNumber: g.field({ + type: g.Int, resolve: () => 1, }), }, diff --git a/tests/test-projects/live-reloading/schemas/second.ts b/tests/test-projects/live-reloading/schemas/second.ts index 0a1d59a6b62..6c99c80931a 100644 --- a/tests/test-projects/live-reloading/schemas/second.ts +++ b/tests/test-projects/live-reloading/schemas/second.ts @@ -1,4 +1,4 @@ -import { graphql, list } from '@keystone-6/core' +import { g, list } from '@keystone-6/core' import { allowAll } from '@keystone-6/core/access' import { text, virtual } from '@keystone-6/core/fields' @@ -10,8 +10,8 @@ export const lists = { fields: { text: text({ label: 'Very Important Text' }), virtual: virtual({ - field: graphql.field({ - type: graphql.String, + field: g.field({ + type: g.String, resolve (item) { return item.text }, @@ -21,11 +21,11 @@ export const lists = { }), } satisfies Lists -export const extendGraphqlSchema = graphql.extend(() => { +export const extendGraphqlSchema = g.extend(() => { return { query: { - someNumber: graphql.field({ - type: graphql.nonNull(graphql.Int), + someNumber: g.field({ + type: g.nonNull(g.Int), resolve: () => 1, }), }, From f7ffc0342238a059e3d96b809cd99a20741a89ee Mon Sep 17 00:00:00 2001 From: Emma Hamilton Date: Mon, 3 Feb 2025 15:04:07 +1000 Subject: [PATCH 4/7] Update usage in resolve-admin-meta.ts --- packages/core/src/lib/resolve-admin-meta.ts | 196 ++++++++++---------- 1 file changed, 98 insertions(+), 98 deletions(-) diff --git a/packages/core/src/lib/resolve-admin-meta.ts b/packages/core/src/lib/resolve-admin-meta.ts index 798354f2672..c41b696c4d2 100644 --- a/packages/core/src/lib/resolve-admin-meta.ts +++ b/packages/core/src/lib/resolve-admin-meta.ts @@ -20,69 +20,69 @@ import type { ListMetaRootVal, } from './create-admin-meta' -const graphql = { +const g = { ...graphqlBoundToKeystoneContext, ...graphqlBoundToKeystoneContext.bindGraphQLSchemaAPIToContext(), } -const KeystoneAdminUIFieldMeta = graphql.object()({ +const KeystoneAdminUIFieldMeta = g.object()({ name: 'KeystoneAdminUIFieldMeta', fields: { - path: graphql.field({ type: graphql.nonNull(graphql.String) }), - label: graphql.field({ type: graphql.nonNull(graphql.String) }), - description: graphql.field({ type: graphql.String }), - ...contextFunctionField('isOrderable', graphql.Boolean), - ...contextFunctionField('isFilterable', graphql.Boolean), - isNonNull: graphql.field({ - type: graphql.list( - graphql.nonNull( - graphql.enum({ + path: g.field({ type: g.nonNull(g.String) }), + label: g.field({ type: g.nonNull(g.String) }), + description: g.field({ type: g.String }), + ...contextFunctionField('isOrderable', g.Boolean), + ...contextFunctionField('isFilterable', g.Boolean), + isNonNull: g.field({ + type: g.list( + g.nonNull( + g.enum({ name: 'KeystoneAdminUIFieldMetaIsNonNull', - values: graphql.enumValues(['read', 'create', 'update']), + values: g.enumValues(['read', 'create', 'update']), }) ) ), }), - fieldMeta: graphql.field({ type: graphql.JSON }), - viewsIndex: graphql.field({ type: graphql.nonNull(graphql.Int) }), - customViewsIndex: graphql.field({ type: graphql.Int }), - createView: graphql.field({ - type: graphql.nonNull( - graphql.object()({ + fieldMeta: g.field({ type: g.JSON }), + viewsIndex: g.field({ type: g.nonNull(g.Int) }), + customViewsIndex: g.field({ type: g.Int }), + createView: g.field({ + type: g.nonNull( + g.object()({ name: 'KeystoneAdminUIFieldMetaCreateView', fields: contextFunctionField( 'fieldMode', - graphql.enum({ + g.enum({ name: 'KeystoneAdminUIFieldMetaCreateViewFieldMode', - values: graphql.enumValues(['edit', 'hidden']), + values: g.enumValues(['edit', 'hidden']), }) ), }) ), }), - listView: graphql.field({ - type: graphql.nonNull( - graphql.object()({ + listView: g.field({ + type: g.nonNull( + g.object()({ name: 'KeystoneAdminUIFieldMetaListView', fields: contextFunctionField( 'fieldMode', - graphql.enum({ + g.enum({ name: 'KeystoneAdminUIFieldMetaListViewFieldMode', - values: graphql.enumValues(['read', 'hidden']), + values: g.enumValues(['read', 'hidden']), }) ), }) ), }), - itemView: graphql.field({ - args: { id: graphql.arg({ type: graphql.ID, }) }, + itemView: g.field({ + args: { id: g.arg({ type: g.ID, }) }, resolve: ({ itemView, listKey }, { id }) => ({ listKey, fieldMode: itemView.fieldMode, itemId: id ?? null, fieldPosition: itemView.fieldPosition, }), - type: graphql.object<{ + type: g.object<{ listKey: string fieldMode: FieldMetaRootVal['itemView']['fieldMode'] fieldPosition: FieldMetaRootVal['itemView']['fieldPosition'] @@ -90,10 +90,10 @@ const KeystoneAdminUIFieldMeta = graphql.object()({ }>()({ name: 'KeystoneAdminUIFieldMetaItemView', fields: { - fieldMode: graphql.field({ - type: graphql.enum({ + fieldMode: g.field({ + type: g.enum({ name: 'KeystoneAdminUIFieldMetaItemViewFieldMode', - values: graphql.enumValues(['edit', 'read', 'hidden']), + values: g.enumValues(['edit', 'read', 'hidden']), }), async resolve ({ fieldMode, itemId, listKey }, args, context, info) { if (typeof fieldMode !== 'function') return fieldMode @@ -106,10 +106,10 @@ const KeystoneAdminUIFieldMeta = graphql.object()({ }) }, }), - fieldPosition: graphql.field({ - type: graphql.enum({ + fieldPosition: g.field({ + type: g.enum({ name: 'KeystoneAdminUIFieldMetaItemViewFieldPosition', - values: graphql.enumValues(['form', 'sidebar']), + values: g.enumValues(['form', 'sidebar']), }), async resolve ({ fieldPosition, itemId, listKey }, args, context, info) { if (typeof fieldPosition !== 'function') return fieldPosition @@ -125,116 +125,116 @@ const KeystoneAdminUIFieldMeta = graphql.object()({ }, }), }), - search: graphql.field({ + search: g.field({ type: QueryMode, }), }, }) -const KeystoneAdminUIFieldGroupMeta = graphql.object()({ +const KeystoneAdminUIFieldGroupMeta = g.object()({ name: 'KeystoneAdminUIFieldGroupMeta', fields: { - label: graphql.field({ type: graphql.nonNull(graphql.String) }), - description: graphql.field({ type: graphql.String }), - fields: graphql.field({ - type: graphql.nonNull(graphql.list(graphql.nonNull(KeystoneAdminUIFieldMeta))), + label: g.field({ type: g.nonNull(g.String) }), + description: g.field({ type: g.String }), + fields: g.field({ + type: g.nonNull(g.list(g.nonNull(KeystoneAdminUIFieldMeta))), }), }, }) -const KeystoneAdminUISort = graphql.object>()({ +const KeystoneAdminUISort = g.object>()({ name: 'KeystoneAdminUISort', fields: { - field: graphql.field({ type: graphql.nonNull(graphql.String) }), - direction: graphql.field({ - type: graphql.nonNull( - graphql.enum({ + field: g.field({ type: g.nonNull(g.String) }), + direction: g.field({ + type: g.nonNull( + g.enum({ name: 'KeystoneAdminUISortDirection', - values: graphql.enumValues(['ASC', 'DESC']), + values: g.enumValues(['ASC', 'DESC']), }) ), }), }, }) -const KeystoneAdminUIGraphQLNames = graphql.object()({ +const KeystoneAdminUIGraphQLNames = g.object()({ name: 'KeystoneAdminUIGraphQLNames', fields: { - outputTypeName: graphql.field({ type: graphql.nonNull(graphql.String) }), - whereInputName: graphql.field({ type: graphql.nonNull(graphql.String) }), - whereUniqueInputName: graphql.field({ type: graphql.nonNull(graphql.String) }), + outputTypeName: g.field({ type: g.nonNull(g.String) }), + whereInputName: g.field({ type: g.nonNull(g.String) }), + whereUniqueInputName: g.field({ type: g.nonNull(g.String) }), // create - createInputName: graphql.field({ type: graphql.nonNull(graphql.String) }), - createMutationName: graphql.field({ type: graphql.nonNull(graphql.String) }), - createManyMutationName: graphql.field({ type: graphql.nonNull(graphql.String) }), - relateToOneForCreateInputName: graphql.field({ type: graphql.nonNull(graphql.String) }), - relateToManyForCreateInputName: graphql.field({ type: graphql.nonNull(graphql.String) }), + createInputName: g.field({ type: g.nonNull(g.String) }), + createMutationName: g.field({ type: g.nonNull(g.String) }), + createManyMutationName: g.field({ type: g.nonNull(g.String) }), + relateToOneForCreateInputName: g.field({ type: g.nonNull(g.String) }), + relateToManyForCreateInputName: g.field({ type: g.nonNull(g.String) }), // read - itemQueryName: graphql.field({ type: graphql.nonNull(graphql.String) }), - listOrderName: graphql.field({ type: graphql.nonNull(graphql.String) }), - listQueryCountName: graphql.field({ type: graphql.nonNull(graphql.String) }), - listQueryName: graphql.field({ type: graphql.nonNull(graphql.String) }), + itemQueryName: g.field({ type: g.nonNull(g.String) }), + listOrderName: g.field({ type: g.nonNull(g.String) }), + listQueryCountName: g.field({ type: g.nonNull(g.String) }), + listQueryName: g.field({ type: g.nonNull(g.String) }), // update - updateInputName: graphql.field({ type: graphql.nonNull(graphql.String) }), - updateMutationName: graphql.field({ type: graphql.nonNull(graphql.String) }), - updateManyInputName: graphql.field({ type: graphql.nonNull(graphql.String) }), - updateManyMutationName: graphql.field({ type: graphql.nonNull(graphql.String) }), - relateToOneForUpdateInputName: graphql.field({ type: graphql.nonNull(graphql.String) }), - relateToManyForUpdateInputName: graphql.field({ type: graphql.nonNull(graphql.String) }), + updateInputName: g.field({ type: g.nonNull(g.String) }), + updateMutationName: g.field({ type: g.nonNull(g.String) }), + updateManyInputName: g.field({ type: g.nonNull(g.String) }), + updateManyMutationName: g.field({ type: g.nonNull(g.String) }), + relateToOneForUpdateInputName: g.field({ type: g.nonNull(g.String) }), + relateToManyForUpdateInputName: g.field({ type: g.nonNull(g.String) }), // delete - deleteMutationName: graphql.field({ type: graphql.nonNull(graphql.String) }), - deleteManyMutationName: graphql.field({ type: graphql.nonNull(graphql.String) }), + deleteMutationName: g.field({ type: g.nonNull(g.String) }), + deleteManyMutationName: g.field({ type: g.nonNull(g.String) }), } }) -const KeystoneAdminUIGraphQL = graphql.object()({ +const KeystoneAdminUIGraphQL = g.object()({ name: 'KeystoneAdminUIGraphQL', fields: { - names: graphql.field({ type: graphql.nonNull(KeystoneAdminUIGraphQLNames) }), + names: g.field({ type: g.nonNull(KeystoneAdminUIGraphQLNames) }), } }) -const KeystoneAdminUIListMeta = graphql.object()({ +const KeystoneAdminUIListMeta = g.object()({ name: 'KeystoneAdminUIListMeta', fields: { - key: graphql.field({ type: graphql.nonNull(graphql.String) }), - path: graphql.field({ type: graphql.nonNull(graphql.String) }), - description: graphql.field({ type: graphql.String }), + key: g.field({ type: g.nonNull(g.String) }), + path: g.field({ type: g.nonNull(g.String) }), + description: g.field({ type: g.String }), - label: graphql.field({ type: graphql.nonNull(graphql.String) }), - labelField: graphql.field({ type: graphql.nonNull(graphql.String) }), - singular: graphql.field({ type: graphql.nonNull(graphql.String) }), - plural: graphql.field({ type: graphql.nonNull(graphql.String) }), + label: g.field({ type: g.nonNull(g.String) }), + labelField: g.field({ type: g.nonNull(g.String) }), + singular: g.field({ type: g.nonNull(g.String) }), + plural: g.field({ type: g.nonNull(g.String) }), - fields: graphql.field({ type: graphql.nonNull(graphql.list(graphql.nonNull(KeystoneAdminUIFieldMeta))), }), - groups: graphql.field({ type: graphql.nonNull(graphql.list(graphql.nonNull(KeystoneAdminUIFieldGroupMeta))), }), - graphql: graphql.field({ type: graphql.nonNull(KeystoneAdminUIGraphQL) }), + fields: g.field({ type: g.nonNull(g.list(g.nonNull(KeystoneAdminUIFieldMeta))), }), + groups: g.field({ type: g.nonNull(g.list(g.nonNull(KeystoneAdminUIFieldGroupMeta))), }), + graphql: g.field({ type: g.nonNull(KeystoneAdminUIGraphQL) }), - pageSize: graphql.field({ type: graphql.nonNull(graphql.Int) }), - initialColumns: graphql.field({ type: graphql.nonNull(graphql.list(graphql.nonNull(graphql.String))), }), - initialSearchFields: graphql.field({ type: graphql.nonNull(graphql.list(graphql.nonNull(graphql.String))), }), - initialSort: graphql.field({ type: KeystoneAdminUISort }), - isSingleton: graphql.field({ type: graphql.nonNull(graphql.Boolean) }), + pageSize: g.field({ type: g.nonNull(g.Int) }), + initialColumns: g.field({ type: g.nonNull(g.list(g.nonNull(g.String))), }), + initialSearchFields: g.field({ type: g.nonNull(g.list(g.nonNull(g.String))), }), + initialSort: g.field({ type: KeystoneAdminUISort }), + isSingleton: g.field({ type: g.nonNull(g.Boolean) }), - ...contextFunctionField('hideNavigation', graphql.Boolean), - ...contextFunctionField('hideCreate', graphql.Boolean), - ...contextFunctionField('hideDelete', graphql.Boolean), + ...contextFunctionField('hideNavigation', g.Boolean), + ...contextFunctionField('hideCreate', g.Boolean), + ...contextFunctionField('hideDelete', g.Boolean), }, }) -const adminMeta = graphql.object()({ +const adminMeta = g.object()({ name: 'KeystoneAdminMeta', fields: { - lists: graphql.field({ - type: graphql.nonNull(graphql.list(graphql.nonNull(KeystoneAdminUIListMeta))), + lists: g.field({ + type: g.nonNull(g.list(g.nonNull(KeystoneAdminUIListMeta))), }), - list: graphql.field({ + list: g.field({ type: KeystoneAdminUIListMeta, - args: { key: graphql.arg({ type: graphql.nonNull(graphql.String) }) }, + args: { key: g.arg({ type: g.nonNull(g.String) }) }, resolve (rootVal, { key }) { return rootVal.listsByKey[key] }, @@ -242,11 +242,11 @@ const adminMeta = graphql.object()({ }, }) -export const KeystoneMeta = graphql.object<{ adminMeta: AdminMetaRootVal }>()({ +export const KeystoneMeta = g.object<{ adminMeta: AdminMetaRootVal }>()({ name: 'KeystoneMeta', fields: { - adminMeta: graphql.field({ - type: graphql.nonNull(adminMeta), + adminMeta: g.field({ + type: g.nonNull(adminMeta), resolve ({ adminMeta }, args, context, info) { return Promise.resolve(adminMeta.isAccessAllowed(context)).then(isAllowed => { if (isAllowed) return adminMeta @@ -291,8 +291,8 @@ function contextFunctionField type: ScalarType | EnumType>> ) { return { - [key]: graphql.field({ - type: graphql.nonNull(type), + [key]: g.field({ + type: g.nonNull(type), resolve (source: { [_ in Key]: (context: Context) => MaybePromise }, args, context, info) { From 942d95baad5e3cfb302b5698d0582c11f0f538c1 Mon Sep 17 00:00:00 2001 From: Emma Hamilton Date: Mon, 3 Feb 2025 15:11:08 +1000 Subject: [PATCH 5/7] Update usages of `graphql` from `@graphql-ts/schema` to `g` --- packages/core/src/types/schema/graphql-ts-schema.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/core/src/types/schema/graphql-ts-schema.ts b/packages/core/src/types/schema/graphql-ts-schema.ts index b524a4c027a..6dcbcbd27b8 100644 --- a/packages/core/src/types/schema/graphql-ts-schema.ts +++ b/packages/core/src/types/schema/graphql-ts-schema.ts @@ -123,7 +123,7 @@ type FieldFunc = < export const field = fieldd as FieldFunc // TODO: remove when we use { graphql } from '.keystone' -export const JSON = graphqlTsSchema.graphql.scalar( +export const JSON = graphqlTsSchema.g.scalar( new GraphQLScalarType({ name: 'JSON', description: @@ -140,7 +140,7 @@ type FileUpload = { createReadStream(): ReadStream } -export const Upload = graphqlTsSchema.graphql.scalar>(GraphQLUpload) +export const Upload = graphqlTsSchema.g.scalar>(GraphQLUpload) // - Decimal.js throws on invalid inputs // - Decimal.js can represent +Infinity and -Infinity, these aren't values in Postgres' decimal, @@ -209,7 +209,7 @@ function parseDate (input: string): Date { return parsed } -export const DateTime = graphqlTsSchema.graphql.scalar( +export const DateTime = graphqlTsSchema.g.scalar( new GraphQLScalarType({ name: 'DateTime', specifiedByURL: 'https://datatracker.ietf.org/doc/html/rfc3339#section-5.6', @@ -243,7 +243,7 @@ function validateCalendarDay (input: string) { } } -export const CalendarDay = graphqlTsSchema.graphql.scalar( +export const CalendarDay = graphqlTsSchema.g.scalar( new GraphQLScalarType({ name: 'CalendarDay', specifiedByURL: 'https://datatracker.ietf.org/doc/html/rfc3339#section-5.6', @@ -270,7 +270,7 @@ export const CalendarDay = graphqlTsSchema.graphql.scalar( }) ) -export const Empty = graphqlTsSchema.graphql.scalar( +export const Empty = graphqlTsSchema.g.scalar( new GraphQLScalarType({ name: 'Empty', serialize (value) { return null }, From 97b0f4507223376bbc00fb53d94c0649bcb233ae Mon Sep 17 00:00:00 2001 From: Emma Hamilton Date: Mon, 3 Feb 2025 15:12:22 +1000 Subject: [PATCH 6/7] Update filter generation script to use g instead of graphql --- prisma-utils/main.ts | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/prisma-utils/main.ts b/prisma-utils/main.ts index 20976474f8b..eaa1b0efa6b 100644 --- a/prisma-utils/main.ts +++ b/prisma-utils/main.ts @@ -15,14 +15,14 @@ const SCALARS = ['String', 'Boolean', 'Int', 'Float', 'DateTime', 'Decimal', 'Bi type Scalar = (typeof SCALARS)[number] const GRAPHQL_SCALARS = { - String: 'graphql.String', - Boolean: 'graphql.Boolean', - Int: 'graphql.Int', - Float: 'graphql.Float', - Json: 'graphql.JSON', - DateTime: 'graphql.DateTime', - Decimal: 'graphql.Decimal', - BigInt: 'graphql.BigInt', + String: 'g.String', + Boolean: 'g.Boolean', + Int: 'g.Int', + Float: 'g.Float', + Json: 'g.JSON', + DateTime: 'g.DateTime', + Decimal: 'g.Decimal', + BigInt: 'g.BigInt', } as const function getSchemaForProvider (provider: Provider) { @@ -64,24 +64,24 @@ function generateTSType (scalar: Scalar, filter: DMMF.InputType, nesting: boolea const filterName = filter.name.replace(/Bool/g, 'Boolean') return [ - `type ${filterName}Type = graphql.InputObjectType<{`, + `type ${filterName}Type = g.InputObjectType<{`, ...filter.fields.map(field => { const suffix = field.isNullable ? ` // can be null` : `` if (field.name === 'not') { - if (nesting) return ` ${field.name}: graphql.Arg${suffix}` - return ` ${field.name}: graphql.Arg<${filterName}Type>${suffix}` + if (nesting) return ` ${field.name}: g.Arg${suffix}` + return ` ${field.name}: g.Arg<${filterName}Type>${suffix}` } if (['in', 'notIn'].includes(field.name)) { - return ` ${field.name}: graphql.Arg>>${suffix}` + return ` ${field.name}: g.Arg>>${suffix}` } if (field.name === 'mode') { - return ` ${field.name}: graphql.Arg${suffix}` + return ` ${field.name}: g.Arg${suffix}` } - return ` ${field.name}: graphql.Arg${suffix}` + return ` ${field.name}: g.Arg${suffix}` }), `}>`, ].join('\n') @@ -94,28 +94,28 @@ function generateGQLType (scalar: Scalar, filter: DMMF.InputType, nesting: boole const filterName = filter.name.replace(/Bool/g, 'Boolean') return [ - `const ${filterName}: ${filterName}Type = graphql.inputObject({`, + `const ${filterName}: ${filterName}Type = g.inputObject({`, ` name: '${filterName}',`, ` fields: () => ({`, ...filter.fields.map(field => { const suffix = field.isNullable ? ` // can be null` : `` if (field.name === 'mode') { - return ` ${field.name}: graphql.arg({ type: QueryMode }),${suffix}` + return ` ${field.name}: g.arg({ type: QueryMode }),${suffix}` } if (field.name === 'not') { if (nesting) { - return ` ${field.name}: graphql.arg({ type: Nested${filterName} }),${suffix}` + return ` ${field.name}: g.arg({ type: Nested${filterName} }),${suffix}` } - return ` ${field.name}: graphql.arg({ type: ${filterName} }),${suffix}` + return ` ${field.name}: g.arg({ type: ${filterName} }),${suffix}` } if (['in', 'notIn'].includes(field.name)) { - return ` ${field.name}: graphql.arg({ type: graphql.list(graphql.nonNull(${gqlType})) }),${suffix}` + return ` ${field.name}: g.arg({ type: g.list(g.nonNull(${gqlType})) }),${suffix}` } - return ` ${field.name}: graphql.arg({ type: ${gqlType} }),${suffix}` + return ` ${field.name}: g.arg({ type: ${gqlType} }),${suffix}` }), ` }),`, `})`, @@ -172,7 +172,7 @@ async function generate (provider: Provider) { return [ `// Do not manually modify this file, it is automatically generated by the package at /prisma-utils in this repo.`, - `import { graphql } from '../../../types/schema'`, + `import { g } from '../../../types/schema'`, // case sensitivity is only supported for POSTGRES ...(provider === 'postgresql' From ed6c96b32680e3a2b54744af4a081d446204f4cc Mon Sep 17 00:00:00 2001 From: Emma Hamilton Date: Mon, 3 Feb 2025 15:23:02 +1000 Subject: [PATCH 7/7] Changesets --- .changeset/lemon-oranges-promise.md | 7 +++++++ .changeset/small-kiwis-speak.md | 5 +++++ 2 files changed, 12 insertions(+) create mode 100644 .changeset/lemon-oranges-promise.md create mode 100644 .changeset/small-kiwis-speak.md diff --git a/.changeset/lemon-oranges-promise.md b/.changeset/lemon-oranges-promise.md new file mode 100644 index 00000000000..2c99f55fd23 --- /dev/null +++ b/.changeset/lemon-oranges-promise.md @@ -0,0 +1,7 @@ +--- +"@keystone-6/fields-document": major +"@keystone-6/cloudinary": major +"@keystone-6/auth": major +--- + +Prefer `g` instead of `graphql` when importing from `@keystone-6/core` diff --git a/.changeset/small-kiwis-speak.md b/.changeset/small-kiwis-speak.md new file mode 100644 index 00000000000..7085bef01bd --- /dev/null +++ b/.changeset/small-kiwis-speak.md @@ -0,0 +1,5 @@ +--- +"@keystone-6/core": minor +--- + +Rename `graphql` export to `g` - `graphql` is still exported but is deprecated and may be removed in a future release