@payloadcms/graphql 4.0.0-internal.543da65 → 4.0.0-internal.567a487
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/packages/graphql-query-complexity/QueryComplexity.d.ts.map +1 -1
- package/dist/packages/graphql-query-complexity/estimators/simple/index.d.ts.map +1 -1
- package/dist/resolvers/collections/count.d.ts +1 -0
- package/dist/resolvers/collections/count.d.ts.map +1 -1
- package/dist/resolvers/collections/count.js.map +1 -1
- package/dist/resolvers/collections/create.d.ts +1 -0
- package/dist/resolvers/collections/create.d.ts.map +1 -1
- package/dist/resolvers/collections/create.js.map +1 -1
- package/dist/resolvers/collections/delete.d.ts +1 -0
- package/dist/resolvers/collections/delete.d.ts.map +1 -1
- package/dist/resolvers/collections/delete.js +11 -1
- package/dist/resolvers/collections/delete.js.map +1 -1
- package/dist/resolvers/collections/duplicate.d.ts +1 -0
- package/dist/resolvers/collections/duplicate.d.ts.map +1 -1
- package/dist/resolvers/collections/duplicate.js +11 -1
- package/dist/resolvers/collections/duplicate.js.map +1 -1
- package/dist/resolvers/collections/find.d.ts +1 -0
- package/dist/resolvers/collections/find.d.ts.map +1 -1
- package/dist/resolvers/collections/find.js +13 -1
- package/dist/resolvers/collections/find.js.map +1 -1
- package/dist/resolvers/collections/findByID.d.ts +1 -0
- package/dist/resolvers/collections/findByID.d.ts.map +1 -1
- package/dist/resolvers/collections/findByID.js +13 -1
- package/dist/resolvers/collections/findByID.js.map +1 -1
- package/dist/resolvers/collections/findVersionByID.d.ts +1 -0
- package/dist/resolvers/collections/findVersionByID.d.ts.map +1 -1
- package/dist/resolvers/collections/findVersionByID.js +13 -1
- package/dist/resolvers/collections/findVersionByID.js.map +1 -1
- package/dist/resolvers/collections/findVersions.d.ts +1 -0
- package/dist/resolvers/collections/findVersions.d.ts.map +1 -1
- package/dist/resolvers/collections/findVersions.js +13 -1
- package/dist/resolvers/collections/findVersions.js.map +1 -1
- package/dist/resolvers/collections/restoreVersion.d.ts +1 -0
- package/dist/resolvers/collections/restoreVersion.d.ts.map +1 -1
- package/dist/resolvers/collections/restoreVersion.js.map +1 -1
- package/dist/resolvers/collections/update.d.ts +1 -0
- package/dist/resolvers/collections/update.d.ts.map +1 -1
- package/dist/resolvers/collections/update.js +11 -1
- package/dist/resolvers/collections/update.js.map +1 -1
- package/dist/resolvers/globals/findOne.d.ts +1 -0
- package/dist/resolvers/globals/findOne.d.ts.map +1 -1
- package/dist/resolvers/globals/findOne.js +13 -1
- package/dist/resolvers/globals/findOne.js.map +1 -1
- package/dist/resolvers/globals/findVersionByID.d.ts +1 -0
- package/dist/resolvers/globals/findVersionByID.d.ts.map +1 -1
- package/dist/resolvers/globals/findVersionByID.js +13 -1
- package/dist/resolvers/globals/findVersionByID.js.map +1 -1
- package/dist/resolvers/globals/findVersions.d.ts +1 -0
- package/dist/resolvers/globals/findVersions.d.ts.map +1 -1
- package/dist/resolvers/globals/findVersions.js +13 -1
- package/dist/resolvers/globals/findVersions.js.map +1 -1
- package/dist/resolvers/globals/restoreVersion.d.ts +1 -0
- package/dist/resolvers/globals/restoreVersion.d.ts.map +1 -1
- package/dist/resolvers/globals/restoreVersion.js.map +1 -1
- package/dist/resolvers/globals/update.d.ts +1 -0
- package/dist/resolvers/globals/update.d.ts.map +1 -1
- package/dist/resolvers/globals/update.js.map +1 -1
- package/dist/schema/buildFallbackLocaleInputType.d.ts.map +1 -1
- package/dist/schema/buildLocaleInputType.d.ts.map +1 -1
- package/dist/schema/buildMutationInputType.d.ts.map +1 -1
- package/dist/schema/buildPaginatedListType.d.ts.map +1 -1
- package/dist/schema/buildPoliciesType.d.ts.map +1 -1
- package/dist/schema/buildWhereInputType.d.ts.map +1 -1
- package/dist/schema/fieldToWhereInputSchemaMap.d.ts.map +1 -1
- package/dist/schema/initCollections.d.ts.map +1 -1
- package/dist/schema/initCollections.js +30 -6
- package/dist/schema/initCollections.js.map +1 -1
- package/dist/schema/initGlobals.d.ts.map +1 -1
- package/dist/schema/initGlobals.js +12 -0
- package/dist/schema/initGlobals.js.map +1 -1
- package/dist/schema/isFieldNullable.d.ts.map +1 -1
- package/dist/schema/operators.d.ts.map +1 -1
- package/dist/schema/recursivelyBuildNestedPaths.d.ts.map +1 -1
- package/dist/schema/withNullableType.d.ts.map +1 -1
- package/dist/schema/withNullableType.js +5 -1
- package/dist/schema/withNullableType.js.map +1 -1
- package/dist/schema/withOperators.d.ts.map +1 -1
- package/dist/utilities/combineParentName.d.ts.map +1 -1
- package/dist/utilities/formatName.d.ts.map +1 -1
- package/dist/utilities/formatOptions.d.ts.map +1 -1
- package/dist/utilities/formatUtcOffset.d.ts.map +1 -1
- package/dist/utilities/groupOrTabHasRequiredSubfield.d.ts.map +1 -1
- package/package.json +3 -3
|
@@ -52,6 +52,9 @@ export function initGlobals({ config, graphqlResult }) {
|
|
|
52
52
|
graphqlResult.Query.fields[formattedName] = {
|
|
53
53
|
type: graphqlResult.globals.graphQL[slug].type,
|
|
54
54
|
args: {
|
|
55
|
+
branch: {
|
|
56
|
+
type: GraphQLString
|
|
57
|
+
},
|
|
55
58
|
draft: {
|
|
56
59
|
type: GraphQLBoolean
|
|
57
60
|
},
|
|
@@ -88,6 +91,9 @@ export function initGlobals({ config, graphqlResult }) {
|
|
|
88
91
|
type: graphqlResult.globals.graphQL[slug].mutationInputType
|
|
89
92
|
}
|
|
90
93
|
} : {},
|
|
94
|
+
branch: {
|
|
95
|
+
type: GraphQLString
|
|
96
|
+
},
|
|
91
97
|
draft: {
|
|
92
98
|
type: GraphQLBoolean
|
|
93
99
|
},
|
|
@@ -134,6 +140,9 @@ export function initGlobals({ config, graphqlResult }) {
|
|
|
134
140
|
id: {
|
|
135
141
|
type: idType
|
|
136
142
|
},
|
|
143
|
+
branch: {
|
|
144
|
+
type: GraphQLString
|
|
145
|
+
},
|
|
137
146
|
draft: {
|
|
138
147
|
type: GraphQLBoolean
|
|
139
148
|
},
|
|
@@ -195,6 +204,9 @@ export function initGlobals({ config, graphqlResult }) {
|
|
|
195
204
|
id: {
|
|
196
205
|
type: idType
|
|
197
206
|
},
|
|
207
|
+
branch: {
|
|
208
|
+
type: GraphQLString
|
|
209
|
+
},
|
|
198
210
|
draft: {
|
|
199
211
|
type: GraphQLBoolean
|
|
200
212
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"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;QACF;QAEA,MAAMC,gBAAgBD,SAASE,OAAOF,QAAQE,IAAI,GAAG5B,SA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;oBAC9B;oBACAoD,SAAS3C,aAAaiB;gBACxB;YACF;YAEA,IAAIc,kBAAkB;gBACpBpB,cAAcoC,QAAQ,CAAC7B,MAAM,CAAC,CAAC,cAAc,EAAEf,WAAWiB,gBAAgB,CAAC,GAAG;oBAC5EM,MAAMf,cAAcG,OAAO,CAACK,OAAO,CAACH,KAAK,CAACU,IAAI;oBAC9CQ,MAAM;wBACJsB,IAAI;4BAAE9B,MAAMwB;wBAAO;wBACnBf,OAAO;4BAAET,MAAMtC;wBAAe;oBAChC;oBACAuD,SAAS1C,eAAegB;gBAC1B;YACF;QACF;IACF;AACF"}
|
|
1
|
+
{"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 branch: { type: GraphQLString },\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 branch: { type: GraphQLString },\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 branch: { type: GraphQLString },\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 branch: { type: GraphQLString },\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","branch","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,cA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GAAIV,OAAO2B,YAAY,GACnB;4BACEC,gBAAgB;gCAAEZ,MAAMf,cAAc4B,KAAK,CAACC,uBAAuB;4BAAC;4BACpEC,QAAQ;gCAAEf,MAAMf,cAAc4B,KAAK,CAACG,eAAe;4BAAC;wBACtD,IACA,CAAC,CAAC;wBACNiB,OAAO;4BAAEjC,MAAMrC;wBAAW;wBAC1BuE,MAAM;4BAAElC,MAAMrC;wBAAW;wBACzBwE,YAAY;4BAAEnC,MAAMtC;wBAAe;wBACnCuD,QAAQ;4BAAEjB,MAAMtC;wBAAe;wBAC/B0E,MAAM;4BAAEpC,MAAMnC;wBAAc;oBAC9B;oBACAqD,SAAS5C,aAAaiB;gBACxB;YACF;YAEA,IAAIc,kBAAkB;gBACpBpB,cAAcqC,QAAQ,CAAC9B,MAAM,CAAC,CAAC,cAAc,EAAEf,WAAWiB,gBAAgB,CAAC,GAAG;oBAC5EM,MAAMf,cAAcG,OAAO,CAACK,OAAO,CAACH,KAAK,CAACU,IAAI;oBAC9CQ,MAAM;wBACJuB,IAAI;4BAAE/B,MAAMyB;wBAAO;wBACnBhB,QAAQ;4BAAET,MAAMnC;wBAAc;wBAC9B6C,OAAO;4BAAEV,MAAMtC;wBAAe;oBAChC;oBACAwD,SAAS3C,eAAegB;gBAC1B;YACF;QACF;IACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isFieldNullable.d.ts","sourceRoot":"","sources":["../../src/schema/isFieldNullable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AAIjD,eAAO,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"isFieldNullable.d.ts","sourceRoot":"","sources":["../../src/schema/isFieldNullable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AAIjD,eAAO,MAAM,eAAe,iDAIzB;IACD,KAAK,EAAE,kBAAkB,CAAA;IACzB,aAAa,EAAE,OAAO,CAAA;IACtB,iBAAiB,EAAE,OAAO,CAAA;CAC3B,KAAG,OAYH,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operators.d.ts","sourceRoot":"","sources":["../../src/schema/operators.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS
|
|
1
|
+
{"version":3,"file":"operators.d.ts","sourceRoot":"","sources":["../../src/schema/operators.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS;IACpB,UAAU;IACV,QAAQ;IACR,QAAQ;IACR,GAAG;IACH,OAAO;IACP,OAAO;CACR,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recursivelyBuildNestedPaths.d.ts","sourceRoot":"","sources":["../../src/schema/recursivelyBuildNestedPaths.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAO,SAAS,EAAE,MAAM,SAAS,CAAA;AAMjE,KAAK,IAAI,GAAG;IACV,KAAK,EAAE,kBAAkB,GAAG,SAAS,CAAA;IACrC,gBAAgB,EAAE,MAAM,CAAA;IACxB,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,eAAO,MAAM,2BAA2B,
|
|
1
|
+
{"version":3,"file":"recursivelyBuildNestedPaths.d.ts","sourceRoot":"","sources":["../../src/schema/recursivelyBuildNestedPaths.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAO,SAAS,EAAE,MAAM,SAAS,CAAA;AAMjE,KAAK,IAAI,GAAG;IACV,KAAK,EAAE,kBAAkB,GAAG,SAAS,CAAA;IACrC,gBAAgB,EAAE,MAAM,CAAA;IACxB,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,eAAO,MAAM,2BAA2B,4CAA6C,IAAI,QA0ExF,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withNullableType.d.ts","sourceRoot":"","sources":["../../src/schema/withNullableType.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAC1C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"withNullableType.d.ts","sourceRoot":"","sources":["../../src/schema/withNullableType.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAC1C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AAKjD,eAAO,MAAM,gBAAgB,uDAK1B;IACD,KAAK,EAAE,kBAAkB,CAAA;IACzB,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,iBAAiB,EAAE,OAAO,CAAA;IAC1B,IAAI,EAAE,WAAW,CAAA;CAClB,KAAG,WAsBH,CAAA"}
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import { GraphQLNonNull } from 'graphql';
|
|
2
|
+
import { fieldIsVirtual } from 'payload/shared';
|
|
2
3
|
export const withNullableType = ({ type, field, forceNullable, parentIsLocalized })=>{
|
|
3
4
|
const hasReadAccessControl = field.access && field.access.read;
|
|
4
5
|
const condition = field.admin && field.admin.condition;
|
|
5
6
|
const isTimestamp = field.name === 'createdAt' || field.name === 'updatedAt';
|
|
6
|
-
|
|
7
|
+
// Virtual fields are computed (by hooks or from a linked relationship), so they must
|
|
8
|
+
// not be non-null in the GraphQL schema even when marked required.
|
|
9
|
+
const isVirtual = fieldIsVirtual(field);
|
|
10
|
+
if (!forceNullable && 'required' in field && field.required && (!field.localized || parentIsLocalized) && !condition && !hasReadAccessControl && !isTimestamp && !isVirtual) {
|
|
7
11
|
return new GraphQLNonNull(type);
|
|
8
12
|
}
|
|
9
13
|
return type;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/schema/withNullableType.ts"],"sourcesContent":["import type { GraphQLType } from 'graphql'\nimport type { FieldAffectingData } from 'payload'\n\nimport { GraphQLNonNull } from 'graphql'\n\nexport const withNullableType = ({\n type,\n field,\n forceNullable,\n parentIsLocalized,\n}: {\n field: FieldAffectingData\n forceNullable?: boolean\n parentIsLocalized: boolean\n type: GraphQLType\n}): GraphQLType => {\n const hasReadAccessControl = field.access && field.access.read\n const condition = field.admin && field.admin.condition\n const isTimestamp = field.name === 'createdAt' || field.name === 'updatedAt'\n\n if (\n !forceNullable &&\n 'required' in field &&\n field.required &&\n (!field.localized || parentIsLocalized) &&\n !condition &&\n !hasReadAccessControl &&\n !isTimestamp\n ) {\n return new GraphQLNonNull(type)\n }\n\n return type\n}\n"],"names":["GraphQLNonNull","withNullableType","type","field","forceNullable","parentIsLocalized","hasReadAccessControl","access","read","condition","admin","isTimestamp","name","required","localized"],"mappings":"AAGA,SAASA,cAAc,QAAQ,UAAS;
|
|
1
|
+
{"version":3,"sources":["../../src/schema/withNullableType.ts"],"sourcesContent":["import type { GraphQLType } from 'graphql'\nimport type { FieldAffectingData } from 'payload'\n\nimport { GraphQLNonNull } from 'graphql'\nimport { fieldIsVirtual } from 'payload/shared'\n\nexport const withNullableType = ({\n type,\n field,\n forceNullable,\n parentIsLocalized,\n}: {\n field: FieldAffectingData\n forceNullable?: boolean\n parentIsLocalized: boolean\n type: GraphQLType\n}): GraphQLType => {\n const hasReadAccessControl = field.access && field.access.read\n const condition = field.admin && field.admin.condition\n const isTimestamp = field.name === 'createdAt' || field.name === 'updatedAt'\n // Virtual fields are computed (by hooks or from a linked relationship), so they must\n // not be non-null in the GraphQL schema even when marked required.\n const isVirtual = fieldIsVirtual(field)\n\n if (\n !forceNullable &&\n 'required' in field &&\n field.required &&\n (!field.localized || parentIsLocalized) &&\n !condition &&\n !hasReadAccessControl &&\n !isTimestamp &&\n !isVirtual\n ) {\n return new GraphQLNonNull(type)\n }\n\n return type\n}\n"],"names":["GraphQLNonNull","fieldIsVirtual","withNullableType","type","field","forceNullable","parentIsLocalized","hasReadAccessControl","access","read","condition","admin","isTimestamp","name","isVirtual","required","localized"],"mappings":"AAGA,SAASA,cAAc,QAAQ,UAAS;AACxC,SAASC,cAAc,QAAQ,iBAAgB;AAE/C,OAAO,MAAMC,mBAAmB,CAAC,EAC/BC,IAAI,EACJC,KAAK,EACLC,aAAa,EACbC,iBAAiB,EAMlB;IACC,MAAMC,uBAAuBH,MAAMI,MAAM,IAAIJ,MAAMI,MAAM,CAACC,IAAI;IAC9D,MAAMC,YAAYN,MAAMO,KAAK,IAAIP,MAAMO,KAAK,CAACD,SAAS;IACtD,MAAME,cAAcR,MAAMS,IAAI,KAAK,eAAeT,MAAMS,IAAI,KAAK;IACjE,qFAAqF;IACrF,mEAAmE;IACnE,MAAMC,YAAYb,eAAeG;IAEjC,IACE,CAACC,iBACD,cAAcD,SACdA,MAAMW,QAAQ,IACb,CAAA,CAACX,MAAMY,SAAS,IAAIV,iBAAgB,KACrC,CAACI,aACD,CAACH,wBACD,CAACK,eACD,CAACE,WACD;QACA,OAAO,IAAId,eAAeG;IAC5B;IAEA,OAAOA;AACT,EAAC"}
|
|
@@ -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;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,aAAa,
|
|
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;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,aAAa,UACjB,kBAAkB,cACb,MAAM,KACjB,sBAiDF,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"combineParentName.d.ts","sourceRoot":"","sources":["../../src/utilities/combineParentName.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,iBAAiB,
|
|
1
|
+
{"version":3,"file":"combineParentName.d.ts","sourceRoot":"","sources":["../../src/utilities/combineParentName.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,iBAAiB,WAAY,MAAM,QAAQ,MAAM,KAAG,MACb,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatName.d.ts","sourceRoot":"","sources":["../../src/utilities/formatName.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"formatName.d.ts","sourceRoot":"","sources":["../../src/utilities/formatName.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,UAAU,WAAY,MAAM,KAAG,MAgC3C,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatOptions.d.ts","sourceRoot":"","sources":["../../src/utilities/formatOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAItD,eAAO,MAAM,aAAa,
|
|
1
|
+
{"version":3,"file":"formatOptions.d.ts","sourceRoot":"","sources":["../../src/utilities/formatOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAItD,eAAO,MAAM,aAAa,UAAW,UAAU,GAAG,WAAW,OAkB5D,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatUtcOffset.d.ts","sourceRoot":"","sources":["../../src/utilities/formatUtcOffset.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,eAAO,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"formatUtcOffset.d.ts","sourceRoot":"","sources":["../../src/utilities/formatUtcOffset.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,eAAO,MAAM,eAAe,UAAW,MAAM,KAAG,IAAI,GAAG,MAYtD,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"groupOrTabHasRequiredSubfield.d.ts","sourceRoot":"","sources":["../../src/utilities/groupOrTabHasRequiredSubfield.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,SAAS,CAAA;AAIzC,eAAO,MAAM,6BAA6B,
|
|
1
|
+
{"version":3,"file":"groupOrTabHasRequiredSubfield.d.ts","sourceRoot":"","sources":["../../src/utilities/groupOrTabHasRequiredSubfield.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,SAAS,CAAA;AAIzC,eAAO,MAAM,6BAA6B,WAAY,KAAK,GAAG,GAAG,KAAG,OAenE,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/graphql",
|
|
3
|
-
"version": "4.0.0-internal.
|
|
3
|
+
"version": "4.0.0-internal.567a487",
|
|
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.567a487"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
59
|
"graphql": "^16.8.1",
|
|
60
|
-
"payload": "4.0.0-internal.
|
|
60
|
+
"payload": "4.0.0-internal.567a487"
|
|
61
61
|
},
|
|
62
62
|
"scripts": {
|
|
63
63
|
"build": "pnpm build:types && pnpm build:swc",
|