@payloadcms/graphql 4.0.0-internal.ea6e8f8 → 4.0.0-internal.ee5d8bd

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.
Files changed (101) hide show
  1. package/dist/bin/index.js +0 -0
  2. package/dist/bin/index.js.map +0 -0
  3. package/dist/resolvers/auth/login.d.ts.map +1 -1
  4. package/dist/resolvers/auth/login.js +1 -0
  5. package/dist/resolvers/auth/login.js.map +1 -1
  6. package/dist/resolvers/auth/refresh.d.ts.map +1 -1
  7. package/dist/resolvers/auth/refresh.js +3 -1
  8. package/dist/resolvers/auth/refresh.js.map +1 -1
  9. package/dist/resolvers/collections/count.d.ts +1 -3
  10. package/dist/resolvers/collections/count.d.ts.map +1 -1
  11. package/dist/resolvers/collections/count.js +11 -11
  12. package/dist/resolvers/collections/count.js.map +1 -1
  13. package/dist/resolvers/collections/create.d.ts +1 -3
  14. package/dist/resolvers/collections/create.d.ts.map +1 -1
  15. package/dist/resolvers/collections/create.js +7 -12
  16. package/dist/resolvers/collections/create.js.map +1 -1
  17. package/dist/resolvers/collections/delete.d.ts +1 -3
  18. package/dist/resolvers/collections/delete.d.ts.map +1 -1
  19. package/dist/resolvers/collections/delete.js +14 -12
  20. package/dist/resolvers/collections/delete.js.map +1 -1
  21. package/dist/resolvers/collections/docAccess.d.ts +4 -5
  22. package/dist/resolvers/collections/docAccess.d.ts.map +1 -1
  23. package/dist/resolvers/collections/docAccess.js +3 -10
  24. package/dist/resolvers/collections/docAccess.js.map +1 -1
  25. package/dist/resolvers/collections/duplicate.d.ts +1 -3
  26. package/dist/resolvers/collections/duplicate.d.ts.map +1 -1
  27. package/dist/resolvers/collections/duplicate.js +9 -12
  28. package/dist/resolvers/collections/duplicate.js.map +1 -1
  29. package/dist/resolvers/collections/find.d.ts +0 -1
  30. package/dist/resolvers/collections/find.d.ts.map +1 -1
  31. package/dist/resolvers/collections/find.js +10 -11
  32. package/dist/resolvers/collections/find.js.map +1 -1
  33. package/dist/resolvers/collections/findByID.d.ts +0 -1
  34. package/dist/resolvers/collections/findByID.d.ts.map +1 -1
  35. package/dist/resolvers/collections/findByID.js +10 -11
  36. package/dist/resolvers/collections/findByID.js.map +1 -1
  37. package/dist/resolvers/collections/findVersionByID.d.ts +0 -1
  38. package/dist/resolvers/collections/findVersionByID.d.ts.map +1 -1
  39. package/dist/resolvers/collections/findVersionByID.js +10 -11
  40. package/dist/resolvers/collections/findVersionByID.js.map +1 -1
  41. package/dist/resolvers/collections/findVersions.d.ts +0 -1
  42. package/dist/resolvers/collections/findVersions.d.ts.map +1 -1
  43. package/dist/resolvers/collections/findVersions.js +10 -11
  44. package/dist/resolvers/collections/findVersions.js.map +1 -1
  45. package/dist/resolvers/collections/restoreVersion.d.ts +1 -3
  46. package/dist/resolvers/collections/restoreVersion.d.ts.map +1 -1
  47. package/dist/resolvers/collections/restoreVersion.js +3 -10
  48. package/dist/resolvers/collections/restoreVersion.js.map +1 -1
  49. package/dist/resolvers/collections/update.d.ts +1 -3
  50. package/dist/resolvers/collections/update.d.ts.map +1 -1
  51. package/dist/resolvers/collections/update.js +15 -13
  52. package/dist/resolvers/collections/update.js.map +1 -1
  53. package/dist/resolvers/globals/docAccess.d.ts +4 -6
  54. package/dist/resolvers/globals/docAccess.d.ts.map +1 -1
  55. package/dist/resolvers/globals/docAccess.js +3 -10
  56. package/dist/resolvers/globals/docAccess.js.map +1 -1
  57. package/dist/resolvers/globals/findOne.d.ts +0 -1
  58. package/dist/resolvers/globals/findOne.d.ts.map +1 -1
  59. package/dist/resolvers/globals/findOne.js +10 -11
  60. package/dist/resolvers/globals/findOne.js.map +1 -1
  61. package/dist/resolvers/globals/findVersionByID.d.ts +0 -1
  62. package/dist/resolvers/globals/findVersionByID.d.ts.map +1 -1
  63. package/dist/resolvers/globals/findVersionByID.js +10 -11
  64. package/dist/resolvers/globals/findVersionByID.js.map +1 -1
  65. package/dist/resolvers/globals/findVersions.d.ts +0 -1
  66. package/dist/resolvers/globals/findVersions.d.ts.map +1 -1
  67. package/dist/resolvers/globals/findVersions.js +10 -11
  68. package/dist/resolvers/globals/findVersions.js.map +1 -1
  69. package/dist/resolvers/globals/restoreVersion.d.ts +1 -3
  70. package/dist/resolvers/globals/restoreVersion.d.ts.map +1 -1
  71. package/dist/resolvers/globals/restoreVersion.js +4 -11
  72. package/dist/resolvers/globals/restoreVersion.js.map +1 -1
  73. package/dist/resolvers/globals/update.d.ts +1 -3
  74. package/dist/resolvers/globals/update.d.ts.map +1 -1
  75. package/dist/resolvers/globals/update.js +9 -12
  76. package/dist/resolvers/globals/update.js.map +1 -1
  77. package/dist/schema/buildMutationInputType.d.ts.map +1 -1
  78. package/dist/schema/buildMutationInputType.js +36 -48
  79. package/dist/schema/buildMutationInputType.js.map +1 -1
  80. package/dist/schema/buildPoliciesType.d.ts +6 -5
  81. package/dist/schema/buildPoliciesType.d.ts.map +1 -1
  82. package/dist/schema/buildPoliciesType.js +14 -10
  83. package/dist/schema/buildPoliciesType.js.map +1 -1
  84. package/dist/schema/buildWhereInputType.js.map +1 -1
  85. package/dist/schema/fieldToSchemaMap.d.ts.map +1 -1
  86. package/dist/schema/fieldToSchemaMap.js +20 -43
  87. package/dist/schema/fieldToSchemaMap.js.map +1 -1
  88. package/dist/schema/initCollections.d.ts.map +1 -1
  89. package/dist/schema/initCollections.js +15 -33
  90. package/dist/schema/initCollections.js.map +1 -1
  91. package/dist/schema/initGlobals.d.ts.map +1 -1
  92. package/dist/schema/initGlobals.js +0 -20
  93. package/dist/schema/initGlobals.js.map +1 -1
  94. package/dist/utilities/groupOrTabHasRequiredSubfield.d.ts.map +1 -1
  95. package/dist/utilities/groupOrTabHasRequiredSubfield.js +4 -1
  96. package/dist/utilities/groupOrTabHasRequiredSubfield.js.map +1 -1
  97. package/package.json +18 -21
  98. package/dist/resolvers/getGraphQLRequest.d.ts +0 -26
  99. package/dist/resolvers/getGraphQLRequest.d.ts.map +0 -1
  100. package/dist/resolvers/getGraphQLRequest.js +0 -69
  101. package/dist/resolvers/getGraphQLRequest.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 { renameFileResolver } from '../resolvers/collections/renameFile.js'\nimport { restoreVersionResolver } from '../resolvers/collections/restoreVersion.js'\nimport { updateResolver } from '../resolvers/collections/update.js'\nimport { validateResolver } from '../resolvers/collections/validate.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 validationMutationInputType = buildMutationInputType({\n name: `${singularName}Validation`,\n config,\n fields: mutationCreateInputFields,\n forceNullable: true,\n graphqlResult,\n parentIsLocalized: false,\n parentName: `${singularName}Validation`,\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 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 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 branch: { type: GraphQLString },\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 branch: { type: GraphQLString },\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 branch: { type: GraphQLString },\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 branch: { type: GraphQLString },\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 branch: { type: GraphQLString },\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[`validate${singularName}`] = {\n type: graphqlResult.types.validationResultType,\n args: {\n id: { type: idType },\n ...(validationMutationInputType ? { data: { type: validationMutationInputType } } : {}),\n draft: { type: GraphQLBoolean },\n ...(config.localization\n ? {\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n },\n resolve: validateResolver(collection),\n }\n\n graphqlResult.Mutation.fields[`delete${singularName}`] = {\n type: collection.graphQL.type,\n args: {\n id: { type: new GraphQLNonNull(idType) },\n branch: { type: GraphQLString },\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 branch: { type: GraphQLString },\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 branch: { type: GraphQLString },\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 branch: { type: GraphQLString },\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 branch: { type: GraphQLString },\n draft: { type: GraphQLBoolean },\n },\n resolve: restoreVersionResolver(collection),\n }\n }\n }\n\n if (mutationsEnabled && collectionConfig.upload) {\n graphqlResult.Mutation.fields[`renameFile${formatName(singularName)}`] = {\n type: collection.graphQL.type,\n args: {\n id: { type: new GraphQLNonNull(idType) },\n draft: { type: GraphQLBoolean },\n filename: { type: new GraphQLNonNull(GraphQLString) },\n },\n resolve: renameFileResolver(collection),\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","renameFileResolver","restoreVersionResolver","updateResolver","validateResolver","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","validationMutationInputType","queriesEnabled","disableQueries","mutationsEnabled","disableMutations","Query","args","branch","draft","localization","fallbackLocale","types","fallbackLocaleInputType","locale","localeInputType","select","trash","resolve","where","limit","page","pagination","sort","totalDocs","entity","scope","typeSuffix","Mutation","data","autosave","validationResultType","disableDuplicate","versionIDType","versionCollectionFields","t","versionType","upload","filename","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,8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,CAAC,aAAa,EAAEG,cAAc,CAAC,GAAG;wBAC9De,MAAM,IAAIjE,kBAAkB;4BAC1B0D,MAAM5B,WAAW,GAAGc,KAAK,aAAa,CAAC;4BACvCG,QAAQ;gCACNyF,OAAO;oCAAEvE,MAAMhE;gCAAc;gCAC7BwI,MAAM;oCAAExE,MAAMpB,WAAWG,OAAO,CAACiB,IAAI;gCAAC;4BACxC;wBACF;wBACAgC,MAAM;4BACJ+C,UAAU;gCAAE/E,MAAMhE;4BAAc;4BAChCuI,OAAO;gCAAEvE,MAAMhE;4BAAc;wBAC/B;wBACA2G,SAAS9F,cAAc+B;oBACzB;oBAEAN,cAAc+E,QAAQ,CAACvE,MAAM,CAAC,CAAC,WAAW,EAAEG,cAAc,CAAC,GAAG;wBAC5De,MAAMpE;wBACNoG,MAAM;4BACJuC,OAAO;gCAAEvE,MAAMhE;4BAAc;wBAC/B;wBACA2G,SAAS5F,YAAY6B;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 { renameFileResolver } from '../resolvers/collections/renameFile.js'\nimport { restoreVersionResolver } from '../resolvers/collections/restoreVersion.js'\nimport { updateResolver } from '../resolvers/collections/update.js'\nimport { validateResolver } from '../resolvers/collections/validate.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 = {}, 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 validationMutationInputType = buildMutationInputType({\n name: `${singularName}Validation`,\n config,\n fields: mutationCreateInputFields,\n forceNullable: true,\n graphqlResult,\n parentIsLocalized: false,\n parentName: `${singularName}Validation`,\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[`validate${singularName}`] = {\n type: graphqlResult.types.validationResultType,\n args: {\n id: { type: idType },\n ...(validationMutationInputType ? { data: { type: validationMutationInputType } } : {}),\n draft: { type: GraphQLBoolean },\n ...(config.localization\n ? {\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n },\n resolve: validateResolver(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 (mutationsEnabled && collectionConfig.upload) {\n graphqlResult.Mutation.fields[`renameFile${formatName(singularName)}`] = {\n type: collection.graphQL.type,\n args: {\n id: { type: new GraphQLNonNull(idType) },\n draft: { type: GraphQLBoolean },\n filename: { type: new GraphQLNonNull(GraphQLString) },\n },\n resolve: renameFileResolver(collection),\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 ...(collectionConfig.auth.refreshTokens\n ? { refreshToken: { type: GraphQLString } }\n : {}),\n user: {\n type: collection.graphQL.JWT,\n },\n },\n }),\n args: collectionConfig.auth.refreshTokens\n ? { refreshToken: { type: GraphQLString } }\n : undefined,\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 ...(collectionConfig.auth.refreshTokens\n ? { refreshToken: { type: GraphQLString } }\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","renameFileResolver","restoreVersionResolver","updateResolver","validateResolver","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","validationMutationInputType","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","validationResultType","disableDuplicate","versionIDType","versionCollectionFields","t","versionType","upload","filename","authFields","loginWithUsername","allowEmailLogin","requireEmail","JWT","saveToJWT","exp","token","user","refreshedToken","refreshTokens","refreshToken","undefined","allSessions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a,EAAE,WAAW,CAAA;CAC3B,CAAA;AACD,wBAAgB,WAAW,CAAC,EAAE,MAAM,EAAE,aAAa,EAAE,EAAE,sBAAsB,GAAG,IAAI,CA6MnF"}
1
+ {"version":3,"file":"initGlobals.d.ts","sourceRoot":"","sources":["../../src/schema/initGlobals.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAS,WAAW,EAAE,eAAe,EAAyB,MAAM,SAAS,CAAA;AAmBzF,KAAK,sBAAsB,GAAG;IAC5B,MAAM,EAAE,eAAe,CAAA;IACvB,aAAa,EAAE,WAAW,CAAA;CAC3B,CAAA;AACD,wBAAgB,WAAW,CAAC,EAAE,MAAM,EAAE,aAAa,EAAE,EAAE,sBAAsB,GAAG,IAAI,CAqMnF"}
@@ -62,9 +62,6 @@ export function initGlobals({ config, graphqlResult }) {
62
62
  graphqlResult.Query.fields[formattedName] = {
63
63
  type: graphqlResult.globals.graphQL[slug].type,
64
64
  args: {
65
- branch: {
66
- type: GraphQLString
67
- },
68
65
  draft: {
69
66
  type: GraphQLBoolean
70
67
  },
@@ -89,11 +86,6 @@ export function initGlobals({ config, graphqlResult }) {
89
86
  scope: 'docAccess',
90
87
  typeSuffix: 'DocAccess'
91
88
  }),
92
- args: {
93
- branch: {
94
- type: GraphQLString
95
- }
96
- },
97
89
  resolve: docAccessResolver(global)
98
90
  };
99
91
  }
@@ -106,9 +98,6 @@ export function initGlobals({ config, graphqlResult }) {
106
98
  type: graphqlResult.globals.graphQL[slug].mutationInputType
107
99
  }
108
100
  } : {},
109
- branch: {
110
- type: GraphQLString
111
- },
112
101
  draft: {
113
102
  type: GraphQLBoolean
114
103
  },
@@ -174,9 +163,6 @@ export function initGlobals({ config, graphqlResult }) {
174
163
  id: {
175
164
  type: idType
176
165
  },
177
- branch: {
178
- type: GraphQLString
179
- },
180
166
  draft: {
181
167
  type: GraphQLBoolean
182
168
  },
@@ -197,9 +183,6 @@ export function initGlobals({ config, graphqlResult }) {
197
183
  graphqlResult.Query.fields[`versions${formattedName}`] = {
198
184
  type: buildPaginatedListType(`versions${formatName(formattedName)}`, graphqlResult.globals.graphQL[slug].versionType),
199
185
  args: {
200
- branch: {
201
- type: GraphQLString
202
- },
203
186
  where: {
204
187
  type: buildWhereInputType({
205
188
  name: `versions${formattedName}`,
@@ -241,9 +224,6 @@ export function initGlobals({ config, graphqlResult }) {
241
224
  id: {
242
225
  type: idType
243
226
  },
244
- branch: {
245
- type: GraphQLString
246
- },
247
227
  draft: {
248
228
  type: GraphQLBoolean
249
229
  }
@@ -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 { validateResolver as validateGlobalResolver } from '../resolvers/globals/validate.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 const validationMutationInputType = buildMutationInputType({\n name: `${formattedName}Validation`,\n config,\n fields,\n forceNullable: true,\n graphqlResult,\n parentIsLocalized: false,\n parentName: `${formattedName}Validation`,\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 args: {\n branch: { type: GraphQLString },\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 graphqlResult.Mutation.fields[`validate${formattedName}`] = {\n type: graphqlResult.types.validationResultType,\n args: {\n ...(validationMutationInputType ? { data: { type: validationMutationInputType } } : {}),\n draft: { type: GraphQLBoolean },\n ...(config.localization\n ? {\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n },\n resolve: validateGlobalResolver(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 branch: { type: GraphQLString },\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","validateResolver","validateGlobalResolver","formatName","buildMutationInputType","buildObjectType","buildPaginatedListType","buildPolicyType","buildWhereInputType","initGlobals","config","graphqlResult","Object","keys","globals","forEach","slug","global","fields","graphQL","formattedName","name","forceNullableObjectType","updateMutationInputType","parentIsLocalized","parentName","validationMutationInputType","forceNullable","type","mutationInputType","queriesEnabled","disableQueries","mutationsEnabled","disableMutations","Query","args","branch","draft","localization","fallbackLocale","types","fallbackLocaleInputType","locale","localeInputType","select","resolve","entity","scope","typeSuffix","Mutation","data","validationResultType","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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c6B,KAAK,CAACC,uBAAuB;4BAAC;4BACpEC,QAAQ;gCAAEd,MAAMjB,cAAc6B,KAAK,CAACG,eAAe;4BAAC;wBACtD,IACA,CAAC,CAAC;wBACNkB,OAAO;4BAAEjC,MAAMzC;wBAAW;wBAC1B2E,MAAM;4BAAElC,MAAMzC;wBAAW;wBACzB4E,YAAY;4BAAEnC,MAAM1C;wBAAe;wBACnC0D,QAAQ;4BAAEhB,MAAM1C;wBAAe;wBAC/B8E,MAAM;4BAAEpC,MAAMvC;wBAAc;oBAC9B;oBACAwD,SAAS/C,aAAamB;gBACxB;YACF;YAEA,IAAIe,kBAAkB;gBACpBrB,cAAcsC,QAAQ,CAAC/B,MAAM,CAAC,CAAC,cAAc,EAAEf,WAAWiB,gBAAgB,CAAC,GAAG;oBAC5EQ,MAAMjB,cAAcG,OAAO,CAACK,OAAO,CAACH,KAAK,CAACY,IAAI;oBAC9CO,MAAM;wBACJwB,IAAI;4BAAE/B,MAAMyB;wBAAO;wBACnBjB,QAAQ;4BAAER,MAAMvC;wBAAc;wBAC9BgD,OAAO;4BAAET,MAAM1C;wBAAe;oBAChC;oBACA2D,SAAS9C,eAAekB;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 { validateResolver as validateGlobalResolver } from '../resolvers/globals/validate.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 const validationMutationInputType = buildMutationInputType({\n name: `${formattedName}Validation`,\n config,\n fields,\n forceNullable: true,\n graphqlResult,\n parentIsLocalized: false,\n parentName: `${formattedName}Validation`,\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 graphqlResult.Mutation.fields[`validate${formattedName}`] = {\n type: graphqlResult.types.validationResultType,\n args: {\n ...(validationMutationInputType ? { data: { type: validationMutationInputType } } : {}),\n draft: { type: GraphQLBoolean },\n ...(config.localization\n ? {\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n },\n resolve: validateGlobalResolver(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","validateResolver","validateGlobalResolver","formatName","buildMutationInputType","buildObjectType","buildPaginatedListType","buildPolicyType","buildWhereInputType","initGlobals","config","graphqlResult","Object","keys","globals","forEach","slug","global","fields","graphQL","formattedName","name","forceNullableObjectType","updateMutationInputType","parentIsLocalized","parentName","validationMutationInputType","forceNullable","type","mutationInputType","queriesEnabled","disableQueries","mutationsEnabled","disableMutations","Query","args","draft","localization","fallbackLocale","types","fallbackLocaleInputType","locale","localeInputType","select","resolve","entity","scope","typeSuffix","Mutation","data","validationResultType","versions","idType","db","defaultIDType","versionGlobalFields","label","versionType","id","where","limit","page","pagination","sort"],"mappings":"AAAA,SAASA,cAAc,EAAE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A,GAAIV,OAAO2B,YAAY,GACnB;4BACEC,gBAAgB;gCAAEV,MAAMjB,cAAc4B,KAAK,CAACC,uBAAuB;4BAAC;4BACpEC,QAAQ;gCAAEb,MAAMjB,cAAc4B,KAAK,CAACG,eAAe;4BAAC;wBACtD,IACA,CAAC,CAAC;wBACNkB,OAAO;4BAAEhC,MAAMzC;wBAAW;wBAC1B0E,MAAM;4BAAEjC,MAAMzC;wBAAW;wBACzB2E,YAAY;4BAAElC,MAAM1C;wBAAe;wBACnCyD,QAAQ;4BAAEf,MAAM1C;wBAAe;wBAC/B6E,MAAM;4BAAEnC,MAAMvC;wBAAc;oBAC9B;oBACAuD,SAAS9C,aAAamB;gBACxB;YACF;YAEA,IAAIe,kBAAkB;gBACpBrB,cAAcqC,QAAQ,CAAC9B,MAAM,CAAC,CAAC,cAAc,EAAEf,WAAWiB,gBAAgB,CAAC,GAAG;oBAC5EQ,MAAMjB,cAAcG,OAAO,CAACK,OAAO,CAACH,KAAK,CAACY,IAAI;oBAC9CO,MAAM;wBACJuB,IAAI;4BAAE9B,MAAMwB;wBAAO;wBACnBhB,OAAO;4BAAER,MAAM1C;wBAAe;oBAChC;oBACA0D,SAAS7C,eAAekB;gBAC1B;YACF;QACF;IACF;AACF"}
@@ -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,WAAY,KAAK,GAAG,GAAG,KAAG,OAenE,CAAA"}
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,OAsBnE,CAAA"}
@@ -1,8 +1,11 @@
1
1
  import { fieldAffectsData } from 'payload/shared';
2
2
  export const groupOrTabHasRequiredSubfield = (entity)=>{
3
+ if ('hidden' in entity && entity.hidden) {
4
+ return false;
5
+ }
3
6
  if ('type' in entity && entity.type === 'group') {
4
7
  return entity.fields.some((subField)=>{
5
- return fieldAffectsData(subField) && 'required' in subField && subField.required || groupOrTabHasRequiredSubfield(subField);
8
+ return fieldAffectsData(subField) && !subField.hidden && 'required' in subField && subField.required || groupOrTabHasRequiredSubfield(subField);
6
9
  });
7
10
  }
8
11
  if ('fields' in entity && 'name' in entity) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utilities/groupOrTabHasRequiredSubfield.ts"],"sourcesContent":["import type { Field, Tab } from 'payload'\n\nimport { fieldAffectsData } from 'payload/shared'\n\nexport const groupOrTabHasRequiredSubfield = (entity: Field | Tab): boolean => {\n if ('type' in entity && entity.type === 'group') {\n return entity.fields.some((subField) => {\n return (\n (fieldAffectsData(subField) && 'required' in subField && subField.required) ||\n groupOrTabHasRequiredSubfield(subField)\n )\n })\n }\n\n if ('fields' in entity && 'name' in entity) {\n return (entity as Tab).fields.some((subField) => groupOrTabHasRequiredSubfield(subField))\n }\n\n return false\n}\n"],"names":["fieldAffectsData","groupOrTabHasRequiredSubfield","entity","type","fields","some","subField","required"],"mappings":"AAEA,SAASA,gBAAgB,QAAQ,iBAAgB;AAEjD,OAAO,MAAMC,gCAAgC,CAACC;IAC5C,IAAI,UAAUA,UAAUA,OAAOC,IAAI,KAAK,SAAS;QAC/C,OAAOD,OAAOE,MAAM,CAACC,IAAI,CAAC,CAACC;YACzB,OACE,AAACN,iBAAiBM,aAAa,cAAcA,YAAYA,SAASC,QAAQ,IAC1EN,8BAA8BK;QAElC;IACF;IAEA,IAAI,YAAYJ,UAAU,UAAUA,QAAQ;QAC1C,OAAO,AAACA,OAAeE,MAAM,CAACC,IAAI,CAAC,CAACC,WAAaL,8BAA8BK;IACjF;IAEA,OAAO;AACT,EAAC"}
1
+ {"version":3,"sources":["../../src/utilities/groupOrTabHasRequiredSubfield.ts"],"sourcesContent":["import type { Field, Tab } from 'payload'\n\nimport { fieldAffectsData } from 'payload/shared'\n\nexport const groupOrTabHasRequiredSubfield = (entity: Field | Tab): boolean => {\n if ('hidden' in entity && entity.hidden) {\n return false\n }\n\n if ('type' in entity && entity.type === 'group') {\n return entity.fields.some((subField) => {\n return (\n (fieldAffectsData(subField) &&\n !subField.hidden &&\n 'required' in subField &&\n subField.required) ||\n groupOrTabHasRequiredSubfield(subField)\n )\n })\n }\n\n if ('fields' in entity && 'name' in entity) {\n return (entity as Tab).fields.some((subField) => groupOrTabHasRequiredSubfield(subField))\n }\n\n return false\n}\n"],"names":["fieldAffectsData","groupOrTabHasRequiredSubfield","entity","hidden","type","fields","some","subField","required"],"mappings":"AAEA,SAASA,gBAAgB,QAAQ,iBAAgB;AAEjD,OAAO,MAAMC,gCAAgC,CAACC;IAC5C,IAAI,YAAYA,UAAUA,OAAOC,MAAM,EAAE;QACvC,OAAO;IACT;IAEA,IAAI,UAAUD,UAAUA,OAAOE,IAAI,KAAK,SAAS;QAC/C,OAAOF,OAAOG,MAAM,CAACC,IAAI,CAAC,CAACC;YACzB,OACE,AAACP,iBAAiBO,aAChB,CAACA,SAASJ,MAAM,IAChB,cAAcI,YACdA,SAASC,QAAQ,IACnBP,8BAA8BM;QAElC;IACF;IAEA,IAAI,YAAYL,UAAU,UAAUA,QAAQ;QAC1C,OAAO,AAACA,OAAeG,MAAM,CAACC,IAAI,CAAC,CAACC,WAAaN,8BAA8BM;IACjF;IAEA,OAAO;AACT,EAAC"}
package/package.json CHANGED
@@ -1,12 +1,7 @@
1
1
  {
2
2
  "name": "@payloadcms/graphql",
3
- "version": "4.0.0-internal.ea6e8f8",
3
+ "version": "4.0.0-internal.ee5d8bd",
4
4
  "homepage": "https://payloadcms.com",
5
- "repository": {
6
- "type": "git",
7
- "url": "https://github.com/payloadcms/payload.git",
8
- "directory": "packages/graphql"
9
- },
10
5
  "license": "MIT",
11
6
  "author": "Payload <dev@payloadcms.com> (https://payloadcms.com)",
12
7
  "maintainers": [
@@ -16,8 +11,21 @@
16
11
  "url": "https://payloadcms.com"
17
12
  }
18
13
  ],
19
- "sideEffects": false,
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "https://github.com/payloadcms/payload.git",
17
+ "directory": "packages/graphql"
18
+ },
19
+ "bin": {
20
+ "payload-graphql": "bin.js"
21
+ },
22
+ "files": [
23
+ "dist"
24
+ ],
20
25
  "type": "module",
26
+ "sideEffects": false,
27
+ "main": "./dist/index.js",
28
+ "types": "./dist/index.d.ts",
21
29
  "exports": {
22
30
  ".": {
23
31
  "import": "./dist/index.js",
@@ -35,14 +43,6 @@
35
43
  "default": "./dist/exports/utilities.js"
36
44
  }
37
45
  },
38
- "main": "./dist/index.js",
39
- "types": "./dist/index.d.ts",
40
- "bin": {
41
- "payload-graphql": "bin.js"
42
- },
43
- "files": [
44
- "dist"
45
- ],
46
46
  "dependencies": {
47
47
  "graphql-scalars": "1.22.2",
48
48
  "pluralize": "8.0.0",
@@ -52,20 +52,17 @@
52
52
  "devDependencies": {
53
53
  "@types/pluralize": "^0.0.33",
54
54
  "graphql-http": "1.22.4",
55
- "@payloadcms/eslint-config": "3.28.0",
56
- "payload": "4.0.0-internal.ea6e8f8"
55
+ "payload": "4.0.0-internal.ee5d8bd"
57
56
  },
58
57
  "peerDependencies": {
59
58
  "graphql": "^16.8.1",
60
- "payload": "4.0.0-internal.ea6e8f8"
59
+ "payload": "4.0.0-internal.ee5d8bd"
61
60
  },
62
61
  "scripts": {
63
62
  "build": "pnpm build:types && pnpm build:swc",
64
63
  "build:debug": "pnpm build",
65
64
  "build:swc": "swc ./src -d ./dist --config-file .swcrc --strip-leading-paths",
66
65
  "build:types": "tsc --emitDeclarationOnly --outDir dist",
67
- "clean": "rimraf -g {dist,*.tsbuildinfo}",
68
- "lint": "eslint .",
69
- "lint:fix": "eslint . --fix"
66
+ "clean": "rimraf -g {dist,*.tsbuildinfo}"
70
67
  }
71
68
  }
@@ -1,26 +0,0 @@
1
- import type { GraphQLResolveInfo } from 'graphql';
2
- import type { PayloadRequest } from 'payload';
3
- import type { Context } from './types.js';
4
- type GetGraphQLRequestArgs = {
5
- branch?: string;
6
- collectionSlug?: string;
7
- context: Context;
8
- fallbackLocale?: PayloadRequest['fallbackLocale'];
9
- globalSlug?: string;
10
- info: GraphQLResolveInfo;
11
- locale?: PayloadRequest['locale'];
12
- };
13
- /**
14
- * Creates the request owned by one GraphQL root field.
15
- *
16
- * GraphQL resolves sibling query fields concurrently. Each field therefore needs its own mutable
17
- * request state, including its branch cache and DataLoader, while nested field resolvers need a
18
- * stable way to recover that same request after the root resolver has completed.
19
- */
20
- export declare const getGraphQLRequest: ({ branch, collectionSlug, context, fallbackLocale, globalSlug, info, locale, }: GetGraphQLRequestArgs) => Promise<PayloadRequest>;
21
- export declare const getGraphQLRequestForNestedField: ({ context, info, }: {
22
- context: Context;
23
- info: GraphQLResolveInfo;
24
- }) => PayloadRequest;
25
- export {};
26
- //# sourceMappingURL=getGraphQLRequest.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getGraphQLRequest.d.ts","sourceRoot":"","sources":["../../src/resolvers/getGraphQLRequest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AACjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAS7C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AASzC,KAAK,qBAAqB,GAAG;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,OAAO,EAAE,OAAO,CAAA;IAChB,cAAc,CAAC,EAAE,cAAc,CAAC,gBAAgB,CAAC,CAAA;IACjD,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,IAAI,EAAE,kBAAkB,CAAA;IACxB,MAAM,CAAC,EAAE,cAAc,CAAC,QAAQ,CAAC,CAAA;CAClC,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,mFAQ3B,qBAAqB,KAAG,OAAO,CAAC,cAAc,CAkChD,CAAA;AAED,eAAO,MAAM,+BAA+B,uBAGzC;IACD,OAAO,EAAE,OAAO,CAAA;IAChB,IAAI,EAAE,kBAAkB,CAAA;CACzB,KAAG,cACgG,CAAA"}
@@ -1,69 +0,0 @@
1
- import { assertBranchReadable, getDataLoader, isolateObjectProperty, resetBranchState } from 'payload';
2
- const requestsByContext = new WeakMap();
3
- /**
4
- * Creates the request owned by one GraphQL root field.
5
- *
6
- * GraphQL resolves sibling query fields concurrently. Each field therefore needs its own mutable
7
- * request state, including its branch cache and DataLoader, while nested field resolvers need a
8
- * stable way to recover that same request after the root resolver has completed.
9
- */ export const getGraphQLRequest = async ({ branch, collectionSlug, context, fallbackLocale, globalSlug, info, locale })=>{
10
- const req = isolateObjectProperty(context.req, [
11
- 'branch',
12
- 'context',
13
- 'fallbackLocale',
14
- 'locale',
15
- 'payloadDataLoader',
16
- 'query',
17
- 'transactionID'
18
- ]);
19
- req.context = {
20
- ...context.req.context
21
- };
22
- req.query = {
23
- ...context.req.query
24
- };
25
- if (typeof locale !== 'undefined') {
26
- req.locale = locale;
27
- }
28
- if (typeof fallbackLocale !== 'undefined') {
29
- req.fallbackLocale = fallbackLocale;
30
- }
31
- if (typeof branch !== 'undefined') {
32
- req.branch = branch;
33
- }
34
- resetBranchState(req);
35
- req.payloadDataLoader = getDataLoader(req);
36
- registerGraphQLRequest({
37
- context,
38
- info,
39
- req
40
- });
41
- await assertBranchReadable({
42
- collectionSlug,
43
- globalSlug,
44
- req
45
- });
46
- return req;
47
- };
48
- export const getGraphQLRequestForNestedField = ({ context, info })=>requestsByContext.get(context)?.get(info.operation)?.get(getRootPathKey(info.path)) ?? context.req;
49
- const getRootPathKey = (path)=>{
50
- while(path.prev){
51
- path = path.prev;
52
- }
53
- return path.key;
54
- };
55
- const registerGraphQLRequest = ({ context, info, req })=>{
56
- let requestsByOperation = requestsByContext.get(context);
57
- if (!requestsByOperation) {
58
- requestsByOperation = new WeakMap();
59
- requestsByContext.set(context, requestsByOperation);
60
- }
61
- let requestsByRootPath = requestsByOperation.get(info.operation);
62
- if (!requestsByRootPath) {
63
- requestsByRootPath = new Map();
64
- requestsByOperation.set(info.operation, requestsByRootPath);
65
- }
66
- requestsByRootPath.set(getRootPathKey(info.path), req);
67
- };
68
-
69
- //# sourceMappingURL=getGraphQLRequest.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/resolvers/getGraphQLRequest.ts"],"sourcesContent":["import type { GraphQLResolveInfo } from 'graphql'\nimport type { PayloadRequest } from 'payload'\n\nimport {\n assertBranchReadable,\n getDataLoader,\n isolateObjectProperty,\n resetBranchState,\n} from 'payload'\n\nimport type { Context } from './types.js'\n\ntype RequestsByOperation = WeakMap<\n GraphQLResolveInfo['operation'],\n Map<GraphQLResolveInfo['path']['key'], PayloadRequest>\n>\n\nconst requestsByContext = new WeakMap<Context, RequestsByOperation>()\n\ntype GetGraphQLRequestArgs = {\n branch?: string\n collectionSlug?: string\n context: Context\n fallbackLocale?: PayloadRequest['fallbackLocale']\n globalSlug?: string\n info: GraphQLResolveInfo\n locale?: PayloadRequest['locale']\n}\n\n/**\n * Creates the request owned by one GraphQL root field.\n *\n * GraphQL resolves sibling query fields concurrently. Each field therefore needs its own mutable\n * request state, including its branch cache and DataLoader, while nested field resolvers need a\n * stable way to recover that same request after the root resolver has completed.\n */\nexport const getGraphQLRequest = async ({\n branch,\n collectionSlug,\n context,\n fallbackLocale,\n globalSlug,\n info,\n locale,\n}: GetGraphQLRequestArgs): Promise<PayloadRequest> => {\n const req = isolateObjectProperty(context.req, [\n 'branch',\n 'context',\n 'fallbackLocale',\n 'locale',\n 'payloadDataLoader',\n 'query',\n 'transactionID',\n ])\n\n req.context = { ...context.req.context }\n req.query = { ...context.req.query }\n\n if (typeof locale !== 'undefined') {\n req.locale = locale\n }\n\n if (typeof fallbackLocale !== 'undefined') {\n req.fallbackLocale = fallbackLocale\n }\n\n if (typeof branch !== 'undefined') {\n req.branch = branch\n }\n\n resetBranchState(req)\n req.payloadDataLoader = getDataLoader(req)\n\n registerGraphQLRequest({ context, info, req })\n\n await assertBranchReadable({ collectionSlug, globalSlug, req })\n\n return req\n}\n\nexport const getGraphQLRequestForNestedField = ({\n context,\n info,\n}: {\n context: Context\n info: GraphQLResolveInfo\n}): PayloadRequest =>\n requestsByContext.get(context)?.get(info.operation)?.get(getRootPathKey(info.path)) ?? context.req\n\nconst getRootPathKey = (path: GraphQLResolveInfo['path']): GraphQLResolveInfo['path']['key'] => {\n while (path.prev) {\n path = path.prev\n }\n\n return path.key\n}\n\nconst registerGraphQLRequest = ({\n context,\n info,\n req,\n}: {\n context: Context\n info: GraphQLResolveInfo\n req: PayloadRequest\n}): void => {\n let requestsByOperation = requestsByContext.get(context)\n\n if (!requestsByOperation) {\n requestsByOperation = new WeakMap()\n requestsByContext.set(context, requestsByOperation)\n }\n\n let requestsByRootPath = requestsByOperation.get(info.operation)\n\n if (!requestsByRootPath) {\n requestsByRootPath = new Map()\n requestsByOperation.set(info.operation, requestsByRootPath)\n }\n\n requestsByRootPath.set(getRootPathKey(info.path), req)\n}\n"],"names":["assertBranchReadable","getDataLoader","isolateObjectProperty","resetBranchState","requestsByContext","WeakMap","getGraphQLRequest","branch","collectionSlug","context","fallbackLocale","globalSlug","info","locale","req","query","payloadDataLoader","registerGraphQLRequest","getGraphQLRequestForNestedField","get","operation","getRootPathKey","path","prev","key","requestsByOperation","set","requestsByRootPath","Map"],"mappings":"AAGA,SACEA,oBAAoB,EACpBC,aAAa,EACbC,qBAAqB,EACrBC,gBAAgB,QACX,UAAS;AAShB,MAAMC,oBAAoB,IAAIC;AAY9B;;;;;;CAMC,GACD,OAAO,MAAMC,oBAAoB,OA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