@payloadcms/graphql 4.0.0-internal.ccea85d → 4.0.0-internal.cd47d20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/resolvers/collections/find.js +1 -1
- package/dist/resolvers/collections/find.js.map +1 -1
- package/dist/resolvers/collections/findByID.js +1 -1
- package/dist/resolvers/collections/findByID.js.map +1 -1
- package/dist/resolvers/collections/findVersionByID.js +1 -1
- package/dist/resolvers/collections/findVersionByID.js.map +1 -1
- package/dist/resolvers/collections/findVersions.js +1 -1
- package/dist/resolvers/collections/findVersions.js.map +1 -1
- package/dist/resolvers/globals/findOne.js +1 -1
- package/dist/resolvers/globals/findOne.js.map +1 -1
- package/dist/resolvers/globals/findVersionByID.js +1 -1
- package/dist/resolvers/globals/findVersionByID.js.map +1 -1
- package/dist/resolvers/globals/findVersions.js +1 -1
- package/dist/resolvers/globals/findVersions.js.map +1 -1
- package/dist/schema/fieldToSchemaMap.js +3 -3
- package/dist/schema/fieldToSchemaMap.js.map +1 -1
- package/dist/schema/initCollections.d.ts.map +1 -1
- package/dist/schema/initCollections.js +9 -6
- package/dist/schema/initCollections.js.map +1 -1
- package/dist/schema/withOperators.d.ts +6 -0
- package/dist/schema/withOperators.d.ts.map +1 -1
- package/dist/schema/withOperators.js +15 -0
- package/dist/schema/withOperators.js.map +1 -1
- package/dist/utilities/select.d.ts +4 -3
- package/dist/utilities/select.d.ts.map +1 -1
- package/dist/utilities/select.js +83 -45
- package/dist/utilities/select.js.map +1 -1
- package/package.json +3 -3
- package/dist/utilities/formatName.spec.js +0 -57
- package/dist/utilities/formatName.spec.js.map +0 -1
- package/dist/utilities/formatUtcOffset.spec.js +0 -142
- package/dist/utilities/formatUtcOffset.spec.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/schema/initCollections.ts"],"sourcesContent":["import type {\n Collection,\n Field,\n GraphQLInfo,\n SanitizedCollectionConfig,\n SanitizedConfig,\n} from 'payload'\n\nimport {\n GraphQLBoolean,\n GraphQLInt,\n GraphQLNonNull,\n GraphQLObjectType,\n GraphQLString,\n} from 'graphql'\nimport { buildVersionCollectionFields, flattenTopLevelFields, formatNames, toWords } from 'payload'\nimport { fieldAffectsData, getLoginOptions } from 'payload/shared'\n\nimport type { ObjectTypeConfig } from './buildObjectType.js'\n\nimport { forgotPassword } from '../resolvers/auth/forgotPassword.js'\nimport { init } from '../resolvers/auth/init.js'\nimport { login } from '../resolvers/auth/login.js'\nimport { logout } from '../resolvers/auth/logout.js'\nimport { me } from '../resolvers/auth/me.js'\nimport { refresh } from '../resolvers/auth/refresh.js'\nimport { resetPassword } from '../resolvers/auth/resetPassword.js'\nimport { unlock } from '../resolvers/auth/unlock.js'\nimport { verifyEmail } from '../resolvers/auth/verifyEmail.js'\nimport { countResolver } from '../resolvers/collections/count.js'\nimport { createResolver } from '../resolvers/collections/create.js'\nimport { getDeleteResolver } from '../resolvers/collections/delete.js'\nimport { docAccessResolver } from '../resolvers/collections/docAccess.js'\nimport { duplicateResolver } from '../resolvers/collections/duplicate.js'\nimport { findResolver } from '../resolvers/collections/find.js'\nimport { findByIDResolver } from '../resolvers/collections/findByID.js'\nimport { findVersionByIDResolver } from '../resolvers/collections/findVersionByID.js'\nimport { findVersionsResolver } from '../resolvers/collections/findVersions.js'\nimport { restoreVersionResolver } from '../resolvers/collections/restoreVersion.js'\nimport { updateResolver } from '../resolvers/collections/update.js'\nimport { formatName } from '../utilities/formatName.js'\nimport { buildMutationInputType, getCollectionIDType } from './buildMutationInputType.js'\nimport { buildObjectType } from './buildObjectType.js'\nimport { buildPaginatedListType } from './buildPaginatedListType.js'\nimport { buildPolicyType } from './buildPoliciesType.js'\nimport { buildWhereInputType } from './buildWhereInputType.js'\n\ntype InitCollectionsGraphQLArgs = {\n config: SanitizedConfig\n graphqlResult: GraphQLInfo\n}\nexport function initCollections({ config, graphqlResult }: InitCollectionsGraphQLArgs): void {\n Object.keys(graphqlResult.collections).forEach((slug) => {\n const collection: Collection = graphqlResult.collections[slug]\n const {\n config: collectionConfig,\n config: { fields, graphQL = {} as SanitizedCollectionConfig['graphQL'], versions },\n } = collection\n\n if (!graphQL) {\n return\n }\n\n let singularName\n let pluralName\n\n const fromSlug = formatNames(collection.config.slug)\n\n if (graphQL.singularName) {\n singularName = toWords(graphQL.singularName, true)\n } else {\n singularName = fromSlug.singular\n }\n if (graphQL.pluralName) {\n pluralName = toWords(graphQL.pluralName, true)\n } else {\n pluralName = fromSlug.plural\n }\n\n // For collections named 'Media' or similar,\n // there is a possibility that the singular name\n // will equal the plural name. Append `all` to the beginning\n // of potential conflicts\n if (singularName === pluralName) {\n pluralName = `all${singularName}`\n }\n\n collection.graphQL = {} as Collection['graphQL']\n\n const hasIDField =\n flattenTopLevelFields(fields).findIndex(\n (field) => fieldAffectsData(field) && field.name === 'id',\n ) > -1\n\n const idType = getCollectionIDType(config.db.defaultIDType, collectionConfig)\n\n const baseFields: ObjectTypeConfig = {}\n\n const whereInputFields = [...fields]\n\n if (!hasIDField) {\n baseFields.id = { type: new GraphQLNonNull(idType) }\n whereInputFields.push({\n name: 'id',\n type: config.db.defaultIDType as 'text',\n })\n }\n\n const forceNullableObjectType = Boolean(versions?.drafts)\n\n collection.graphQL.type = buildObjectType({\n name: singularName,\n baseFields,\n collectionSlug: collectionConfig.slug,\n config,\n fields,\n forceNullable: forceNullableObjectType,\n graphqlResult,\n parentName: singularName,\n })\n\n collection.graphQL.paginatedType = buildPaginatedListType(pluralName, collection.graphQL.type)\n\n collection.graphQL.whereInputType = buildWhereInputType({\n name: singularName,\n fields: whereInputFields,\n parentName: singularName,\n })\n\n const mutationInputFields = [...fields]\n\n if (\n collectionConfig.auth &&\n (!collectionConfig.auth.disableLocalStrategy ||\n (typeof collectionConfig.auth.disableLocalStrategy === 'object' &&\n collectionConfig.auth.disableLocalStrategy.optionalPassword))\n ) {\n mutationInputFields.push({\n name: 'password',\n type: 'text',\n label: 'Password',\n required: !(\n typeof collectionConfig.auth.disableLocalStrategy === 'object' &&\n collectionConfig.auth.disableLocalStrategy.optionalPassword\n ),\n })\n }\n\n let mutationCreateInputFields = mutationInputFields\n\n if (\n config.db.allowIDOnCreate &&\n !collectionConfig.flattenedFields.some((field) => field.name === 'id')\n ) {\n mutationCreateInputFields = [\n ...mutationCreateInputFields,\n {\n name: 'id',\n type: config.db.defaultIDType,\n } as Field,\n ]\n }\n\n const createMutationInputType = buildMutationInputType({\n name: singularName,\n config,\n fields: mutationCreateInputFields,\n graphqlResult,\n parentIsLocalized: false,\n parentName: singularName,\n })\n if (createMutationInputType) {\n collection.graphQL.mutationInputType = new GraphQLNonNull(createMutationInputType)\n }\n\n const updateMutationInputType = buildMutationInputType({\n name: `${singularName}Update`,\n config,\n fields: mutationInputFields.filter(\n (field) => !(fieldAffectsData(field) && field.name === 'id'),\n ),\n forceNullable: true,\n graphqlResult,\n parentIsLocalized: false,\n parentName: `${singularName}Update`,\n })\n if (updateMutationInputType) {\n collection.graphQL.updateMutationInputType = new GraphQLNonNull(updateMutationInputType)\n }\n\n const queriesEnabled =\n typeof collectionConfig.graphQL !== 'object' || !collectionConfig.graphQL.disableQueries\n const mutationsEnabled =\n typeof collectionConfig.graphQL !== 'object' || !collectionConfig.graphQL.disableMutations\n\n if (queriesEnabled) {\n graphqlResult.Query.fields[singularName] = {\n type: collection.graphQL.type,\n args: {\n id: { type: new GraphQLNonNull(idType) },\n draft: { type: GraphQLBoolean },\n ...(config.localization\n ? {\n fallbackLocale: { type: graphqlResult.types.fallbackLocaleInputType },\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n select: { type: GraphQLBoolean },\n trash: { type: GraphQLBoolean },\n },\n resolve: findByIDResolver(collection),\n }\n\n graphqlResult.Query.fields[pluralName] = {\n type: buildPaginatedListType(pluralName, collection.graphQL.type),\n args: {\n draft: { type: GraphQLBoolean },\n where: { type: collection.graphQL.whereInputType },\n ...(config.localization\n ? {\n fallbackLocale: { type: graphqlResult.types.fallbackLocaleInputType },\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n limit: { type: GraphQLInt },\n page: { type: GraphQLInt },\n pagination: { type: GraphQLBoolean },\n select: { type: GraphQLBoolean },\n sort: { type: GraphQLString },\n trash: { type: GraphQLBoolean },\n },\n resolve: findResolver(collection),\n }\n\n graphqlResult.Query.fields[`count${pluralName}`] = {\n type: new GraphQLObjectType({\n name: `count${pluralName}`,\n fields: {\n totalDocs: { type: GraphQLInt },\n },\n }),\n args: {\n draft: { type: GraphQLBoolean },\n trash: { type: GraphQLBoolean },\n where: { type: collection.graphQL.whereInputType },\n ...(config.localization\n ? {\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n },\n resolve: countResolver(collection),\n }\n\n graphqlResult.Query.fields[`docAccess${singularName}`] = {\n type: buildPolicyType({\n type: 'collection',\n entity: collectionConfig,\n scope: 'docAccess',\n typeSuffix: 'DocAccess',\n }),\n args: {\n id: { type: new GraphQLNonNull(idType) },\n },\n resolve: docAccessResolver(collection),\n }\n }\n\n if (mutationsEnabled) {\n graphqlResult.Mutation.fields[`create${singularName}`] = {\n type: collection.graphQL.type,\n args: {\n ...(createMutationInputType\n ? { data: { type: collection.graphQL.mutationInputType } }\n : {}),\n draft: { type: GraphQLBoolean },\n ...(config.localization\n ? {\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n },\n resolve: createResolver(collection),\n }\n\n graphqlResult.Mutation.fields[`update${singularName}`] = {\n type: collection.graphQL.type,\n args: {\n id: { type: new GraphQLNonNull(idType) },\n autosave: { type: GraphQLBoolean },\n ...(updateMutationInputType\n ? { data: { type: collection.graphQL.updateMutationInputType } }\n : {}),\n draft: { type: GraphQLBoolean },\n ...(config.localization\n ? {\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n trash: { type: GraphQLBoolean },\n },\n resolve: updateResolver(collection),\n }\n\n graphqlResult.Mutation.fields[`delete${singularName}`] = {\n type: collection.graphQL.type,\n args: {\n id: { type: new GraphQLNonNull(idType) },\n trash: { type: GraphQLBoolean },\n },\n resolve: getDeleteResolver(collection),\n }\n\n if (collectionConfig.disableDuplicate !== true) {\n graphqlResult.Mutation.fields[`duplicate${singularName}`] = {\n type: collection.graphQL.type,\n args: {\n id: { type: new GraphQLNonNull(idType) },\n ...(createMutationInputType\n ? { data: { type: collection.graphQL.mutationInputType } }\n : {}),\n },\n resolve: duplicateResolver(collection),\n }\n }\n }\n\n if (collectionConfig.versions) {\n const versionIDType = config.db.defaultIDType === 'text' ? GraphQLString : GraphQLInt\n const versionCollectionFields: Field[] = [\n ...buildVersionCollectionFields(config, collectionConfig),\n {\n name: 'id',\n type: config.db.defaultIDType as 'text',\n },\n {\n name: 'createdAt',\n type: 'date',\n label: ({ t }) => t('general:createdAt'),\n },\n {\n name: 'updatedAt',\n type: 'date',\n label: ({ t }) => t('general:updatedAt'),\n },\n ]\n\n collection.graphQL.versionType = buildObjectType({\n name: `${singularName}Version`,\n collectionSlug: collectionConfig.slug,\n config,\n fields: versionCollectionFields,\n forceNullable: forceNullableObjectType,\n graphqlResult,\n parentName: `${singularName}Version`,\n })\n\n if (queriesEnabled) {\n graphqlResult.Query.fields[`version${formatName(singularName)}`] = {\n type: collection.graphQL.versionType,\n args: {\n id: { type: versionIDType },\n ...(config.localization\n ? {\n fallbackLocale: { type: graphqlResult.types.fallbackLocaleInputType },\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n trash: { type: GraphQLBoolean },\n },\n resolve: findVersionByIDResolver(collection),\n }\n graphqlResult.Query.fields[`versions${pluralName}`] = {\n type: buildPaginatedListType(\n `versions${formatName(pluralName)}`,\n collection.graphQL.versionType,\n ),\n args: {\n where: {\n type: buildWhereInputType({\n name: `versions${singularName}`,\n fields: versionCollectionFields,\n parentName: `versions${singularName}`,\n }),\n },\n ...(config.localization\n ? {\n fallbackLocale: { type: graphqlResult.types.fallbackLocaleInputType },\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n limit: { type: GraphQLInt },\n page: { type: GraphQLInt },\n pagination: { type: GraphQLBoolean },\n select: { type: GraphQLBoolean },\n sort: { type: GraphQLString },\n trash: { type: GraphQLBoolean },\n },\n resolve: findVersionsResolver(collection),\n }\n }\n\n if (mutationsEnabled) {\n graphqlResult.Mutation.fields[`restoreVersion${formatName(singularName)}`] = {\n type: collection.graphQL.type,\n args: {\n id: { type: versionIDType },\n draft: { type: GraphQLBoolean },\n },\n resolve: restoreVersionResolver(collection),\n }\n }\n }\n\n if (collectionConfig.auth) {\n const authFields: Field[] =\n collectionConfig.auth.disableLocalStrategy ||\n (collectionConfig.auth.loginWithUsername &&\n !collectionConfig.auth.loginWithUsername.allowEmailLogin &&\n !collectionConfig.auth.loginWithUsername.requireEmail)\n ? []\n : [\n {\n name: 'email',\n type: 'email',\n required: true,\n },\n ]\n collection.graphQL.JWT = buildObjectType({\n name: formatName(`${slug}JWT`),\n config,\n fields: [\n ...collectionConfig.fields.filter((field) => fieldAffectsData(field) && field.saveToJWT),\n ...authFields,\n {\n name: 'collection',\n type: 'text',\n required: true,\n },\n ],\n graphqlResult,\n parentName: formatName(`${slug}JWT`),\n })\n\n if (queriesEnabled) {\n graphqlResult.Query.fields[`me${singularName}`] = {\n type: new GraphQLObjectType({\n name: formatName(`${slug}Me`),\n fields: {\n collection: {\n type: GraphQLString,\n },\n exp: {\n type: GraphQLInt,\n },\n strategy: {\n type: GraphQLString,\n },\n token: {\n type: GraphQLString,\n },\n user: {\n type: collection.graphQL.type,\n },\n },\n }),\n resolve: me(collection),\n }\n\n graphqlResult.Query.fields[`initialized${singularName}`] = {\n type: GraphQLBoolean,\n resolve: init(collection.config.slug),\n }\n }\n\n if (mutationsEnabled) {\n graphqlResult.Mutation.fields[`refreshToken${singularName}`] = {\n type: new GraphQLObjectType({\n name: formatName(`${slug}Refreshed${singularName}`),\n fields: {\n exp: {\n type: GraphQLInt,\n },\n refreshedToken: {\n type: GraphQLString,\n },\n strategy: {\n type: GraphQLString,\n },\n user: {\n type: collection.graphQL.JWT,\n },\n },\n }),\n resolve: refresh(collection),\n }\n\n graphqlResult.Mutation.fields[`logout${singularName}`] = {\n type: GraphQLString,\n args: {\n allSessions: { type: GraphQLBoolean },\n },\n resolve: logout(collection),\n }\n\n if (!collectionConfig.auth.disableLocalStrategy) {\n const authArgs = {}\n\n const { canLoginWithEmail, canLoginWithUsername } = getLoginOptions(\n collectionConfig.auth.loginWithUsername,\n )\n\n if (canLoginWithEmail) {\n authArgs['email'] = { type: new GraphQLNonNull(GraphQLString) }\n }\n if (canLoginWithUsername) {\n authArgs['username'] = { type: new GraphQLNonNull(GraphQLString) }\n }\n\n if (collectionConfig.auth.maxLoginAttempts > 0) {\n graphqlResult.Mutation.fields[`unlock${singularName}`] = {\n type: new GraphQLNonNull(GraphQLBoolean),\n args: authArgs,\n resolve: unlock(collection),\n }\n }\n\n graphqlResult.Mutation.fields[`login${singularName}`] = {\n type: new GraphQLObjectType({\n name: formatName(`${slug}LoginResult`),\n fields: {\n exp: {\n type: GraphQLInt,\n },\n token: {\n type: GraphQLString,\n },\n user: {\n type: collection.graphQL.type,\n },\n },\n }),\n args: {\n ...authArgs,\n password: { type: GraphQLString },\n },\n resolve: login(collection),\n }\n\n graphqlResult.Mutation.fields[`forgotPassword${singularName}`] = {\n type: new GraphQLNonNull(GraphQLBoolean),\n args: {\n ...authArgs,\n },\n resolve: forgotPassword(collection),\n }\n\n graphqlResult.Mutation.fields[`resetPassword${singularName}`] = {\n type: new GraphQLObjectType({\n name: formatName(`${slug}ResetPassword`),\n fields: {\n token: { type: GraphQLString },\n user: { type: collection.graphQL.type },\n },\n }),\n args: {\n password: { type: GraphQLString },\n token: { type: GraphQLString },\n },\n resolve: resetPassword(collection),\n }\n\n graphqlResult.Mutation.fields[`verifyEmail${singularName}`] = {\n type: GraphQLBoolean,\n args: {\n token: { type: GraphQLString },\n },\n resolve: verifyEmail(collection),\n }\n }\n }\n }\n })\n}\n"],"names":["GraphQLBoolean","GraphQLInt","GraphQLNonNull","GraphQLObjectType","GraphQLString","buildVersionCollectionFields","flattenTopLevelFields","formatNames","toWords","fieldAffectsData","getLoginOptions","forgotPassword","init","login","logout","me","refresh","resetPassword","unlock","verifyEmail","countResolver","createResolver","getDeleteResolver","docAccessResolver","duplicateResolver","findResolver","findByIDResolver","findVersionByIDResolver","findVersionsResolver","restoreVersionResolver","updateResolver","formatName","buildMutationInputType","getCollectionIDType","buildObjectType","buildPaginatedListType","buildPolicyType","buildWhereInputType","initCollections","config","graphqlResult","Object","keys","collections","forEach","slug","collection","collectionConfig","fields","graphQL","versions","singularName","pluralName","fromSlug","singular","plural","hasIDField","findIndex","field","name","idType","db","defaultIDType","baseFields","whereInputFields","id","type","push","forceNullableObjectType","Boolean","drafts","collectionSlug","forceNullable","parentName","paginatedType","whereInputType","mutationInputFields","auth","disableLocalStrategy","optionalPassword","label","required","mutationCreateInputFields","allowIDOnCreate","flattenedFields","some","createMutationInputType","parentIsLocalized","mutationInputType","updateMutationInputType","filter","queriesEnabled","disableQueries","mutationsEnabled","disableMutations","Query","args","draft","localization","fallbackLocale","types","fallbackLocaleInputType","locale","localeInputType","select","trash","resolve","where","limit","page","pagination","sort","totalDocs","entity","scope","typeSuffix","Mutation","data","autosave","disableDuplicate","versionIDType","versionCollectionFields","t","versionType","authFields","loginWithUsername","allowEmailLogin","requireEmail","JWT","saveToJWT","exp","strategy","token","user","refreshedToken","allSessions","authArgs","canLoginWithEmail","canLoginWithUsername","maxLoginAttempts","password"],"mappings":"AAQA,SACEA,cAAc,EACdC,UAAU,EACVC,cAAc,EACdC,iBAAiB,EACjBC,aAAa,QACR,UAAS;AAChB,SAASC,4BAA4B,EAAEC,qBAAqB,EAAEC,WAAW,EAAEC,OAAO,QAAQ,UAAS;AACnG,SAASC,gBAAgB,EAAEC,eAAe,QAAQ,iBAAgB;AAIlE,SAASC,cAAc,QAAQ,sCAAqC;AACpE,SAASC,IAAI,QAAQ,4BAA2B;AAChD,SAASC,KAAK,QAAQ,6BAA4B;AACl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;gCAAC;4BACxC;wBACF;wBACA8B,MAAM;4BACJ4C,UAAU;gCAAE1E,MAAM9D;4BAAc;4BAChCgI,OAAO;gCAAElE,MAAM9D;4BAAc;wBAC/B;wBACAsG,SAASzF,cAAc6B;oBACzB;oBAEAN,cAAc4E,QAAQ,CAACpE,MAAM,CAAC,CAAC,WAAW,EAAEG,cAAc,CAAC,GAAG;wBAC5De,MAAMlE;wBACNgG,MAAM;4BACJoC,OAAO;gCAAElE,MAAM9D;4BAAc;wBAC/B;wBACAsG,SAASvF,YAAY2B;oBACvB;gBACF;YACF;QACF;IACF;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../src/schema/initCollections.ts"],"sourcesContent":["import type {\n Collection,\n Field,\n GraphQLInfo,\n SanitizedCollectionConfig,\n SanitizedConfig,\n} from 'payload'\n\nimport {\n GraphQLBoolean,\n GraphQLInt,\n GraphQLNonNull,\n GraphQLObjectType,\n GraphQLString,\n} from 'graphql'\nimport { buildVersionCollectionFields, flattenTopLevelFields, formatNames, toWords } from 'payload'\nimport { fieldAffectsData, getLoginOptions } from 'payload/shared'\n\nimport type { ObjectTypeConfig } from './buildObjectType.js'\n\nimport { forgotPassword } from '../resolvers/auth/forgotPassword.js'\nimport { init } from '../resolvers/auth/init.js'\nimport { login } from '../resolvers/auth/login.js'\nimport { logout } from '../resolvers/auth/logout.js'\nimport { me } from '../resolvers/auth/me.js'\nimport { refresh } from '../resolvers/auth/refresh.js'\nimport { resetPassword } from '../resolvers/auth/resetPassword.js'\nimport { unlock } from '../resolvers/auth/unlock.js'\nimport { verifyEmail } from '../resolvers/auth/verifyEmail.js'\nimport { countResolver } from '../resolvers/collections/count.js'\nimport { createResolver } from '../resolvers/collections/create.js'\nimport { getDeleteResolver } from '../resolvers/collections/delete.js'\nimport { docAccessResolver } from '../resolvers/collections/docAccess.js'\nimport { duplicateResolver } from '../resolvers/collections/duplicate.js'\nimport { findResolver } from '../resolvers/collections/find.js'\nimport { findByIDResolver } from '../resolvers/collections/findByID.js'\nimport { findVersionByIDResolver } from '../resolvers/collections/findVersionByID.js'\nimport { findVersionsResolver } from '../resolvers/collections/findVersions.js'\nimport { restoreVersionResolver } from '../resolvers/collections/restoreVersion.js'\nimport { updateResolver } from '../resolvers/collections/update.js'\nimport { formatName } from '../utilities/formatName.js'\nimport { buildMutationInputType, getCollectionIDType } from './buildMutationInputType.js'\nimport { buildObjectType } from './buildObjectType.js'\nimport { buildPaginatedListType } from './buildPaginatedListType.js'\nimport { buildPolicyType } from './buildPoliciesType.js'\nimport { buildWhereInputType } from './buildWhereInputType.js'\n\ntype InitCollectionsGraphQLArgs = {\n config: SanitizedConfig\n graphqlResult: GraphQLInfo\n}\nexport function initCollections({ config, graphqlResult }: InitCollectionsGraphQLArgs): void {\n Object.keys(graphqlResult.collections).forEach((slug) => {\n const collection: Collection = graphqlResult.collections[slug]\n const {\n config: collectionConfig,\n config: { fields, graphQL = {} as SanitizedCollectionConfig['graphQL'], versions },\n } = collection\n\n if (!graphQL) {\n return\n }\n\n let singularName\n let pluralName\n\n const fromSlug = formatNames(collection.config.slug)\n\n if (graphQL.singularName) {\n singularName = toWords(graphQL.singularName, true)\n } else {\n singularName = fromSlug.singular\n }\n if (graphQL.pluralName) {\n pluralName = toWords(graphQL.pluralName, true)\n } else {\n pluralName = fromSlug.plural\n }\n\n // For collections named 'Media' or similar,\n // there is a possibility that the singular name\n // will equal the plural name. Append `all` to the beginning\n // of potential conflicts\n if (singularName === pluralName) {\n pluralName = `all${singularName}`\n }\n\n collection.graphQL = {} as Collection['graphQL']\n\n const hasIDField =\n flattenTopLevelFields(fields).findIndex(\n (field) => fieldAffectsData(field) && field.name === 'id',\n ) > -1\n\n const idType = getCollectionIDType(config.db.defaultIDType, collectionConfig)\n\n const baseFields: ObjectTypeConfig = {}\n\n const whereInputFields = [...fields]\n\n if (!hasIDField) {\n baseFields.id = { type: new GraphQLNonNull(idType) }\n whereInputFields.push({\n name: 'id',\n type: config.db.defaultIDType as 'text',\n })\n }\n\n if (collectionConfig.auth) {\n baseFields._strategy = { type: GraphQLString }\n }\n\n const forceNullableObjectType = Boolean(versions?.drafts)\n\n collection.graphQL.type = buildObjectType({\n name: singularName,\n baseFields,\n collectionSlug: collectionConfig.slug,\n config,\n fields,\n forceNullable: forceNullableObjectType,\n graphqlResult,\n parentName: singularName,\n })\n\n collection.graphQL.paginatedType = buildPaginatedListType(pluralName, collection.graphQL.type)\n\n collection.graphQL.whereInputType = buildWhereInputType({\n name: singularName,\n fields: whereInputFields,\n parentName: singularName,\n })\n\n const mutationInputFields = [...fields]\n\n if (\n collectionConfig.auth &&\n (!collectionConfig.auth.disableLocalStrategy ||\n (typeof collectionConfig.auth.disableLocalStrategy === 'object' &&\n collectionConfig.auth.disableLocalStrategy.optionalPassword))\n ) {\n mutationInputFields.push({\n name: 'password',\n type: 'text',\n label: 'Password',\n required: !(\n typeof collectionConfig.auth.disableLocalStrategy === 'object' &&\n collectionConfig.auth.disableLocalStrategy.optionalPassword\n ),\n })\n }\n\n let mutationCreateInputFields = mutationInputFields\n\n if (\n config.db.allowIDOnCreate &&\n !collectionConfig.flattenedFields.some((field) => field.name === 'id')\n ) {\n mutationCreateInputFields = [\n ...mutationCreateInputFields,\n {\n name: 'id',\n type: config.db.defaultIDType,\n } as Field,\n ]\n }\n\n const createMutationInputType = buildMutationInputType({\n name: singularName,\n config,\n fields: mutationCreateInputFields,\n graphqlResult,\n parentIsLocalized: false,\n parentName: singularName,\n })\n if (createMutationInputType) {\n collection.graphQL.mutationInputType = new GraphQLNonNull(createMutationInputType)\n }\n\n const updateMutationInputType = buildMutationInputType({\n name: `${singularName}Update`,\n config,\n fields: mutationInputFields.filter(\n (field) => !(fieldAffectsData(field) && field.name === 'id'),\n ),\n forceNullable: true,\n graphqlResult,\n parentIsLocalized: false,\n parentName: `${singularName}Update`,\n })\n if (updateMutationInputType) {\n collection.graphQL.updateMutationInputType = new GraphQLNonNull(updateMutationInputType)\n }\n\n const queriesEnabled =\n typeof collectionConfig.graphQL !== 'object' || !collectionConfig.graphQL.disableQueries\n const mutationsEnabled =\n typeof collectionConfig.graphQL !== 'object' || !collectionConfig.graphQL.disableMutations\n\n if (queriesEnabled) {\n graphqlResult.Query.fields[singularName] = {\n type: collection.graphQL.type,\n args: {\n id: { type: new GraphQLNonNull(idType) },\n draft: { type: GraphQLBoolean },\n ...(config.localization\n ? {\n fallbackLocale: { type: graphqlResult.types.fallbackLocaleInputType },\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n select: { type: GraphQLBoolean },\n trash: { type: GraphQLBoolean },\n },\n resolve: findByIDResolver(collection),\n }\n\n graphqlResult.Query.fields[pluralName] = {\n type: buildPaginatedListType(pluralName, collection.graphQL.type),\n args: {\n draft: { type: GraphQLBoolean },\n where: { type: collection.graphQL.whereInputType },\n ...(config.localization\n ? {\n fallbackLocale: { type: graphqlResult.types.fallbackLocaleInputType },\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n limit: { type: GraphQLInt },\n page: { type: GraphQLInt },\n pagination: { type: GraphQLBoolean },\n select: { type: GraphQLBoolean },\n sort: { type: GraphQLString },\n trash: { type: GraphQLBoolean },\n },\n resolve: findResolver(collection),\n }\n\n graphqlResult.Query.fields[`count${pluralName}`] = {\n type: new GraphQLObjectType({\n name: `count${pluralName}`,\n fields: {\n totalDocs: { type: GraphQLInt },\n },\n }),\n args: {\n draft: { type: GraphQLBoolean },\n trash: { type: GraphQLBoolean },\n where: { type: collection.graphQL.whereInputType },\n ...(config.localization\n ? {\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n },\n resolve: countResolver(collection),\n }\n\n graphqlResult.Query.fields[`docAccess${singularName}`] = {\n type: buildPolicyType({\n type: 'collection',\n entity: collectionConfig,\n scope: 'docAccess',\n typeSuffix: 'DocAccess',\n }),\n args: {\n id: { type: new GraphQLNonNull(idType) },\n },\n resolve: docAccessResolver(collection),\n }\n }\n\n if (mutationsEnabled) {\n graphqlResult.Mutation.fields[`create${singularName}`] = {\n type: collection.graphQL.type,\n args: {\n ...(createMutationInputType\n ? { data: { type: collection.graphQL.mutationInputType } }\n : {}),\n draft: { type: GraphQLBoolean },\n ...(config.localization\n ? {\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n },\n resolve: createResolver(collection),\n }\n\n graphqlResult.Mutation.fields[`update${singularName}`] = {\n type: collection.graphQL.type,\n args: {\n id: { type: new GraphQLNonNull(idType) },\n autosave: { type: GraphQLBoolean },\n ...(updateMutationInputType\n ? { data: { type: collection.graphQL.updateMutationInputType } }\n : {}),\n draft: { type: GraphQLBoolean },\n ...(config.localization\n ? {\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n trash: { type: GraphQLBoolean },\n },\n resolve: updateResolver(collection),\n }\n\n graphqlResult.Mutation.fields[`delete${singularName}`] = {\n type: collection.graphQL.type,\n args: {\n id: { type: new GraphQLNonNull(idType) },\n trash: { type: GraphQLBoolean },\n },\n resolve: getDeleteResolver(collection),\n }\n\n if (collectionConfig.disableDuplicate !== true) {\n graphqlResult.Mutation.fields[`duplicate${singularName}`] = {\n type: collection.graphQL.type,\n args: {\n id: { type: new GraphQLNonNull(idType) },\n ...(createMutationInputType\n ? { data: { type: collection.graphQL.mutationInputType } }\n : {}),\n },\n resolve: duplicateResolver(collection),\n }\n }\n }\n\n if (collectionConfig.versions) {\n const versionIDType = config.db.defaultIDType === 'text' ? GraphQLString : GraphQLInt\n const versionCollectionFields: Field[] = [\n ...buildVersionCollectionFields(config, collectionConfig),\n {\n name: 'id',\n type: config.db.defaultIDType as 'text',\n },\n {\n name: 'createdAt',\n type: 'date',\n label: ({ t }) => t('general:createdAt'),\n },\n {\n name: 'updatedAt',\n type: 'date',\n label: ({ t }) => t('general:updatedAt'),\n },\n ]\n\n collection.graphQL.versionType = buildObjectType({\n name: `${singularName}Version`,\n collectionSlug: collectionConfig.slug,\n config,\n fields: versionCollectionFields,\n forceNullable: forceNullableObjectType,\n graphqlResult,\n parentName: `${singularName}Version`,\n })\n\n if (queriesEnabled) {\n graphqlResult.Query.fields[`version${formatName(singularName)}`] = {\n type: collection.graphQL.versionType,\n args: {\n id: { type: versionIDType },\n ...(config.localization\n ? {\n fallbackLocale: { type: graphqlResult.types.fallbackLocaleInputType },\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n trash: { type: GraphQLBoolean },\n },\n resolve: findVersionByIDResolver(collection),\n }\n graphqlResult.Query.fields[`versions${pluralName}`] = {\n type: buildPaginatedListType(\n `versions${formatName(pluralName)}`,\n collection.graphQL.versionType,\n ),\n args: {\n where: {\n type: buildWhereInputType({\n name: `versions${singularName}`,\n fields: versionCollectionFields,\n parentName: `versions${singularName}`,\n }),\n },\n ...(config.localization\n ? {\n fallbackLocale: { type: graphqlResult.types.fallbackLocaleInputType },\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n limit: { type: GraphQLInt },\n page: { type: GraphQLInt },\n pagination: { type: GraphQLBoolean },\n select: { type: GraphQLBoolean },\n sort: { type: GraphQLString },\n trash: { type: GraphQLBoolean },\n },\n resolve: findVersionsResolver(collection),\n }\n }\n\n if (mutationsEnabled) {\n graphqlResult.Mutation.fields[`restoreVersion${formatName(singularName)}`] = {\n type: collection.graphQL.type,\n args: {\n id: { type: versionIDType },\n draft: { type: GraphQLBoolean },\n },\n resolve: restoreVersionResolver(collection),\n }\n }\n }\n\n if (collectionConfig.auth) {\n const authFields: Field[] =\n collectionConfig.auth.disableLocalStrategy ||\n (collectionConfig.auth.loginWithUsername &&\n !collectionConfig.auth.loginWithUsername.allowEmailLogin &&\n !collectionConfig.auth.loginWithUsername.requireEmail)\n ? []\n : [\n {\n name: 'email',\n type: 'email',\n required: true,\n },\n ]\n collection.graphQL.JWT = buildObjectType({\n name: formatName(`${slug}JWT`),\n config,\n fields: [\n ...collectionConfig.fields.filter((field) => fieldAffectsData(field) && field.saveToJWT),\n ...authFields,\n {\n name: 'collection',\n type: 'text',\n required: true,\n },\n {\n name: '_strategy',\n type: 'text',\n },\n ],\n graphqlResult,\n parentName: formatName(`${slug}JWT`),\n })\n\n if (queriesEnabled) {\n graphqlResult.Query.fields[`me${singularName}`] = {\n type: new GraphQLObjectType({\n name: formatName(`${slug}Me`),\n fields: {\n collection: {\n type: GraphQLString,\n },\n exp: {\n type: GraphQLInt,\n },\n token: {\n type: GraphQLString,\n },\n user: {\n type: collection.graphQL.type,\n },\n },\n }),\n resolve: me(collection),\n }\n\n graphqlResult.Query.fields[`initialized${singularName}`] = {\n type: GraphQLBoolean,\n resolve: init(collection.config.slug),\n }\n }\n\n if (mutationsEnabled) {\n graphqlResult.Mutation.fields[`refreshToken${singularName}`] = {\n type: new GraphQLObjectType({\n name: formatName(`${slug}Refreshed${singularName}`),\n fields: {\n exp: {\n type: GraphQLInt,\n },\n refreshedToken: {\n type: GraphQLString,\n },\n user: {\n type: collection.graphQL.JWT,\n },\n },\n }),\n resolve: refresh(collection),\n }\n\n graphqlResult.Mutation.fields[`logout${singularName}`] = {\n type: GraphQLString,\n args: {\n allSessions: { type: GraphQLBoolean },\n },\n resolve: logout(collection),\n }\n\n if (!collectionConfig.auth.disableLocalStrategy) {\n const authArgs = {}\n\n const { canLoginWithEmail, canLoginWithUsername } = getLoginOptions(\n collectionConfig.auth.loginWithUsername,\n )\n\n if (canLoginWithEmail) {\n authArgs['email'] = { type: new GraphQLNonNull(GraphQLString) }\n }\n if (canLoginWithUsername) {\n authArgs['username'] = { type: new GraphQLNonNull(GraphQLString) }\n }\n\n if (collectionConfig.auth.maxLoginAttempts > 0) {\n graphqlResult.Mutation.fields[`unlock${singularName}`] = {\n type: new GraphQLNonNull(GraphQLBoolean),\n args: authArgs,\n resolve: unlock(collection),\n }\n }\n\n graphqlResult.Mutation.fields[`login${singularName}`] = {\n type: new GraphQLObjectType({\n name: formatName(`${slug}LoginResult`),\n fields: {\n exp: {\n type: GraphQLInt,\n },\n token: {\n type: GraphQLString,\n },\n user: {\n type: collection.graphQL.type,\n },\n },\n }),\n args: {\n ...authArgs,\n password: { type: GraphQLString },\n },\n resolve: login(collection),\n }\n\n graphqlResult.Mutation.fields[`forgotPassword${singularName}`] = {\n type: new GraphQLNonNull(GraphQLBoolean),\n args: {\n ...authArgs,\n },\n resolve: forgotPassword(collection),\n }\n\n graphqlResult.Mutation.fields[`resetPassword${singularName}`] = {\n type: new GraphQLObjectType({\n name: formatName(`${slug}ResetPassword`),\n fields: {\n token: { type: GraphQLString },\n user: { type: collection.graphQL.type },\n },\n }),\n args: {\n password: { type: GraphQLString },\n token: { type: GraphQLString },\n },\n resolve: resetPassword(collection),\n }\n\n graphqlResult.Mutation.fields[`verifyEmail${singularName}`] = {\n type: GraphQLBoolean,\n args: {\n token: { type: GraphQLString },\n },\n resolve: verifyEmail(collection),\n }\n }\n }\n }\n })\n}\n"],"names":["GraphQLBoolean","GraphQLInt","GraphQLNonNull","GraphQLObjectType","GraphQLString","buildVersionCollectionFields","flattenTopLevelFields","formatNames","toWords","fieldAffectsData","getLoginOptions","forgotPassword","init","login","logout","me","refresh","resetPassword","unlock","verifyEmail","countResolver","createResolver","getDeleteResolver","docAccessResolver","duplicateResolver","findResolver","findByIDResolver","findVersionByIDResolver","findVersionsResolver","restoreVersionResolver","updateResolver","formatName","buildMutationInputType","getCollectionIDType","buildObjectType","buildPaginatedListType","buildPolicyType","buildWhereInputType","initCollections","config","graphqlResult","Object","keys","collections","forEach","slug","collection","collectionConfig","fields","graphQL","versions","singularName","pluralName","fromSlug","singular","plural","hasIDField","findIndex","field","name","idType","db","defaultIDType","baseFields","whereInputFields","id","type","push","auth","_strategy","forceNullableObjectType","Boolean","drafts","collectionSlug","forceNullable","parentName","paginatedType","whereInputType","mutationInputFields","disableLocalStrategy","optionalPassword","label","required","mutationCreateInputFields","allowIDOnCreate","flattenedFields","some","createMutationInputType","parentIsLocalized","mutationInputType","updateMutationInputType","filter","queriesEnabled","disableQueries","mutationsEnabled","disableMutations","Query","args","draft","localization","fallbackLocale","types","fallbackLocaleInputType","locale","localeInputType","select","trash","resolve","where","limit","page","pagination","sort","totalDocs","entity","scope","typeSuffix","Mutation","data","autosave","disableDuplicate","versionIDType","versionCollectionFields","t","versionType","authFields","loginWithUsername","allowEmailLogin","requireEmail","JWT","saveToJWT","exp","token","user","refreshedToken","allSessions","authArgs","canLoginWithEmail","canLoginWithUsername","maxLoginAttempts","password"],"mappings":"AAQA,SACEA,cAAc,EACdC,UAAU,EACVC,cAAc,EACdC,iBAAiB,EACjBC,aAAa,QACR,UAAS;AAChB,SAASC,4BAA4B,EAAEC,qBAAqB,EAAEC,WAAW,EAAEC,OAAO,QAAQ,UAAS;AACnG,SAASC,gBAAgB,EAAEC,eAAe,QAAQ,iBAAgB;AAIlE,SAASC,cAAc,QAAQ,sCAAqC;AACpE,SAASC,IAAI,QAAQ,4BAA2B;AAChD,SAASC,KAAK,QAAQ,6BAA4B;AAClD,SAASC,MAAM,QAAQ,8BAA6B;AACpD,SAASC,EAAE,QAAQ,0BAAyB;AAC5C,SAASC,OAAO,QAAQ,+BAA8B;AACtD,SAASC,aAAa,QAAQ,qCAAoC;AAClE,SAASC,MAAM,QAAQ,8BAA6B;AACpD,SAASC,WAAW,QAAQ,mCAAkC;AAC9D,SAASC,aAAa,QAAQ,oCAAmC;AACjE,SAASC,cAAc,QAAQ,qCAAoC;AACnE,SAASC,iBAAiB,QAAQ,qCAAoC;AACtE,SAASC,iBAAiB,QAAQ,wCAAuC;AACzE,SAASC,iBAAiB,QAAQ,wCAAuC;AACzE,SAASC,YAAY,QAAQ,mCAAkC;AAC/D,SAASC,gBAAgB,QAAQ,uCAAsC;AACvE,SAASC,uBAAuB,QAAQ,8CAA6C;AACrF,SAASC,oBAAoB,QAAQ,2CAA0C;AAC/E,SAASC,sBAAsB,QAAQ,6CAA4C;AACnF,SAASC,cAAc,QAAQ,qCAAoC;AACnE,SAASC,UAAU,QAAQ,6BAA4B;AACvD,SAASC,sBAAsB,EAAEC,mBAAmB,QAAQ,8BAA6B;AACzF,SAASC,eAAe,QAAQ,uBAAsB;AACtD,S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AE1E,MAAM9D;4BAAc;wBAClC;wBACAuG,SAAS9F,MAAMiC;oBACjB;oBAEAN,cAAc6E,QAAQ,CAACrE,MAAM,CAAC,CAAC,cAAc,EAAEG,cAAc,CAAC,GAAG;wBAC/De,MAAM,IAAIhE,eAAeF;wBACzBiG,MAAM;4BACJ,GAAGuC,QAAQ;wBACb;wBACA7B,SAAShG,eAAemC;oBAC1B;oBAEAN,cAAc6E,QAAQ,CAACrE,MAAM,CAAC,CAAC,aAAa,EAAEG,cAAc,CAAC,GAAG;wBAC9De,MAAM,IAAI/D,kBAAkB;4BAC1BwD,MAAM5B,WAAW,GAAGc,KAAK,aAAa,CAAC;4BACvCG,QAAQ;gCACNoF,OAAO;oCAAElE,MAAM9D;gCAAc;gCAC7BiI,MAAM;oCAAEnE,MAAMpB,WAAWG,OAAO,CAACiB,IAAI;gCAAC;4BACxC;wBACF;wBACA+B,MAAM;4BACJ2C,UAAU;gCAAE1E,MAAM9D;4BAAc;4BAChCgI,OAAO;gCAAElE,MAAM9D;4BAAc;wBAC/B;wBACAuG,SAAS1F,cAAc6B;oBACzB;oBAEAN,cAAc6E,QAAQ,CAACrE,MAAM,CAAC,CAAC,WAAW,EAAEG,cAAc,CAAC,GAAG;wBAC5De,MAAMlE;wBACNiG,MAAM;4BACJmC,OAAO;gCAAElE,MAAM9D;4BAAc;wBAC/B;wBACAuG,SAASxF,YAAY2B;oBACvB;gBACF;YACF;QACF;IACF;AACF"}
|
|
@@ -11,6 +11,12 @@ import { GraphQLInputObjectType } from 'graphql';
|
|
|
11
11
|
* @param field the field for which their valid operators inside a "where" argument is being defined
|
|
12
12
|
* @param parentName the name of the parent field (if any)
|
|
13
13
|
* @returns all the operators (including their types) which can be used as a condition for a given field inside a where
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* A has-many relationship accepts a nested query with its relationship operators:
|
|
17
|
+
* ```graphql
|
|
18
|
+
* Burgers(where: { ingredients: { not_equals: { isHealthy: { equals: false } } } })
|
|
19
|
+
* ```
|
|
14
20
|
*/
|
|
15
21
|
export declare const withOperators: (field: FieldAffectingData, parentName: string) => GraphQLInputObjectType;
|
|
16
22
|
//# sourceMappingURL=withOperators.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withOperators.d.ts","sourceRoot":"","sources":["../../src/schema/withOperators.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAwC,MAAM,SAAS,CAAA;AAEvF,OAAO,EAIL,sBAAsB,EAIvB,MAAM,SAAS,CAAA;AA8OhB
|
|
1
|
+
{"version":3,"file":"withOperators.d.ts","sourceRoot":"","sources":["../../src/schema/withOperators.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAwC,MAAM,SAAS,CAAA;AAEvF,OAAO,EAIL,sBAAsB,EAIvB,MAAM,SAAS,CAAA;AA8OhB;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,aAAa,UACjB,kBAAkB,cACb,MAAM,KACjB,sBA4DF,CAAA"}
|
|
@@ -249,6 +249,12 @@ const gqlTypeCache = {};
|
|
|
249
249
|
* @param field the field for which their valid operators inside a "where" argument is being defined
|
|
250
250
|
* @param parentName the name of the parent field (if any)
|
|
251
251
|
* @returns all the operators (including their types) which can be used as a condition for a given field inside a where
|
|
252
|
+
*
|
|
253
|
+
* @example
|
|
254
|
+
* A has-many relationship accepts a nested query with its relationship operators:
|
|
255
|
+
* ```graphql
|
|
256
|
+
* Burgers(where: { ingredients: { not_equals: { isHealthy: { equals: false } } } })
|
|
257
|
+
* ```
|
|
252
258
|
*/ export const withOperators = (field, parentName)=>{
|
|
253
259
|
if (!defaults?.[field.type]) {
|
|
254
260
|
throw new Error(`Error: ${field.type} has no defaults configured.`);
|
|
@@ -258,6 +264,15 @@ const gqlTypeCache = {};
|
|
|
258
264
|
const fieldOperators = [
|
|
259
265
|
...defaults[field.type].operators
|
|
260
266
|
];
|
|
267
|
+
// These operators accept a complete `where` query for the one collection targeted by the
|
|
268
|
+
// relationship. Polymorphic relationships are excluded because they can target multiple schemas.
|
|
269
|
+
if ((field.type === 'relationship' || field.type === 'upload') && field.hasMany && typeof field.relationTo === 'string') {
|
|
270
|
+
// `equals` and `not_equals` already exist for relationship fields.
|
|
271
|
+
fieldOperators.push({
|
|
272
|
+
name: 'contains',
|
|
273
|
+
type: GraphQLJSON
|
|
274
|
+
});
|
|
275
|
+
}
|
|
261
276
|
if (!('required' in field) || !field.required) {
|
|
262
277
|
fieldOperators.push({
|
|
263
278
|
name: 'exists',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/schema/withOperators.ts"],"sourcesContent":["import type { GraphQLType } from 'graphql'\nimport type { FieldAffectingData, NumberField, RadioField, SelectField } from 'payload'\n\nimport {\n GraphQLBoolean,\n GraphQLEnumType,\n GraphQLFloat,\n GraphQLInputObjectType,\n GraphQLInt,\n GraphQLList,\n GraphQLString,\n} from 'graphql'\nimport { DateTimeResolver, EmailAddressResolver } from 'graphql-scalars'\nimport { optionIsObject } from 'payload/shared'\n\nimport { GraphQLJSON } from '../packages/graphql-type-json/index.js'\nimport { combineParentName } from '../utilities/combineParentName.js'\nimport { formatName } from '../utilities/formatName.js'\nimport { operators } from './operators.js'\n\ntype staticTypes =\n | 'checkbox'\n | 'code'\n | 'date'\n | 'email'\n | 'json'\n | 'number'\n | 'point'\n | 'relationship'\n | 'richText'\n | 'text'\n | 'textarea'\n | 'upload'\n\ntype dynamicTypes = 'radio' | 'select'\n\nconst GeoJSONObject = new GraphQLInputObjectType({\n name: 'GeoJSONObject',\n fields: {\n type: { type: GraphQLString },\n coordinates: {\n type: GraphQLJSON,\n },\n },\n})\n\ntype DefaultsType = {\n [key in dynamicTypes]: {\n operators: {\n name: string\n type: (field: FieldAffectingData, parentName: string) => GraphQLType\n }[]\n }\n} & {\n [key in staticTypes]: {\n operators: {\n name: string\n type: ((field: FieldAffectingData, parentName: string) => GraphQLType) | GraphQLType\n }[]\n }\n}\n\nconst defaults: DefaultsType = {\n checkbox: {\n operators: [\n ...operators.equality.map((operator) => ({\n name: operator,\n type: GraphQLBoolean,\n })),\n ],\n },\n code: {\n operators: [\n ...[...operators.equality, ...operators.partial].map((operator) => ({\n name: operator,\n type: GraphQLString,\n })),\n ],\n },\n date: {\n operators: [\n ...[...operators.equality, ...operators.comparison, 'like'].map((operator) => ({\n name: operator,\n type: DateTimeResolver,\n })),\n ],\n },\n email: {\n operators: [\n ...[...operators.equality, ...operators.partial, ...operators.contains].map((operator) => ({\n name: operator,\n type: EmailAddressResolver,\n })),\n ],\n },\n json: {\n operators: [\n ...[...operators.equality, ...operators.partial, ...operators.geojson].map((operator) => ({\n name: operator,\n type: GraphQLJSON,\n })),\n ],\n },\n number: {\n operators: [\n ...[...operators.equality, ...operators.comparison].map((operator) => ({\n name: operator,\n type: (field: NumberField): GraphQLType => {\n return field?.name === 'id' ? GraphQLInt : GraphQLFloat\n },\n })),\n ],\n },\n point: {\n operators: [\n ...[...operators.equality, ...operators.comparison, ...operators.geo].map((operator) => ({\n name: operator,\n type: new GraphQLList(GraphQLFloat),\n })),\n ...operators.geojson.map((operator) => ({\n name: operator,\n /**\n * @example:\n * within: {\n * type: \"Polygon\",\n * coordinates: [[\n * [0.0, 0.0],\n * [1.0, 1.0],\n * [1.0, 0.0],\n * [0.0, 0.0],\n * ]],\n * }\n * @example\n * intersects: {\n * type: \"Point\",\n * coordinates: [ 0.5, 0.5 ]\n * }\n */\n type: GeoJSONObject,\n })),\n ],\n },\n radio: {\n operators: [\n ...[...operators.equality, ...operators.partial].map((operator) => ({\n name: operator,\n type: (field: RadioField, parentName): GraphQLType =>\n new GraphQLEnumType({\n name: `${combineParentName(parentName, field.name)}_Input`,\n values: field.options.reduce((values, option) => {\n if (optionIsObject(option)) {\n return {\n ...values,\n [formatName(option.value)]: {\n value: option.value,\n },\n }\n }\n\n return {\n ...values,\n [formatName(option)]: {\n value: option,\n },\n }\n }, {}),\n }),\n })),\n ],\n },\n relationship: {\n operators: [\n ...[...operators.equality, ...operators.contains].map((operator) => ({\n name: operator,\n type: GraphQLJSON,\n })),\n ],\n },\n richText: {\n operators: [\n ...[...operators.equality, ...operators.partial].map((operator) => ({\n name: operator,\n type: GraphQLJSON,\n })),\n ],\n },\n select: {\n operators: [\n ...[...operators.equality, ...operators.contains].map((operator) => ({\n name: operator,\n type: (field: SelectField, parentName): GraphQLType =>\n new GraphQLEnumType({\n name: `${combineParentName(parentName, field.name)}_Input`,\n values: field.options.reduce((values, option) => {\n if (optionIsObject(option)) {\n return {\n ...values,\n [formatName(option.value)]: {\n value: option.value,\n },\n }\n }\n\n return {\n ...values,\n [formatName(option)]: {\n value: option,\n },\n }\n }, {}),\n }),\n })),\n ],\n },\n text: {\n operators: [\n ...[...operators.equality, ...operators.partial, ...operators.contains].map((operator) => ({\n name: operator,\n type: GraphQLString,\n })),\n ],\n },\n textarea: {\n operators: [\n ...[...operators.equality, ...operators.partial].map((operator) => ({\n name: operator,\n type: GraphQLString,\n })),\n ],\n },\n upload: {\n operators: [\n ...[...operators.equality, ...operators.contains].map((operator) => ({\n name: operator,\n type: GraphQLJSON,\n })),\n ],\n },\n // array: n/a\n // group: n/a\n // row: n/a\n // collapsible: n/a\n // tabs: n/a\n}\n\nconst listOperators = ['in', 'not_in', 'all']\n\nconst gqlTypeCache: Record<string, GraphQLType> = {}\n\n/**\n * In GraphQL, you can use \"where\" as an argument to filter a collection. Example:\n * { Posts(where: { title: { equals: \"Hello\" } }) { text } }\n * This function defines the operators for a field's condition in the \"where\" argument of the collection (it thus gets called for every field).\n * For example, in the example above, it would control that\n * - \"equals\" is a valid operator for the \"title\" field\n * - the accepted type of the \"equals\" argument has to be a string.\n *\n * @param field the field for which their valid operators inside a \"where\" argument is being defined\n * @param parentName the name of the parent field (if any)\n * @returns all the operators (including their types) which can be used as a condition for a given field inside a where\n */\nexport const withOperators = (\n field: FieldAffectingData,\n parentName: string,\n): GraphQLInputObjectType => {\n if (!defaults?.[field.type]) {\n throw new Error(`Error: ${field.type} has no defaults configured.`)\n }\n\n const name = `${combineParentName(parentName, field.name)}_operator`\n\n // Get the default operators for the field type which are hard-coded above\n const fieldOperators = [...defaults[field.type].operators]\n\n if (!('required' in field) || !field.required) {\n fieldOperators.push({\n name: 'exists',\n type: fieldOperators[0].type,\n })\n }\n\n return new GraphQLInputObjectType({\n name,\n fields: fieldOperators.reduce((objectTypeFields, operator) => {\n // Get the type of the operator. It can be either static, or dynamic (=> a function)\n let gqlType: GraphQLType =\n typeof operator.type === 'function' ? operator.type(field, parentName) : operator.type\n\n // GraphQL does not allow types with duplicate names, so we use this cache to avoid that.\n // Without this, select and radio fields would have the same name, and GraphQL would throw an error\n // This usually only happens if a custom type is returned from the operator.type function\n if (typeof operator.type === 'function' && 'name' in gqlType) {\n if (gqlTypeCache[gqlType.name]) {\n gqlType = gqlTypeCache[gqlType.name]\n } else {\n gqlTypeCache[gqlType.name] = gqlType\n }\n }\n\n if (listOperators.includes(operator.name)) {\n gqlType = new GraphQLList(gqlType)\n } else if (operator.name === 'exists') {\n gqlType = GraphQLBoolean\n }\n\n return {\n ...objectTypeFields,\n [operator.name]: {\n type: gqlType,\n },\n }\n }, {}),\n })\n}\n"],"names":["GraphQLBoolean","GraphQLEnumType","GraphQLFloat","GraphQLInputObjectType","GraphQLInt","GraphQLList","GraphQLString","DateTimeResolver","EmailAddressResolver","optionIsObject","GraphQLJSON","combineParentName","formatName","operators","GeoJSONObject","name","fields","type","coordinates","defaults","checkbox","equality","map","operator","code","partial","date","comparison","email","contains","json","geojson","number","field","point","geo","radio","parentName","values","options","reduce","option","value","relationship","richText","select","text","textarea","upload","listOperators","gqlTypeCache","withOperators","Error","fieldOperators","required","push","objectTypeFields","gqlType","includes"],"mappings":"AAGA,SACEA,cAAc,EACdC,eAAe,EACfC,YAAY,EACZC,sBAAsB,EACtBC,UAAU,EACVC,WAAW,EACXC,aAAa,QACR,UAAS;AAChB,SAASC,gBAAgB,EAAEC,oBAAo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1C,IAAI,CAAC,EAAE;oBAC9B0C,UAAUP,YAAY,CAACO,QAAQ1C,IAAI,CAAC;gBACtC,OAAO;oBACLmC,YAAY,CAACO,QAAQ1C,IAAI,CAAC,GAAG0C;gBAC/B;YACF;YAEA,IAAIR,cAAcS,QAAQ,CAACnC,SAASR,IAAI,GAAG;gBACzC0C,UAAU,IAAIpD,YAAYoD;YAC5B,OAAO,IAAIlC,SAASR,IAAI,KAAK,UAAU;gBACrC0C,UAAUzD;YACZ;YAEA,OAAO;gBACL,GAAGwD,gBAAgB;gBACnB,CAACjC,SAASR,IAAI,CAAC,EAAE;oBACfE,MAAMwC;gBACR;YACF;QACF,GAAG,CAAC;IACN;AACF,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../src/schema/withOperators.ts"],"sourcesContent":["import type { GraphQLType } from 'graphql'\nimport type { FieldAffectingData, NumberField, RadioField, SelectField } from 'payload'\n\nimport {\n GraphQLBoolean,\n GraphQLEnumType,\n GraphQLFloat,\n GraphQLInputObjectType,\n GraphQLInt,\n GraphQLList,\n GraphQLString,\n} from 'graphql'\nimport { DateTimeResolver, EmailAddressResolver } from 'graphql-scalars'\nimport { optionIsObject } from 'payload/shared'\n\nimport { GraphQLJSON } from '../packages/graphql-type-json/index.js'\nimport { combineParentName } from '../utilities/combineParentName.js'\nimport { formatName } from '../utilities/formatName.js'\nimport { operators } from './operators.js'\n\ntype staticTypes =\n | 'checkbox'\n | 'code'\n | 'date'\n | 'email'\n | 'json'\n | 'number'\n | 'point'\n | 'relationship'\n | 'richText'\n | 'text'\n | 'textarea'\n | 'upload'\n\ntype dynamicTypes = 'radio' | 'select'\n\nconst GeoJSONObject = new GraphQLInputObjectType({\n name: 'GeoJSONObject',\n fields: {\n type: { type: GraphQLString },\n coordinates: {\n type: GraphQLJSON,\n },\n },\n})\n\ntype DefaultsType = {\n [key in dynamicTypes]: {\n operators: {\n name: string\n type: (field: FieldAffectingData, parentName: string) => GraphQLType\n }[]\n }\n} & {\n [key in staticTypes]: {\n operators: {\n name: string\n type: ((field: FieldAffectingData, parentName: string) => GraphQLType) | GraphQLType\n }[]\n }\n}\n\nconst defaults: DefaultsType = {\n checkbox: {\n operators: [\n ...operators.equality.map((operator) => ({\n name: operator,\n type: GraphQLBoolean,\n })),\n ],\n },\n code: {\n operators: [\n ...[...operators.equality, ...operators.partial].map((operator) => ({\n name: operator,\n type: GraphQLString,\n })),\n ],\n },\n date: {\n operators: [\n ...[...operators.equality, ...operators.comparison, 'like'].map((operator) => ({\n name: operator,\n type: DateTimeResolver,\n })),\n ],\n },\n email: {\n operators: [\n ...[...operators.equality, ...operators.partial, ...operators.contains].map((operator) => ({\n name: operator,\n type: EmailAddressResolver,\n })),\n ],\n },\n json: {\n operators: [\n ...[...operators.equality, ...operators.partial, ...operators.geojson].map((operator) => ({\n name: operator,\n type: GraphQLJSON,\n })),\n ],\n },\n number: {\n operators: [\n ...[...operators.equality, ...operators.comparison].map((operator) => ({\n name: operator,\n type: (field: NumberField): GraphQLType => {\n return field?.name === 'id' ? GraphQLInt : GraphQLFloat\n },\n })),\n ],\n },\n point: {\n operators: [\n ...[...operators.equality, ...operators.comparison, ...operators.geo].map((operator) => ({\n name: operator,\n type: new GraphQLList(GraphQLFloat),\n })),\n ...operators.geojson.map((operator) => ({\n name: operator,\n /**\n * @example:\n * within: {\n * type: \"Polygon\",\n * coordinates: [[\n * [0.0, 0.0],\n * [1.0, 1.0],\n * [1.0, 0.0],\n * [0.0, 0.0],\n * ]],\n * }\n * @example\n * intersects: {\n * type: \"Point\",\n * coordinates: [ 0.5, 0.5 ]\n * }\n */\n type: GeoJSONObject,\n })),\n ],\n },\n radio: {\n operators: [\n ...[...operators.equality, ...operators.partial].map((operator) => ({\n name: operator,\n type: (field: RadioField, parentName): GraphQLType =>\n new GraphQLEnumType({\n name: `${combineParentName(parentName, field.name)}_Input`,\n values: field.options.reduce((values, option) => {\n if (optionIsObject(option)) {\n return {\n ...values,\n [formatName(option.value)]: {\n value: option.value,\n },\n }\n }\n\n return {\n ...values,\n [formatName(option)]: {\n value: option,\n },\n }\n }, {}),\n }),\n })),\n ],\n },\n relationship: {\n operators: [\n ...[...operators.equality, ...operators.contains].map((operator) => ({\n name: operator,\n type: GraphQLJSON,\n })),\n ],\n },\n richText: {\n operators: [\n ...[...operators.equality, ...operators.partial].map((operator) => ({\n name: operator,\n type: GraphQLJSON,\n })),\n ],\n },\n select: {\n operators: [\n ...[...operators.equality, ...operators.contains].map((operator) => ({\n name: operator,\n type: (field: SelectField, parentName): GraphQLType =>\n new GraphQLEnumType({\n name: `${combineParentName(parentName, field.name)}_Input`,\n values: field.options.reduce((values, option) => {\n if (optionIsObject(option)) {\n return {\n ...values,\n [formatName(option.value)]: {\n value: option.value,\n },\n }\n }\n\n return {\n ...values,\n [formatName(option)]: {\n value: option,\n },\n }\n }, {}),\n }),\n })),\n ],\n },\n text: {\n operators: [\n ...[...operators.equality, ...operators.partial, ...operators.contains].map((operator) => ({\n name: operator,\n type: GraphQLString,\n })),\n ],\n },\n textarea: {\n operators: [\n ...[...operators.equality, ...operators.partial].map((operator) => ({\n name: operator,\n type: GraphQLString,\n })),\n ],\n },\n upload: {\n operators: [\n ...[...operators.equality, ...operators.contains].map((operator) => ({\n name: operator,\n type: GraphQLJSON,\n })),\n ],\n },\n // array: n/a\n // group: n/a\n // row: n/a\n // collapsible: n/a\n // tabs: n/a\n}\n\nconst listOperators = ['in', 'not_in', 'all']\n\nconst gqlTypeCache: Record<string, GraphQLType> = {}\n\n/**\n * In GraphQL, you can use \"where\" as an argument to filter a collection. Example:\n * { Posts(where: { title: { equals: \"Hello\" } }) { text } }\n * This function defines the operators for a field's condition in the \"where\" argument of the collection (it thus gets called for every field).\n * For example, in the example above, it would control that\n * - \"equals\" is a valid operator for the \"title\" field\n * - the accepted type of the \"equals\" argument has to be a string.\n *\n * @param field the field for which their valid operators inside a \"where\" argument is being defined\n * @param parentName the name of the parent field (if any)\n * @returns all the operators (including their types) which can be used as a condition for a given field inside a where\n *\n * @example\n * A has-many relationship accepts a nested query with its relationship operators:\n * ```graphql\n * Burgers(where: { ingredients: { not_equals: { isHealthy: { equals: false } } } })\n * ```\n */\nexport const withOperators = (\n field: FieldAffectingData,\n parentName: string,\n): GraphQLInputObjectType => {\n if (!defaults?.[field.type]) {\n throw new Error(`Error: ${field.type} has no defaults configured.`)\n }\n\n const name = `${combineParentName(parentName, field.name)}_operator`\n\n // Get the default operators for the field type which are hard-coded above\n const fieldOperators = [...defaults[field.type].operators]\n\n // These operators accept a complete `where` query for the one collection targeted by the\n // relationship. Polymorphic relationships are excluded because they can target multiple schemas.\n if (\n (field.type === 'relationship' || field.type === 'upload') &&\n field.hasMany &&\n typeof field.relationTo === 'string'\n ) {\n // `equals` and `not_equals` already exist for relationship fields.\n fieldOperators.push({ name: 'contains', type: GraphQLJSON })\n }\n\n if (!('required' in field) || !field.required) {\n fieldOperators.push({\n name: 'exists',\n type: fieldOperators[0].type,\n })\n }\n\n return new GraphQLInputObjectType({\n name,\n fields: fieldOperators.reduce((objectTypeFields, operator) => {\n // Get the type of the operator. It can be either static, or dynamic (=> a function)\n let gqlType: GraphQLType =\n typeof operator.type === 'function' ? operator.type(field, parentName) : operator.type\n\n // GraphQL does not allow types with duplicate names, so we use this cache to avoid that.\n // Without this, select and radio fields would have the same name, and GraphQL would throw an error\n // This usually only happens if a custom type is returned from the operator.type function\n if (typeof operator.type === 'function' && 'name' in gqlType) {\n if (gqlTypeCache[gqlType.name]) {\n gqlType = gqlTypeCache[gqlType.name]\n } else {\n gqlTypeCache[gqlType.name] = gqlType\n }\n }\n\n if (listOperators.includes(operator.name)) {\n gqlType = new GraphQLList(gqlType)\n } else if (operator.name === 'exists') {\n gqlType = GraphQLBoolean\n }\n\n return {\n ...objectTypeFields,\n [operator.name]: {\n type: gqlType,\n },\n }\n }, {}),\n })\n}\n"],"names":["GraphQLBoolean","GraphQLEnumType","GraphQLFloat","GraphQLInputObjectType","GraphQLInt","GraphQLList","GraphQLString","DateTimeResolver","EmailAddressResolver","optionIsObject","GraphQLJSON","combineParentName","formatName","operators","GeoJSONObject","name","fields","type","coordinates","defaults","checkbox","equality","map","operator","code","partial","date","comparison","email","contains","json","geojson","number","field","point","geo","radio","parentName","values","options","reduce","option","value","relationship","richText","select","text","textarea","upload","listOperators","gqlTypeCache","withOperators","Error","fieldOperators","hasMany","relationTo","push","required","objectTypeFields","gqlType","includes"],"mappings":"AAGA,SACEA,cAAc,EACdC,eAAe,EACfC,YAAY,EACZC,sBAAsB,EACtBC,UAAU,EACVC,WAAW,EACXC,aAAa,QACR,UAAS;AAChB,SAASC,gBAAgB,EAAEC,oBAAoB,QAAQ,kBAAiB;AACxE,SAASC,cAAc,QAAQ,iBAAgB;AAE/C,SAASC,WAAW,QAAQ,yCAAwC;AACpE,SAASC,iBAAiB,QAAQ,oCAAmC;AACrE,SAASC,UAAU,QAAQ,6BAA4B;AACvD,SAASC,SAAS,QAAQ,iBAAgB;AAkB1C,MAAMC,gBAAgB,IAAIX,uBAAuB;IAC/CY,MAAM;IACNC,QAAQ;QACNC,MAAM;YAAEA,MAAMX;QAAc;QAC5BY,aAAa;YACXD,MAAMP;QACR;IACF;AACF;AAkBA,MAAMS,WAAyB;IAC7BC,UAAU;QACRP,WAAW;eACNA,UAAUQ,QAAQ,CAACC,GAAG,CAAC,CAACC,WAAc,CAAA;oBACvCR,MAAMQ;oBACNN,MAAMjB;gBACR,CAAA;SACD;IACH;IACAwB,MAAM;QACJX,WAAW;eACN;mBAAIA,UAAUQ,QAAQ;mBAAKR,UAAUY,OAAO;aAAC,CAACH,GAAG,CAAC,CAACC,WAAc,CAAA;oBAClER,MAAMQ;oBACNN,MAAMX;gBACR,CAAA;SACD;IACH;IACAoB,MAAM;QACJb,WAAW;eACN;mBAAIA,UAAUQ,QAAQ;mBAAKR,UAAUc,UAAU;gBAAE;aAAO,CAACL,GAAG,CAAC,CAACC,WAAc,CAAA;oBAC7ER,MAAMQ;oBACNN,MAAMV;gBACR,CAAA;SACD;I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AK,QAAO,KACxDgB,MAAMqB,OAAO,IACb,OAAOrB,MAAMsB,UAAU,KAAK,UAC5B;QACA,mEAAmE;QACnEF,eAAeG,IAAI,CAAC;YAAEzC,MAAM;YAAYE,MAAMP;QAAY;IAC5D;IAEA,IAAI,CAAE,CAAA,cAAcuB,KAAI,KAAM,CAACA,MAAMwB,QAAQ,EAAE;QAC7CJ,eAAeG,IAAI,CAAC;YAClBzC,MAAM;YACNE,MAAMoC,cAAc,CAAC,EAAE,CAACpC,IAAI;QAC9B;IACF;IAEA,OAAO,IAAId,uBAAuB;QAChCY;QACAC,QAAQqC,eAAeb,MAAM,CAAC,CAACkB,kBAAkBnC;YAC/C,oFAAoF;YACpF,IAAIoC,UACF,OAAOpC,SAASN,IAAI,KAAK,aAAaM,SAASN,IAAI,CAACgB,OAAOI,cAAcd,SAASN,IAAI;YAExF,yFAAyF;YACzF,mGAAmG;YACnG,yFAAyF;YACzF,IAAI,OAAOM,SAASN,IAAI,KAAK,cAAc,UAAU0C,SAAS;gBAC5D,IAAIT,YAAY,CAACS,QAAQ5C,IAAI,CAAC,EAAE;oBAC9B4C,UAAUT,YAAY,CAACS,QAAQ5C,IAAI,CAAC;gBACtC,OAAO;oBACLmC,YAAY,CAACS,QAAQ5C,IAAI,CAAC,GAAG4C;gBAC/B;YACF;YAEA,IAAIV,cAAcW,QAAQ,CAACrC,SAASR,IAAI,GAAG;gBACzC4C,UAAU,IAAItD,YAAYsD;YAC5B,OAAO,IAAIpC,SAASR,IAAI,KAAK,UAAU;gBACrC4C,UAAU3D;YACZ;YAEA,OAAO;gBACL,GAAG0D,gBAAgB;gBACnB,CAACnC,SAASR,IAAI,CAAC,EAAE;oBACfE,MAAM0C;gBACR;YACF;QACF,GAAG,CAAC;IACN;AACF,EAAC"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { GraphQLResolveInfo } from 'graphql';
|
|
2
2
|
import type { TypedCollectionSelect } from 'payload';
|
|
3
|
-
|
|
4
|
-
export declare function
|
|
5
|
-
export declare function
|
|
3
|
+
import type { Context } from '../resolvers/types.js';
|
|
4
|
+
export declare function buildSelectForCollection(info: GraphQLResolveInfo, context?: Context): SelectType;
|
|
5
|
+
export declare function buildSelectForCollectionMany(info: GraphQLResolveInfo, context?: Context): SelectType;
|
|
6
|
+
export declare function resolveSelect(info: GraphQLResolveInfo, select: SelectType, context?: Context): SelectType;
|
|
6
7
|
type SelectType = TypedCollectionSelect['any'];
|
|
7
8
|
export {};
|
|
8
9
|
//# sourceMappingURL=select.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select.d.ts","sourceRoot":"","sources":["../../src/utilities/select.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAqB,kBAAkB,EAAoB,MAAM,SAAS,CAAA;AACtF,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"select.d.ts","sourceRoot":"","sources":["../../src/utilities/select.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAqB,kBAAkB,EAAoB,MAAM,SAAS,CAAA;AACtF,OAAO,KAAK,EAKV,qBAAqB,EAEtB,MAAM,SAAS,CAAA;AAIhB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAA;AASpD,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,kBAAkB,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,UAAU,CAMhG;AACD,wBAAgB,4BAA4B,CAC1C,IAAI,EAAE,kBAAkB,EACxB,OAAO,CAAC,EAAE,OAAO,GAChB,UAAU,CAMZ;AAED,wBAAgB,aAAa,CAC3B,IAAI,EAAE,kBAAkB,EACxB,MAAM,EAAE,UAAU,EAClB,OAAO,CAAC,EAAE,OAAO,GAChB,UAAU,CA0BZ;AA+JD,KAAK,UAAU,GAAG,qBAAqB,CAAC,KAAK,CAAC,CAAA"}
|
package/dist/utilities/select.js
CHANGED
|
@@ -1,52 +1,47 @@
|
|
|
1
1
|
import { getNamedType, isInterfaceType, isObjectType, isUnionType, Kind } from 'graphql';
|
|
2
|
-
|
|
2
|
+
const selectRootPathsByContext = new WeakMap();
|
|
3
|
+
export function buildSelectForCollection(info, context) {
|
|
4
|
+
if (context) {
|
|
5
|
+
registerSelectRootPath(context, info);
|
|
6
|
+
}
|
|
3
7
|
return buildSelect(info);
|
|
4
8
|
}
|
|
5
|
-
export function buildSelectForCollectionMany(info) {
|
|
6
|
-
|
|
9
|
+
export function buildSelectForCollectionMany(info, context) {
|
|
10
|
+
if (context) {
|
|
11
|
+
registerSelectRootPath(context, info);
|
|
12
|
+
}
|
|
13
|
+
return buildSelect(info)?.docs;
|
|
7
14
|
}
|
|
8
|
-
export function resolveSelect(info, select) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const pathKey = path.key;
|
|
13
|
-
const pathType = info.schema.getType(path.typename);
|
|
14
|
-
if (pathType) {
|
|
15
|
-
const field = pathType?.getFields()?.[pathKey]?.extensions?.field;
|
|
16
|
-
if (field?.type === 'join') {
|
|
17
|
-
path = path.prev;
|
|
18
|
-
traversePath.unshift('docs');
|
|
19
|
-
}
|
|
20
|
-
if (field?.type === 'relationship' && Array.isArray(field.relationTo)) {
|
|
21
|
-
path = path.prev;
|
|
22
|
-
traversePath.unshift('value');
|
|
23
|
-
}
|
|
24
|
-
if (field) {
|
|
25
|
-
traversePath.unshift(field.name);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
if (path.prev) {
|
|
29
|
-
traverseTree(path.prev);
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
traverseTree(info.path);
|
|
33
|
-
traversePath.forEach((key)=>{
|
|
34
|
-
select = select?.[key];
|
|
35
|
-
});
|
|
15
|
+
export function resolveSelect(info, select, context) {
|
|
16
|
+
const isSelectEnabled = context ? hasSelectRootPath(context, info) : typeof select !== 'undefined';
|
|
17
|
+
if (!isSelectEnabled) {
|
|
18
|
+
return undefined;
|
|
36
19
|
}
|
|
37
|
-
|
|
20
|
+
const field = info.parentType.getFields()[info.fieldName]?.extensions?.field;
|
|
21
|
+
const fieldSelect = buildSelect(info);
|
|
22
|
+
if (field?.type === 'join') {
|
|
23
|
+
return fieldSelect?.docs;
|
|
24
|
+
}
|
|
25
|
+
if ((field?.type === 'relationship' || field?.type === 'upload') && Array.isArray(field.relationTo)) {
|
|
26
|
+
return fieldSelect?.value;
|
|
27
|
+
}
|
|
28
|
+
return fieldSelect;
|
|
38
29
|
}
|
|
39
30
|
function buildSelect(info) {
|
|
40
31
|
const returnType = getNamedType(info.returnType);
|
|
41
|
-
const selectionSet = info.fieldNodes[0].selectionSet;
|
|
42
32
|
if (!returnType) {
|
|
43
33
|
return;
|
|
44
34
|
}
|
|
45
|
-
return
|
|
35
|
+
return info.fieldNodes.reduce((fieldTree, fieldNode)=>{
|
|
36
|
+
if (!fieldNode.selectionSet) {
|
|
37
|
+
return fieldTree;
|
|
38
|
+
}
|
|
39
|
+
return mergeSelectTrees(fieldTree, buildSelectTree(info, fieldNode.selectionSet, returnType));
|
|
40
|
+
}, {});
|
|
46
41
|
}
|
|
47
42
|
function buildSelectTree(info, selectionSet, type) {
|
|
48
43
|
const fieldMap = type.getFields?.();
|
|
49
|
-
|
|
44
|
+
let fieldTree = {};
|
|
50
45
|
for (const selection of selectionSet.selections){
|
|
51
46
|
switch(selection.kind){
|
|
52
47
|
case Kind.FIELD:
|
|
@@ -64,11 +59,15 @@ function buildSelectTree(info, selectionSet, type) {
|
|
|
64
59
|
if (selection.selectionSet) {
|
|
65
60
|
const type = getNamedType(fieldSchema.type);
|
|
66
61
|
if (isObjectType(type) || isInterfaceType(type) || isUnionType(type)) {
|
|
67
|
-
fieldTree
|
|
62
|
+
fieldTree = mergeSelectTrees(fieldTree, {
|
|
63
|
+
[fieldNameOriginal]: buildSelectTree(info, selection.selectionSet, type)
|
|
64
|
+
});
|
|
68
65
|
continue;
|
|
69
66
|
}
|
|
70
67
|
}
|
|
71
|
-
fieldTree
|
|
68
|
+
fieldTree = mergeSelectTrees(fieldTree, {
|
|
69
|
+
[fieldNameOriginal]: true
|
|
70
|
+
});
|
|
72
71
|
break;
|
|
73
72
|
}
|
|
74
73
|
case Kind.FRAGMENT_SPREAD:
|
|
@@ -77,7 +76,7 @@ function buildSelectTree(info, selectionSet, type) {
|
|
|
77
76
|
const fragment = info.fragments[fragmentName];
|
|
78
77
|
const fragmentType = fragment && info.schema.getType(fragment.typeCondition.name.value);
|
|
79
78
|
if (fragmentType) {
|
|
80
|
-
|
|
79
|
+
fieldTree = mergeSelectTrees(fieldTree, buildFragmentSelectTree(info, fragment.selectionSet, fragmentType, type));
|
|
81
80
|
}
|
|
82
81
|
break;
|
|
83
82
|
}
|
|
@@ -85,13 +84,7 @@ function buildSelectTree(info, selectionSet, type) {
|
|
|
85
84
|
{
|
|
86
85
|
const fragmentType = selection.typeCondition ? info.schema.getType(selection.typeCondition.name.value) : type;
|
|
87
86
|
if (fragmentType) {
|
|
88
|
-
|
|
89
|
-
const blockSlug = fragmentType.extensions?.blockSlug;
|
|
90
|
-
if (blockSlug && isUnionType(type)) {
|
|
91
|
-
fieldTree[blockSlug] = buildSelectTree(info, selection.selectionSet, fragmentType);
|
|
92
|
-
} else {
|
|
93
|
-
Object.assign(fieldTree, buildSelectTree(info, selection.selectionSet, fragmentType));
|
|
94
|
-
}
|
|
87
|
+
fieldTree = mergeSelectTrees(fieldTree, buildFragmentSelectTree(info, selection.selectionSet, fragmentType, type));
|
|
95
88
|
}
|
|
96
89
|
break;
|
|
97
90
|
}
|
|
@@ -99,5 +92,50 @@ function buildSelectTree(info, selectionSet, type) {
|
|
|
99
92
|
}
|
|
100
93
|
return fieldTree;
|
|
101
94
|
}
|
|
95
|
+
function buildFragmentSelectTree(info, selectionSet, fragmentType, parentType) {
|
|
96
|
+
const fragmentSelectTree = buildSelectTree(info, selectionSet, fragmentType);
|
|
97
|
+
const blockSlug = fragmentType.extensions?.blockSlug;
|
|
98
|
+
if (blockSlug && isUnionType(parentType)) {
|
|
99
|
+
return {
|
|
100
|
+
[blockSlug]: fragmentSelectTree
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
return fragmentSelectTree;
|
|
104
|
+
}
|
|
105
|
+
function getRootPathKey(path) {
|
|
106
|
+
while(path.prev){
|
|
107
|
+
path = path.prev;
|
|
108
|
+
}
|
|
109
|
+
return path.key;
|
|
110
|
+
}
|
|
111
|
+
function hasSelectRootPath(context, info) {
|
|
112
|
+
return Boolean(selectRootPathsByContext.get(context)?.get(info.operation)?.has(getRootPathKey(info.path)));
|
|
113
|
+
}
|
|
114
|
+
function isSelectTree(value) {
|
|
115
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
116
|
+
}
|
|
117
|
+
function mergeSelectTrees(firstTree, secondTree) {
|
|
118
|
+
const mergedTree = {
|
|
119
|
+
...firstTree
|
|
120
|
+
};
|
|
121
|
+
for (const [fieldName, fieldSelect] of Object.entries(secondTree)){
|
|
122
|
+
const existingFieldSelect = mergedTree[fieldName];
|
|
123
|
+
mergedTree[fieldName] = isSelectTree(existingFieldSelect) && isSelectTree(fieldSelect) ? mergeSelectTrees(existingFieldSelect, fieldSelect) : fieldSelect;
|
|
124
|
+
}
|
|
125
|
+
return mergedTree;
|
|
126
|
+
}
|
|
127
|
+
function registerSelectRootPath(context, info) {
|
|
128
|
+
let selectRootPathsByOperation = selectRootPathsByContext.get(context);
|
|
129
|
+
if (!selectRootPathsByOperation) {
|
|
130
|
+
selectRootPathsByOperation = new WeakMap();
|
|
131
|
+
selectRootPathsByContext.set(context, selectRootPathsByOperation);
|
|
132
|
+
}
|
|
133
|
+
let selectRootPaths = selectRootPathsByOperation.get(info.operation);
|
|
134
|
+
if (!selectRootPaths) {
|
|
135
|
+
selectRootPaths = new Set();
|
|
136
|
+
selectRootPathsByOperation.set(info.operation, selectRootPaths);
|
|
137
|
+
}
|
|
138
|
+
selectRootPaths.add(getRootPathKey(info.path));
|
|
139
|
+
}
|
|
102
140
|
|
|
103
141
|
//# sourceMappingURL=select.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/select.ts"],"sourcesContent":["import type { GraphQLObjectType, GraphQLResolveInfo, SelectionSetNode } from 'graphql'\nimport type { FieldBase, JoinField, RelationshipField, TypedCollectionSelect } from 'payload'\n\nimport { getNamedType, isInterfaceType, isObjectType, isUnionType, Kind } from 'graphql'\n\nexport function buildSelectForCollection(info: GraphQLResolveInfo): SelectType {\n return buildSelect(info)\n}\nexport function buildSelectForCollectionMany(info: GraphQLResolveInfo): SelectType {\n return buildSelect(info).docs as SelectType\n}\n\nexport function resolveSelect(info: GraphQLResolveInfo, select: SelectType): SelectType {\n if (select) {\n const traversePath: string[] = []\n const traverseTree = (path: GraphQLResolveInfo['path']) => {\n const pathKey = path.key\n const pathType = info.schema.getType(path.typename) as GraphQLObjectType\n\n if (pathType) {\n const field = pathType?.getFields()?.[pathKey]?.extensions?.field as\n | JoinField\n | RelationshipField\n\n if (field?.type === 'join') {\n path = path.prev\n traversePath.unshift('docs')\n }\n if (field?.type === 'relationship' && Array.isArray(field.relationTo)) {\n path = path.prev\n traversePath.unshift('value')\n }\n if (field) {\n traversePath.unshift(field.name)\n }\n }\n\n if (path.prev) {\n traverseTree(path.prev)\n }\n }\n\n traverseTree(info.path)\n traversePath.forEach((key) => {\n select = select?.[key] as SelectType\n })\n }\n\n return select\n}\n\nfunction buildSelect(info: GraphQLResolveInfo) {\n const returnType = getNamedType(info.returnType) as GraphQLObjectType\n const selectionSet = info.fieldNodes[0].selectionSet\n\n if (!returnType) {\n return\n }\n\n return buildSelectTree(info, selectionSet, returnType)\n}\nfunction buildSelectTree(\n info: GraphQLResolveInfo,\n selectionSet: SelectionSetNode,\n type: GraphQLObjectType,\n): SelectType {\n const fieldMap = type.getFields?.()\n const fieldTree: SelectType = {}\n\n for (const selection of selectionSet.selections) {\n switch (selection.kind) {\n case Kind.FIELD: {\n const fieldName = selection.name.value\n const fieldSchema = fieldMap?.[fieldName]\n\n const field = fieldSchema?.extensions?.field as FieldBase\n const fieldNameOriginal = field?.name || fieldName\n\n if (fieldName === '__typename') {\n continue\n }\n if (fieldSchema == undefined) {\n continue\n }\n\n if (selection.selectionSet) {\n const type = getNamedType(fieldSchema.type) as GraphQLObjectType\n\n if (isObjectType(type) || isInterfaceType(type) || isUnionType(type)) {\n fieldTree[fieldNameOriginal] = buildSelectTree(info, selection.selectionSet, type)\n continue\n }\n }\n\n fieldTree[fieldNameOriginal] = true\n break\n }\n\n case Kind.FRAGMENT_SPREAD: {\n const fragmentName = selection.name.value\n const fragment = info.fragments[fragmentName]\n const fragmentType =\n fragment && (info.schema.getType(fragment.typeCondition.name.value) as GraphQLObjectType)\n\n if (fragmentType) {\n Object.assign(fieldTree, buildSelectTree(info, fragment.selectionSet, fragmentType))\n }\n break\n }\n\n case Kind.INLINE_FRAGMENT: {\n const fragmentType = selection.typeCondition\n ? (info.schema.getType(selection.typeCondition.name.value) as GraphQLObjectType)\n : type\n\n if (fragmentType) {\n // Block types in unions need selections nested under their slug\n const blockSlug = fragmentType.extensions?.blockSlug as string | undefined\n\n if (blockSlug && isUnionType(type)) {\n fieldTree[blockSlug] = buildSelectTree(info, selection.selectionSet, fragmentType)\n } else {\n Object.assign(fieldTree, buildSelectTree(info, selection.selectionSet, fragmentType))\n }\n }\n break\n }\n }\n }\n\n return fieldTree\n}\n\ntype SelectType = TypedCollectionSelect['any']\n"],"names":["getNamedType","isInterfaceType","isObjectType","isUnionType","Kind","buildSelectForCollection","info","buildSelect","buildSelectForCollectionMany","docs","resolveSelect","select","traversePath","traverseTree","path","pathKey","key","pathType","schema","getType","typename","field","getFields","extensions","type","prev","unshift","Array","isArray","relationTo","name","forEach","returnType","selectionSet","fieldNodes","buildSelectTree","fieldMap","fieldTree","selection","selections","kind","FIELD","fieldName","value","fieldSchema","fieldNameOriginal","undefined","FRAGMENT_SPREAD","fragmentName","fragment","fragments","fragmentType","typeCondition","Object","assign","INLINE_FRAGMENT","blockSlug"],"mappings":"AAGA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,OAAO,CAACmB,UAAUc,aAAa,CAACtB,IAAI,CAACa,KAAK,IACvDnB;oBAEJ,IAAI2B,cAAc;wBAChB,gEAAgE;wBAChE,MAAMK,YAAYL,aAAa5B,UAAU,EAAEiC;wBAE3C,IAAIA,aAAarD,YAAYqB,OAAO;4BAClCa,SAAS,CAACmB,UAAU,GAAGrB,gBAAgB7B,MAAMgC,UAAUL,YAAY,EAAEkB;wBACvE,OAAO;4BACLE,OAAOC,MAAM,CAACjB,WAAWF,gBAAgB7B,MAAMgC,UAAUL,YAAY,EAAEkB;wBACzE;oBACF;oBACA;gBACF;QACF;IACF;IAEA,OAAOd;AACT"}
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/select.ts"],"sourcesContent":["import type { GraphQLObjectType, GraphQLResolveInfo, SelectionSetNode } from 'graphql'\nimport type {\n FieldBase,\n JoinField,\n RelationshipField,\n SelectIncludeType,\n TypedCollectionSelect,\n UploadField,\n} from 'payload'\n\nimport { getNamedType, isInterfaceType, isObjectType, isUnionType, Kind } from 'graphql'\n\nimport type { Context } from '../resolvers/types.js'\n\ntype SelectRootPathsByOperation = WeakMap<\n GraphQLResolveInfo['operation'],\n Set<GraphQLResolveInfo['path']['key']>\n>\n\nconst selectRootPathsByContext = new WeakMap<Context, SelectRootPathsByOperation>()\n\nexport function buildSelectForCollection(info: GraphQLResolveInfo, context?: Context): SelectType {\n if (context) {\n registerSelectRootPath(context, info)\n }\n\n return buildSelect(info)\n}\nexport function buildSelectForCollectionMany(\n info: GraphQLResolveInfo,\n context?: Context,\n): SelectType {\n if (context) {\n registerSelectRootPath(context, info)\n }\n\n return buildSelect(info)?.docs as SelectType\n}\n\nexport function resolveSelect(\n info: GraphQLResolveInfo,\n select: SelectType,\n context?: Context,\n): SelectType {\n const isSelectEnabled = context ? hasSelectRootPath(context, info) : typeof select !== 'undefined'\n\n if (!isSelectEnabled) {\n return undefined\n }\n\n const field = info.parentType.getFields()[info.fieldName]?.extensions?.field as\n | JoinField\n | RelationshipField\n | undefined\n | UploadField\n const fieldSelect = buildSelect(info)\n\n if (field?.type === 'join') {\n return fieldSelect?.docs as SelectType\n }\n\n if (\n (field?.type === 'relationship' || field?.type === 'upload') &&\n Array.isArray(field.relationTo)\n ) {\n return fieldSelect?.value as SelectType\n }\n\n return fieldSelect\n}\n\nfunction buildSelect(info: GraphQLResolveInfo) {\n const returnType = getNamedType(info.returnType) as GraphQLObjectType\n\n if (!returnType) {\n return\n }\n\n return info.fieldNodes.reduce<SelectTree>((fieldTree, fieldNode) => {\n if (!fieldNode.selectionSet) {\n return fieldTree\n }\n\n return mergeSelectTrees(fieldTree, buildSelectTree(info, fieldNode.selectionSet, returnType))\n }, {})\n}\n\nfunction buildSelectTree(\n info: GraphQLResolveInfo,\n selectionSet: SelectionSetNode,\n type: GraphQLObjectType,\n): SelectTree {\n const fieldMap = type.getFields?.()\n let fieldTree: SelectTree = {}\n\n for (const selection of selectionSet.selections) {\n switch (selection.kind) {\n case Kind.FIELD: {\n const fieldName = selection.name.value\n const fieldSchema = fieldMap?.[fieldName]\n\n const field = fieldSchema?.extensions?.field as FieldBase\n const fieldNameOriginal = field?.name || fieldName\n\n if (fieldName === '__typename') {\n continue\n }\n if (fieldSchema == undefined) {\n continue\n }\n\n if (selection.selectionSet) {\n const type = getNamedType(fieldSchema.type) as GraphQLObjectType\n\n if (isObjectType(type) || isInterfaceType(type) || isUnionType(type)) {\n fieldTree = mergeSelectTrees(fieldTree, {\n [fieldNameOriginal]: buildSelectTree(info, selection.selectionSet, type),\n })\n continue\n }\n }\n\n fieldTree = mergeSelectTrees(fieldTree, { [fieldNameOriginal]: true })\n break\n }\n\n case Kind.FRAGMENT_SPREAD: {\n const fragmentName = selection.name.value\n const fragment = info.fragments[fragmentName]\n const fragmentType =\n fragment && (info.schema.getType(fragment.typeCondition.name.value) as GraphQLObjectType)\n\n if (fragmentType) {\n fieldTree = mergeSelectTrees(\n fieldTree,\n buildFragmentSelectTree(info, fragment.selectionSet, fragmentType, type),\n )\n }\n break\n }\n\n case Kind.INLINE_FRAGMENT: {\n const fragmentType = selection.typeCondition\n ? (info.schema.getType(selection.typeCondition.name.value) as GraphQLObjectType)\n : type\n\n if (fragmentType) {\n fieldTree = mergeSelectTrees(\n fieldTree,\n buildFragmentSelectTree(info, selection.selectionSet, fragmentType, type),\n )\n }\n break\n }\n }\n }\n\n return fieldTree\n}\n\nfunction buildFragmentSelectTree(\n info: GraphQLResolveInfo,\n selectionSet: SelectionSetNode,\n fragmentType: GraphQLObjectType,\n parentType: GraphQLObjectType,\n): SelectTree {\n const fragmentSelectTree = buildSelectTree(info, selectionSet, fragmentType)\n const blockSlug = fragmentType.extensions?.blockSlug as string | undefined\n\n if (blockSlug && isUnionType(parentType)) {\n return { [blockSlug]: fragmentSelectTree }\n }\n\n return fragmentSelectTree\n}\n\nfunction getRootPathKey(path: GraphQLResolveInfo['path']): GraphQLResolveInfo['path']['key'] {\n while (path.prev) {\n path = path.prev\n }\n\n return path.key\n}\n\nfunction hasSelectRootPath(context: Context, info: GraphQLResolveInfo): boolean {\n return Boolean(\n selectRootPathsByContext.get(context)?.get(info.operation)?.has(getRootPathKey(info.path)),\n )\n}\n\nfunction isSelectTree(value: unknown): value is SelectTree {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n\nfunction mergeSelectTrees(firstTree: SelectTree, secondTree: SelectTree): SelectTree {\n const mergedTree = { ...firstTree }\n\n for (const [fieldName, fieldSelect] of Object.entries(secondTree)) {\n const existingFieldSelect = mergedTree[fieldName]\n\n mergedTree[fieldName] =\n isSelectTree(existingFieldSelect) && isSelectTree(fieldSelect)\n ? mergeSelectTrees(existingFieldSelect, fieldSelect)\n : fieldSelect\n }\n\n return mergedTree\n}\n\nfunction registerSelectRootPath(context: Context, info: GraphQLResolveInfo): void {\n let selectRootPathsByOperation = selectRootPathsByContext.get(context)\n\n if (!selectRootPathsByOperation) {\n selectRootPathsByOperation = new WeakMap()\n selectRootPathsByContext.set(context, selectRootPathsByOperation)\n }\n\n let selectRootPaths = selectRootPathsByOperation.get(info.operation)\n\n if (!selectRootPaths) {\n selectRootPaths = new Set()\n selectRootPathsByOperation.set(info.operation, selectRootPaths)\n }\n\n selectRootPaths.add(getRootPathKey(info.path))\n}\n\ntype SelectTree = SelectIncludeType\ntype SelectType = TypedCollectionSelect['any']\n"],"names":["getNamedType","isInterfaceType","isObjectType","isUnionType","Kind","selectRootPathsByContext","WeakMap","buildSelectForCollection","info","context","registerSelectRootPath","buildSelect","buildSelectForCollectionMany","docs","resolveSelect","select","isSelectEnabled","hasSelectRootPath","undefined","field","parentType","getFields","fieldName","extensions","fieldSelect","type","Array","isArray","relationTo","value","returnType","fieldNodes","reduce","fieldTree","fieldNode","selectionSet","mergeSelectTrees","buildSelectTree","fieldMap","selection","selections","kind","FIELD","name","fieldSchema","fieldNameOriginal","FRAGMENT_SPREAD","fragmentName","fragment","fragments","fragmentType","schema","getType","typeCondition","buildFragmentSelectTree","INLINE_FRAGMENT","fragmentSelectTree","blockSlug","getRootPathKey","path","prev","key","Boolean","get","operation","has","isSelectTree","firstTree","secondTree","mergedTree","Object","entries","existingFieldSelect","selectRootPathsByOperation","set","selectRootPaths","Set","add"],"mappings":"AAUA,SAASA,YAAY,EAAEC,eAAe,EAAEC,YAAY,EAAEC,WAAW,EAAEC,IAAI,QAAQ,UAAS;AASxF,MAAMC,2BAA2B,IAAIC;AAErC,OAAO,SAASC,yBAAyBC,IAAwB,EAAEC,OAAiB;IAClF,IAAIA,SAAS;QACXC,uBAAuBD,SAASD;IAClC;IAEA,OAAOG,YAAYH;AACrB;AACA,OAAO,SAASI,6BACdJ,IAAwB,EACxBC,OAAiB;IAEjB,IAAIA,SAAS;QACXC,uBAAuBD,SAASD;IAClC;IAEA,OAAOG,YAAYH,OAAOK;AAC5B;AAEA,OAAO,SAASC,cACdN,IAAwB,EACxBO,MAAkB,EAClBN,OAAiB;IAEjB,MAAMO,kBAAkBP,UAAUQ,kBAAkBR,SAASD,QAAQ,OAAOO,WAA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|
2
2
|
"name": "@payloadcms/graphql",
|
|
3
|
-
"version": "4.0.0-internal.
|
|
3
|
+
"version": "4.0.0-internal.cd47d20",
|
|
4
4
|
"homepage": "https://payloadcms.com",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -53,11 +53,11 @@
|
|
|
53
53
|
"@types/pluralize": "^0.0.33",
|
|
54
54
|
"graphql-http": "1.22.4",
|
|
55
55
|
"@payloadcms/eslint-config": "3.28.0",
|
|
56
|
-
"payload": "4.0.0-internal.
|
|
56
|
+
"payload": "4.0.0-internal.cd47d20"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
59
|
"graphql": "^16.8.1",
|
|
60
|
-
"payload": "4.0.0-internal.
|
|
60
|
+
"payload": "4.0.0-internal.cd47d20"
|
|
61
61
|
},
|
|
62
62
|
"scripts": {
|
|
63
63
|
"build": "pnpm build:types && pnpm build:swc",
|