Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
1 line
12 KiB
Plaintext
1 line
12 KiB
Plaintext
{"version":3,"sources":["../../src/schema/initGlobals.ts"],"sourcesContent":["import { GraphQLBoolean, GraphQLInt, GraphQLNonNull, GraphQLString } from 'graphql'\nimport pluralize from 'pluralize'\nconst { singular } = pluralize\n\nimport type { Field, GraphQLInfo, SanitizedConfig, SanitizedGlobalConfig } from 'payload'\n\nimport { buildVersionGlobalFields, toWords } from 'payload'\nimport { hasDraftsEnabled } from 'payload/shared'\n\nimport { docAccessResolver } from '../resolvers/globals/docAccess.js'\nimport { findOne } from '../resolvers/globals/findOne.js'\nimport { findVersionByID } from '../resolvers/globals/findVersionByID.js'\nimport { findVersions } from '../resolvers/globals/findVersions.js'\nimport { restoreVersion } from '../resolvers/globals/restoreVersion.js'\nimport { update } from '../resolvers/globals/update.js'\nimport { formatName } from '../utilities/formatName.js'\nimport { buildMutationInputType } 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 InitGlobalsGraphQLArgs = {\n config: SanitizedConfig\n graphqlResult: GraphQLInfo\n}\nexport function initGlobals({ config, graphqlResult }: InitGlobalsGraphQLArgs): void {\n Object.keys(graphqlResult.globals.config).forEach((slug) => {\n const global: SanitizedGlobalConfig = graphqlResult.globals.config[slug]\n const { fields, graphQL } = global\n\n if (graphQL === false) {\n return\n }\n\n const formattedName = graphQL?.name ? graphQL.name : singular(toWords(global.slug, true))\n\n const forceNullableObjectType = hasDraftsEnabled(global)\n\n if (!graphqlResult.globals.graphQL) {\n graphqlResult.globals.graphQL = {}\n }\n\n const updateMutationInputType = buildMutationInputType({\n name: formattedName,\n config,\n fields,\n graphqlResult,\n parentIsLocalized: false,\n parentName: formattedName,\n })\n graphqlResult.globals.graphQL[slug] = {\n type: buildObjectType({\n name: formattedName,\n config,\n fields,\n forceNullable: forceNullableObjectType,\n graphqlResult,\n parentName: formattedName,\n }),\n mutationInputType: updateMutationInputType\n ? new GraphQLNonNull(updateMutationInputType)\n : null,\n }\n\n const queriesEnabled = typeof global.graphQL !== 'object' || !global.graphQL.disableQueries\n const mutationsEnabled = typeof global.graphQL !== 'object' || !global.graphQL.disableMutations\n\n if (queriesEnabled) {\n graphqlResult.Query.fields[formattedName] = {\n type: graphqlResult.globals.graphQL[slug].type,\n args: {\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 },\n resolve: findOne(global),\n }\n\n graphqlResult.Query.fields[`docAccess${formattedName}`] = {\n type: buildPolicyType({\n type: 'global',\n entity: global,\n scope: 'docAccess',\n typeSuffix: 'DocAccess',\n }),\n resolve: docAccessResolver(global),\n }\n }\n\n if (mutationsEnabled) {\n graphqlResult.Mutation.fields[`update${formattedName}`] = {\n type: graphqlResult.globals.graphQL[slug].type,\n args: {\n ...(updateMutationInputType\n ? { data: { type: graphqlResult.globals.graphQL[slug].mutationInputType } }\n : {}),\n draft: { type: GraphQLBoolean },\n ...(config.localization\n ? {\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n },\n resolve: update(global),\n }\n }\n\n if (global.versions) {\n const idType = config.db.defaultIDType === 'number' ? GraphQLInt : GraphQLString\n\n const versionGlobalFields: Field[] = [\n ...buildVersionGlobalFields(config, global),\n {\n name: 'id',\n type: config.db.defaultIDType as 'text',\n },\n {\n name: 'createdAt',\n type: 'date',\n label: 'Created At',\n },\n {\n name: 'updatedAt',\n type: 'date',\n label: 'Updated At',\n },\n ]\n\n graphqlResult.globals.graphQL[slug].versionType = buildObjectType({\n name: `${formattedName}Version`,\n config,\n fields: versionGlobalFields,\n forceNullable: forceNullableObjectType,\n graphqlResult,\n parentName: `${formattedName}Version`,\n })\n\n if (queriesEnabled) {\n graphqlResult.Query.fields[`version${formatName(formattedName)}`] = {\n type: graphqlResult.globals.graphQL[slug].versionType,\n args: {\n id: { type: 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 },\n resolve: findVersionByID(global),\n }\n graphqlResult.Query.fields[`versions${formattedName}`] = {\n type: buildPaginatedListType(\n `versions${formatName(formattedName)}`,\n graphqlResult.globals.graphQL[slug].versionType,\n ),\n args: {\n where: {\n type: buildWhereInputType({\n name: `versions${formattedName}`,\n fields: versionGlobalFields,\n parentName: `versions${formattedName}`,\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 },\n resolve: findVersions(global),\n }\n }\n\n if (mutationsEnabled) {\n graphqlResult.Mutation.fields[`restoreVersion${formatName(formattedName)}`] = {\n type: graphqlResult.globals.graphQL[slug].type,\n args: {\n id: { type: idType },\n draft: { type: GraphQLBoolean },\n },\n resolve: restoreVersion(global),\n }\n }\n }\n })\n}\n"],"names":["GraphQLBoolean","GraphQLInt","GraphQLNonNull","GraphQLString","pluralize","singular","buildVersionGlobalFields","toWords","hasDraftsEnabled","docAccessResolver","findOne","findVersionByID","findVersions","restoreVersion","update","formatName","buildMutationInputType","buildObjectType","buildPaginatedListType","buildPolicyType","buildWhereInputType","initGlobals","config","graphqlResult","Object","keys","globals","forEach","slug","global","fields","graphQL","formattedName","name","forceNullableObjectType","updateMutationInputType","parentIsLocalized","parentName","type","forceNullable","mutationInputType","queriesEnabled","disableQueries","mutationsEnabled","disableMutations","Query","args","draft","localization","fallbackLocale","types","fallbackLocaleInputType","locale","localeInputType","select","resolve","entity","scope","typeSuffix","Mutation","data","versions","idType","db","defaultIDType","versionGlobalFields","label","versionType","id","where","limit","page","pagination","sort"],"mappings":"AAAA,SAASA,cAAc,EAAEC,UAAU,EAAEC,cAAc,EAAEC,aAAa,QAAQ,UAAS;AACnF,OAAOC,eAAe,YAAW;AACjC,MAAM,EAAEC,QAAQ,EAAE,GAAGD;AAIrB,SAASE,wBAAwB,EAAEC,OAAO,QAAQ,UAAS;AAC3D,SAASC,gBAAgB,QAAQ,iBAAgB;AAEjD,SAASC,iBAAiB,QAAQ,oCAAmC;AACrE,SAASC,OAAO,QAAQ,kCAAiC;AACzD,SAASC,eAAe,QAAQ,0CAAyC;AACzE,SAASC,YAAY,QAAQ,uCAAsC;AACnE,SAASC,cAAc,QAAQ,yCAAwC;AACvE,SAASC,MAAM,QAAQ,iCAAgC;AACvD,SAASC,UAAU,QAAQ,6BAA4B;AACvD,SAASC,sBAAsB,QAAQ,8BAA6B;AACpE,SAASC,eAAe,QAAQ,uBAAsB;AACtD,SAASC,sBAAsB,QAAQ,8BAA6B;AACpE,SAASC,eAAe,QAAQ,yBAAwB;AACxD,SAASC,mBAAmB,QAAQ,2BAA0B;AAM9D,OAAO,SAASC,YAAY,EAAEC,MAAM,EAAEC,aAAa,EAA0B;IAC3EC,OAAOC,IAAI,CAACF,cAAcG,OAAO,CAACJ,MAAM,EAAEK,OAAO,CAAC,CAACC;QACjD,MAAMC,SAAgCN,cAAcG,OAAO,CAACJ,MAAM,CAACM,KAAK;QACxE,MAAM,EAAEE,MAAM,EAAEC,OAAO,EAAE,GAAGF;QAE5B,IAAIE,YAAY,OAAO;YACrB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