@payloadcms/graphql 4.0.0-internal.183b315 → 4.0.0-internal.1a2a79e

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 (145) hide show
  1. package/LICENSE.md +1 -1
  2. package/dist/bin/index.js +0 -0
  3. package/dist/bin/index.js.map +0 -0
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.js +3 -1
  6. package/dist/index.js.map +1 -1
  7. package/dist/packages/graphql-query-complexity/QueryComplexity.d.ts.map +1 -1
  8. package/dist/packages/graphql-query-complexity/estimators/simple/index.d.ts.map +1 -1
  9. package/dist/resolvers/collections/count.d.ts +3 -1
  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 +3 -1
  14. package/dist/resolvers/collections/create.d.ts.map +1 -1
  15. package/dist/resolvers/collections/create.js +12 -7
  16. package/dist/resolvers/collections/create.js.map +1 -1
  17. package/dist/resolvers/collections/delete.d.ts +3 -1
  18. package/dist/resolvers/collections/delete.d.ts.map +1 -1
  19. package/dist/resolvers/collections/delete.js +12 -14
  20. package/dist/resolvers/collections/delete.js.map +1 -1
  21. package/dist/resolvers/collections/docAccess.d.ts +5 -4
  22. package/dist/resolvers/collections/docAccess.d.ts.map +1 -1
  23. package/dist/resolvers/collections/docAccess.js +10 -3
  24. package/dist/resolvers/collections/docAccess.js.map +1 -1
  25. package/dist/resolvers/collections/duplicate.d.ts +3 -1
  26. package/dist/resolvers/collections/duplicate.d.ts.map +1 -1
  27. package/dist/resolvers/collections/duplicate.js +12 -9
  28. package/dist/resolvers/collections/duplicate.js.map +1 -1
  29. package/dist/resolvers/collections/find.d.ts +1 -0
  30. package/dist/resolvers/collections/find.d.ts.map +1 -1
  31. package/dist/resolvers/collections/find.js +11 -10
  32. package/dist/resolvers/collections/find.js.map +1 -1
  33. package/dist/resolvers/collections/findByID.d.ts +1 -0
  34. package/dist/resolvers/collections/findByID.d.ts.map +1 -1
  35. package/dist/resolvers/collections/findByID.js +11 -10
  36. package/dist/resolvers/collections/findByID.js.map +1 -1
  37. package/dist/resolvers/collections/findVersionByID.d.ts +1 -0
  38. package/dist/resolvers/collections/findVersionByID.d.ts.map +1 -1
  39. package/dist/resolvers/collections/findVersionByID.js +11 -10
  40. package/dist/resolvers/collections/findVersionByID.js.map +1 -1
  41. package/dist/resolvers/collections/findVersions.d.ts +1 -0
  42. package/dist/resolvers/collections/findVersions.d.ts.map +1 -1
  43. package/dist/resolvers/collections/findVersions.js +11 -10
  44. package/dist/resolvers/collections/findVersions.js.map +1 -1
  45. package/dist/resolvers/collections/renameFile.d.ts +8 -0
  46. package/dist/resolvers/collections/renameFile.d.ts.map +1 -0
  47. package/dist/resolvers/collections/renameFile.js +10 -0
  48. package/dist/resolvers/collections/renameFile.js.map +1 -0
  49. package/dist/resolvers/collections/restoreVersion.d.ts +3 -1
  50. package/dist/resolvers/collections/restoreVersion.d.ts.map +1 -1
  51. package/dist/resolvers/collections/restoreVersion.js +10 -3
  52. package/dist/resolvers/collections/restoreVersion.js.map +1 -1
  53. package/dist/resolvers/collections/update.d.ts +3 -1
  54. package/dist/resolvers/collections/update.d.ts.map +1 -1
  55. package/dist/resolvers/collections/update.js +13 -15
  56. package/dist/resolvers/collections/update.js.map +1 -1
  57. package/dist/resolvers/collections/validate.d.ts +16 -0
  58. package/dist/resolvers/collections/validate.d.ts.map +1 -0
  59. package/dist/resolvers/collections/validate.js +33 -0
  60. package/dist/resolvers/collections/validate.js.map +1 -0
  61. package/dist/resolvers/getGraphQLRequest.d.ts +26 -0
  62. package/dist/resolvers/getGraphQLRequest.d.ts.map +1 -0
  63. package/dist/resolvers/getGraphQLRequest.js +69 -0
  64. package/dist/resolvers/getGraphQLRequest.js.map +1 -0
  65. package/dist/resolvers/globals/docAccess.d.ts +6 -4
  66. package/dist/resolvers/globals/docAccess.d.ts.map +1 -1
  67. package/dist/resolvers/globals/docAccess.js +10 -3
  68. package/dist/resolvers/globals/docAccess.js.map +1 -1
  69. package/dist/resolvers/globals/findOne.d.ts +1 -0
  70. package/dist/resolvers/globals/findOne.d.ts.map +1 -1
  71. package/dist/resolvers/globals/findOne.js +11 -10
  72. package/dist/resolvers/globals/findOne.js.map +1 -1
  73. package/dist/resolvers/globals/findVersionByID.d.ts +1 -0
  74. package/dist/resolvers/globals/findVersionByID.d.ts.map +1 -1
  75. package/dist/resolvers/globals/findVersionByID.js +11 -10
  76. package/dist/resolvers/globals/findVersionByID.js.map +1 -1
  77. package/dist/resolvers/globals/findVersions.d.ts +1 -0
  78. package/dist/resolvers/globals/findVersions.d.ts.map +1 -1
  79. package/dist/resolvers/globals/findVersions.js +11 -10
  80. package/dist/resolvers/globals/findVersions.js.map +1 -1
  81. package/dist/resolvers/globals/restoreVersion.d.ts +3 -1
  82. package/dist/resolvers/globals/restoreVersion.d.ts.map +1 -1
  83. package/dist/resolvers/globals/restoreVersion.js +10 -3
  84. package/dist/resolvers/globals/restoreVersion.js.map +1 -1
  85. package/dist/resolvers/globals/update.d.ts +3 -1
  86. package/dist/resolvers/globals/update.d.ts.map +1 -1
  87. package/dist/resolvers/globals/update.js +12 -9
  88. package/dist/resolvers/globals/update.js.map +1 -1
  89. package/dist/resolvers/globals/validate.d.ts +15 -0
  90. package/dist/resolvers/globals/validate.d.ts.map +1 -0
  91. package/dist/resolvers/globals/validate.js +21 -0
  92. package/dist/resolvers/globals/validate.js.map +1 -0
  93. package/dist/schema/buildFallbackLocaleInputType.d.ts.map +1 -1
  94. package/dist/schema/buildLocaleInputType.d.ts.map +1 -1
  95. package/dist/schema/buildMutationInputType.d.ts.map +1 -1
  96. package/dist/schema/buildMutationInputType.js +52 -47
  97. package/dist/schema/buildMutationInputType.js.map +1 -1
  98. package/dist/schema/buildPaginatedListType.d.ts.map +1 -1
  99. package/dist/schema/buildPoliciesType.d.ts +7 -6
  100. package/dist/schema/buildPoliciesType.d.ts.map +1 -1
  101. package/dist/schema/buildPoliciesType.js +20 -13
  102. package/dist/schema/buildPoliciesType.js.map +1 -1
  103. package/dist/schema/buildValidationResultType.d.ts +3 -0
  104. package/dist/schema/buildValidationResultType.d.ts.map +1 -0
  105. package/dist/schema/buildValidationResultType.js +30 -0
  106. package/dist/schema/buildValidationResultType.js.map +1 -0
  107. package/dist/schema/buildWhereInputType.d.ts.map +1 -1
  108. package/dist/schema/buildWhereInputType.js.map +1 -1
  109. package/dist/schema/fieldToSchemaMap.d.ts +4 -1
  110. package/dist/schema/fieldToSchemaMap.d.ts.map +1 -1
  111. package/dist/schema/fieldToSchemaMap.js +59 -24
  112. package/dist/schema/fieldToSchemaMap.js.map +1 -1
  113. package/dist/schema/fieldToWhereInputSchemaMap.d.ts.map +1 -1
  114. package/dist/schema/initCollections.d.ts.map +1 -1
  115. package/dist/schema/initCollections.js +93 -7
  116. package/dist/schema/initCollections.js.map +1 -1
  117. package/dist/schema/initGlobals.d.ts.map +1 -1
  118. package/dist/schema/initGlobals.js +49 -0
  119. package/dist/schema/initGlobals.js.map +1 -1
  120. package/dist/schema/isFieldNullable.d.ts.map +1 -1
  121. package/dist/schema/operators.d.ts.map +1 -1
  122. package/dist/schema/recursivelyBuildNestedPaths.d.ts.map +1 -1
  123. package/dist/schema/withNullableType.d.ts.map +1 -1
  124. package/dist/schema/withNullableType.js +5 -1
  125. package/dist/schema/withNullableType.js.map +1 -1
  126. package/dist/schema/withOperators.d.ts +6 -0
  127. package/dist/schema/withOperators.d.ts.map +1 -1
  128. package/dist/schema/withOperators.js +15 -0
  129. package/dist/schema/withOperators.js.map +1 -1
  130. package/dist/utilities/combineParentName.d.ts.map +1 -1
  131. package/dist/utilities/formatName.d.ts.map +1 -1
  132. package/dist/utilities/formatOptions.d.ts.map +1 -1
  133. package/dist/utilities/formatUtcOffset.d.ts.map +1 -1
  134. package/dist/utilities/groupOrTabHasRequiredSubfield.d.ts.map +1 -1
  135. package/dist/utilities/groupOrTabHasRequiredSubfield.js +4 -1
  136. package/dist/utilities/groupOrTabHasRequiredSubfield.js.map +1 -1
  137. package/dist/utilities/select.d.ts +4 -3
  138. package/dist/utilities/select.d.ts.map +1 -1
  139. package/dist/utilities/select.js +83 -45
  140. package/dist/utilities/select.js.map +1 -1
  141. package/package.json +19 -22
  142. package/dist/utilities/formatName.spec.js +0 -57
  143. package/dist/utilities/formatName.spec.js.map +0 -1
  144. package/dist/utilities/formatUtcOffset.spec.js +0 -142
  145. package/dist/utilities/formatUtcOffset.spec.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/schema/buildMutationInputType.ts"],"sourcesContent":["import type { GraphQLInputFieldConfig, GraphQLScalarType, GraphQLType } from 'graphql'\nimport type {\n ArrayField,\n BlocksField,\n CheckboxField,\n CodeField,\n CollapsibleField,\n DateField,\n EmailField,\n Field,\n GraphQLInfo,\n GroupField,\n JSONField,\n NumberField,\n PointField,\n RadioField,\n RelationshipField,\n RichTextField,\n RowField,\n SanitizedCollectionConfig,\n SanitizedConfig,\n SelectField,\n TabsField,\n TextareaField,\n TextField,\n UploadField,\n} from 'payload'\n\nimport {\n GraphQLBoolean,\n GraphQLEnumType,\n GraphQLFloat,\n GraphQLInputObjectType,\n GraphQLInt,\n GraphQLList,\n GraphQLNonNull,\n GraphQLString,\n} from 'graphql'\nimport { flattenTopLevelFields, toWords } from 'payload'\nimport { fieldAffectsData, optionIsObject, tabHasName } from 'payload/shared'\n\nimport { GraphQLJSON } from '../packages/graphql-type-json/index.js'\nimport { combineParentName } from '../utilities/combineParentName.js'\nimport { formatName } from '../utilities/formatName.js'\nimport { groupOrTabHasRequiredSubfield } from '../utilities/groupOrTabHasRequiredSubfield.js'\nimport { withNullableType } from './withNullableType.js'\n\nconst idFieldTypes = {\n number: GraphQLInt,\n text: GraphQLString,\n}\n\nexport const getCollectionIDType = (\n type: keyof typeof idFieldTypes,\n collection: SanitizedCollectionConfig,\n): GraphQLScalarType => {\n const idField = flattenTopLevelFields(collection.fields).find(\n (field) => fieldAffectsData(field) && field.name === 'id',\n )\n\n if (!idField) {\n return idFieldTypes[type]\n }\n\n return idFieldTypes[idField.type]\n}\n\nexport type InputObjectTypeConfig = {\n [path: string]: GraphQLInputFieldConfig\n}\n\ntype BuildMutationInputTypeArgs = {\n config: SanitizedConfig\n fields: Field[]\n forceNullable?: boolean\n graphqlResult: GraphQLInfo\n name: string\n parentIsLocalized: boolean\n parentName: string\n}\n\nexport function buildMutationInputType({\n name,\n config,\n fields,\n forceNullable = false,\n graphqlResult,\n parentIsLocalized,\n parentName,\n}: BuildMutationInputTypeArgs): GraphQLInputObjectType | null {\n const fieldToSchemaMap = {\n array: (inputObjectTypeConfig: InputObjectTypeConfig, field: ArrayField) => {\n const fullName = combineParentName(parentName, toWords(field.name, true))\n let type: GraphQLList<GraphQLType> | GraphQLType = buildMutationInputType({\n name: fullName,\n config,\n fields: field.fields,\n graphqlResult,\n parentIsLocalized: parentIsLocalized || field.localized,\n parentName: fullName,\n })\n\n if (!type) {\n return inputObjectTypeConfig\n }\n\n type = new GraphQLList(withNullableType({ type, field, forceNullable, parentIsLocalized }))\n return {\n ...inputObjectTypeConfig,\n [formatName(field.name)]: { type },\n }\n },\n blocks: (inputObjectTypeConfig: InputObjectTypeConfig, field: BlocksField) => ({\n ...inputObjectTypeConfig,\n [formatName(field.name)]: { type: GraphQLJSON },\n }),\n checkbox: (inputObjectTypeConfig: InputObjectTypeConfig, field: CheckboxField) => ({\n ...inputObjectTypeConfig,\n [formatName(field.name)]: { type: GraphQLBoolean },\n }),\n code: (inputObjectTypeConfig: InputObjectTypeConfig, field: CodeField) => ({\n ...inputObjectTypeConfig,\n [formatName(field.name)]: {\n type: withNullableType({ type: GraphQLString, field, forceNullable, parentIsLocalized }),\n },\n }),\n collapsible: (inputObjectTypeConfig: InputObjectTypeConfig, field: CollapsibleField) =>\n field.fields.reduce((acc, subField: CollapsibleField) => {\n const addSubField = fieldToSchemaMap[subField.type]\n if (addSubField) {\n return addSubField(acc, subField)\n }\n return acc\n }, inputObjectTypeConfig),\n date: (inputObjectTypeConfig: InputObjectTypeConfig, field: DateField) => ({\n ...inputObjectTypeConfig,\n [formatName(field.name)]: {\n type: withNullableType({ type: GraphQLString, field, forceNullable, parentIsLocalized }),\n },\n }),\n email: (inputObjectTypeConfig: InputObjectTypeConfig, field: EmailField) => ({\n ...inputObjectTypeConfig,\n [formatName(field.name)]: {\n type: withNullableType({ type: GraphQLString, field, forceNullable, parentIsLocalized }),\n },\n }),\n group: (inputObjectTypeConfig: InputObjectTypeConfig, field: GroupField) => {\n if (fieldAffectsData(field)) {\n const requiresAtLeastOneField = groupOrTabHasRequiredSubfield(field)\n const fullName = combineParentName(parentName, toWords(field.name, true))\n let type: GraphQLType = buildMutationInputType({\n name: fullName,\n config,\n fields: field.fields,\n graphqlResult,\n parentIsLocalized: parentIsLocalized || field.localized,\n parentName: fullName,\n })\n\n if (!type) {\n return inputObjectTypeConfig\n }\n\n if (requiresAtLeastOneField) {\n type = new GraphQLNonNull(type)\n }\n return {\n ...inputObjectTypeConfig,\n [formatName(field.name)]: { type },\n }\n } else {\n return field.fields.reduce((acc, subField: CollapsibleField) => {\n const addSubField = fieldToSchemaMap[subField.type]\n if (addSubField) {\n return addSubField(acc, subField)\n }\n return acc\n }, inputObjectTypeConfig)\n }\n },\n json: (inputObjectTypeConfig: InputObjectTypeConfig, field: JSONField) => ({\n ...inputObjectTypeConfig,\n [formatName(field.name)]: {\n type: withNullableType({ type: GraphQLJSON, field, forceNullable, parentIsLocalized }),\n },\n }),\n number: (inputObjectTypeConfig: InputObjectTypeConfig, field: NumberField) => {\n const type = field.name === 'id' ? GraphQLInt : GraphQLFloat\n return {\n ...inputObjectTypeConfig,\n [formatName(field.name)]: {\n type: withNullableType({\n type: field.hasMany === true ? new GraphQLList(type) : type,\n field,\n forceNullable,\n parentIsLocalized,\n }),\n },\n }\n },\n point: (inputObjectTypeConfig: InputObjectTypeConfig, field: PointField) => ({\n ...inputObjectTypeConfig,\n [formatName(field.name)]: {\n type: withNullableType({\n type: new GraphQLList(GraphQLFloat),\n field,\n forceNullable,\n parentIsLocalized,\n }),\n },\n }),\n radio: (inputObjectTypeConfig: InputObjectTypeConfig, field: RadioField) => ({\n ...inputObjectTypeConfig,\n [formatName(field.name)]: {\n type: withNullableType({ type: GraphQLString, field, forceNullable, parentIsLocalized }),\n },\n }),\n relationship: (inputObjectTypeConfig: InputObjectTypeConfig, field: RelationshipField) => {\n const { relationTo } = field\n type PayloadGraphQLRelationshipType =\n | GraphQLInputObjectType\n | GraphQLList<GraphQLScalarType>\n | GraphQLScalarType\n let type: PayloadGraphQLRelationshipType\n\n if (Array.isArray(relationTo)) {\n const fullName = `${combineParentName(\n parentName,\n toWords(field.name, true),\n )}RelationshipInput`\n type = new GraphQLInputObjectType({\n name: fullName,\n fields: {\n relationTo: {\n type: new GraphQLEnumType({\n name: `${fullName}RelationTo`,\n values: relationTo.reduce(\n (values, option) => ({\n ...values,\n [formatName(option)]: {\n value: option,\n },\n }),\n {},\n ),\n }),\n },\n value: { type: GraphQLJSON },\n },\n })\n } else {\n type = getCollectionIDType(\n config.db.defaultIDType,\n graphqlResult.collections[relationTo].config,\n )\n }\n\n return {\n ...inputObjectTypeConfig,\n [formatName(field.name)]: { type: field.hasMany ? new GraphQLList(type) : type },\n }\n },\n richText: (inputObjectTypeConfig: InputObjectTypeConfig, field: RichTextField) => ({\n ...inputObjectTypeConfig,\n [formatName(field.name)]: {\n type: withNullableType({ type: GraphQLJSON, field, forceNullable, parentIsLocalized }),\n },\n }),\n row: (inputObjectTypeConfig: InputObjectTypeConfig, field: RowField) =>\n field.fields.reduce((acc, subField: Field) => {\n const addSubField = fieldToSchemaMap[subField.type]\n if (addSubField) {\n return addSubField(acc, subField)\n }\n return acc\n }, inputObjectTypeConfig),\n select: (inputObjectTypeConfig: InputObjectTypeConfig, field: SelectField) => {\n const formattedName = `${combineParentName(parentName, field.name)}_MutationInput`\n let type: GraphQLType = new GraphQLEnumType({\n name: formattedName,\n values: field.options.reduce((values, option) => {\n if (optionIsObject(option)) {\n return {\n ...values,\n [formatName(option.value)]: {\n value: option.value,\n },\n }\n }\n\n return {\n ...values,\n [formatName(option)]: {\n value: option,\n },\n }\n }, {}),\n })\n\n type = field.hasMany ? new GraphQLList(type) : type\n type = withNullableType({ type, field, forceNullable, parentIsLocalized })\n\n return {\n ...inputObjectTypeConfig,\n [formatName(field.name)]: { type },\n }\n },\n tabs: (inputObjectTypeConfig: InputObjectTypeConfig, field: TabsField) => {\n return field.tabs.reduce((acc, tab) => {\n if (tabHasName(tab)) {\n const fullName = combineParentName(parentName, toWords(tab.name, true))\n const requiresAtLeastOneField = groupOrTabHasRequiredSubfield(field)\n let type: GraphQLType = buildMutationInputType({\n name: fullName,\n config,\n fields: tab.fields,\n graphqlResult,\n parentIsLocalized: parentIsLocalized || tab.localized,\n parentName: fullName,\n })\n\n if (!type) {\n return acc\n }\n\n if (requiresAtLeastOneField) {\n type = new GraphQLNonNull(type)\n }\n return {\n ...acc,\n [tab.name]: { type },\n }\n }\n\n return {\n ...acc,\n ...tab.fields.reduce((subFieldSchema, subField) => {\n const addSubField = fieldToSchemaMap[subField.type]\n if (addSubField) {\n return addSubField(subFieldSchema, subField)\n }\n return subFieldSchema\n }, acc),\n }\n }, inputObjectTypeConfig)\n },\n text: (inputObjectTypeConfig: InputObjectTypeConfig, field: TextField) => ({\n ...inputObjectTypeConfig,\n [formatName(field.name)]: {\n type: withNullableType({\n type: field.hasMany === true ? new GraphQLList(GraphQLString) : GraphQLString,\n field,\n forceNullable,\n parentIsLocalized,\n }),\n },\n }),\n textarea: (inputObjectTypeConfig: InputObjectTypeConfig, field: TextareaField) => ({\n ...inputObjectTypeConfig,\n [formatName(field.name)]: {\n type: withNullableType({ type: GraphQLString, field, forceNullable, parentIsLocalized }),\n },\n }),\n upload: (inputObjectTypeConfig: InputObjectTypeConfig, field: UploadField) => {\n const { relationTo } = field\n type PayloadGraphQLRelationshipType =\n | GraphQLInputObjectType\n | GraphQLList<GraphQLScalarType>\n | GraphQLScalarType\n let type: PayloadGraphQLRelationshipType\n\n if (Array.isArray(relationTo)) {\n const fullName = `${combineParentName(\n parentName,\n toWords(field.name, true),\n )}RelationshipInput`\n type = new GraphQLInputObjectType({\n name: fullName,\n fields: {\n relationTo: {\n type: new GraphQLEnumType({\n name: `${fullName}RelationTo`,\n values: relationTo.reduce(\n (values, option) => ({\n ...values,\n [formatName(option)]: {\n value: option,\n },\n }),\n {},\n ),\n }),\n },\n value: { type: GraphQLJSON },\n },\n })\n } else {\n type = getCollectionIDType(\n config.db.defaultIDType,\n graphqlResult.collections[relationTo].config,\n )\n }\n\n return {\n ...inputObjectTypeConfig,\n [formatName(field.name)]: { type: field.hasMany ? new GraphQLList(type) : type },\n }\n },\n }\n\n const fieldName = formatName(name)\n\n const fieldSchemas = fields.reduce((inputObjectTypeConfig, field) => {\n const fieldSchema = fieldToSchemaMap[field.type]\n\n if (typeof fieldSchema !== 'function') {\n return inputObjectTypeConfig\n }\n\n const schema = fieldSchema(inputObjectTypeConfig, field)\n if (Object.keys(schema).length === 0) {\n return inputObjectTypeConfig\n }\n\n return {\n ...inputObjectTypeConfig,\n ...fieldSchema(inputObjectTypeConfig, field),\n }\n }, {})\n\n if (Object.keys(fieldSchemas).length === 0) {\n return null\n }\n\n return new GraphQLInputObjectType({\n name: `mutation${fieldName}Input`,\n fields: fieldSchemas,\n })\n}\n"],"names":["GraphQLBoolean","GraphQLEnumType","GraphQLFloat","GraphQLInputObjectType","GraphQLInt","GraphQLList","GraphQLNonNull","GraphQLString","flattenTopLevelFields","toWords","fieldAffectsData","optionIsObject","tabHasName","GraphQLJSON","combineParentName","formatName","groupOrTabHasRequiredSubfield","withNullableType","idFieldTypes","number","text","getCollectionIDType","type","collection","idField","fields","find","field","name","buildMutationInputType","config","forceNullable","graphqlResult","parentIsLocalized","parentName","fieldToSchemaMap","array","inputObjectTypeConfig","fullName","localized","blocks","checkbox","code","collapsible","reduce","acc","subField","addSubField","date","email","group","requiresAtLeastOneField","json","hasMany","point","radio","relationship","relationTo","Array","isArray","values","option","value","db","defaultIDType","collections","richText","row","select","formattedName","options","tabs","tab","subFieldSchema","textarea","upload","fieldName","fieldSchemas","fieldSchema","schema","Object","keys","length"],"mappings":"AA4BA,SACEA,cAAc,EACdC,eAAe,EACfC,YAAY,EACZC,sBAAsB,EACtBC,UAAU,EACVC,WAAW,EACXC,cAAc,EACdC,aAAa,QACR,UAAS;AAChB,SAASC,qBAAqB,EAAEC,OAAO,QAAQ,UAAS;AACxD,SAASC,gBAAgB,EAAEC,cAAc,EAAEC,UAAU,QAAQ,iBAAgB;AAE7E,SAASC,WAAW,QAAQ,yCAAwC;AACpE,SAASC,iBAAiB,QAAQ,oCAAmC;AACrE,SAASC,UAAU,QAAQ,6BAA4B;AACvD,SAASC,6BAA6B,QAAQ,gDAA+C;AAC7F,SAASC,gBAAgB,QAAQ,wBAAuB;AAExD,MAAMC,eAAe;IACnBC,QAAQf;IACRgB,MAAMb;AACR;AAEA,OAAO,MAAMc,sBAAsB,CACjCC,MACAC;IAEA,MAAMC,UAAUhB,sBAAsBe,WAAWE,MAAM,EAAEC,IAAI,CAC3D,CAACC,QAAUjB,iBAAiBiB,UAAUA,MAAMC,IAAI,KAAK;IAGvD,IAAI,CAACJ,SAAS;QACZ,OAAON,YAAY,CAACI,KAAK;IAC3B;IAEA,OAAOJ,YAAY,CAACM,QAAQF,IAAI,CAAC;AACnC,EAAC;AAgBD,OAAO,SAASO,uBAAuB,EACrCD,IAAI,EACJE,MAAM,EACNL,MAAM,EACNM,gBAAgB,KAAK,EACrBC,aAAa,EACbC,iBAAiB,EACjBC,UAAU,EACiB;IAC3B,MAAMC,mBAAmB;QACvBC,OAAO,CAACC,uBAA8CV;YACpD,MAAMW,WAAWxB,kBAAkBoB,YAAYzB,QAAQkB,MAAMC,IAAI,EAAE;YACnE,IAAIN,OAA+CO,uBAAuB;gBACxED,MAAMU;gBACNR;gBACAL,Q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AAMsD,YAAY7D,WAAWa;IAE7B,MAAMiD,eAAepD,OAAOmB,MAAM,CAAC,CAACP,uBAAuBV;QACzD,MAAMmD,cAAc3C,gBAAgB,CAACR,MAAML,IAAI,CAAC;QAEhD,IAAI,OAAOwD,gBAAgB,YAAY;YACrC,OAAOzC;QACT;QAEA,MAAM0C,SAASD,YAAYzC,uBAAuBV;QAClD,IAAIqD,OAAOC,IAAI,CAACF,QAAQG,MAAM,KAAK,GAAG;YACpC,OAAO7C;QACT;QAEA,OAAO;YACL,GAAGA,qBAAqB;YACxB,GAAGyC,YAAYzC,uBAAuBV,MAAM;QAC9C;IACF,GAAG,CAAC;IAEJ,IAAIqD,OAAOC,IAAI,CAACJ,cAAcK,MAAM,KAAK,GAAG;QAC1C,OAAO;IACT;IAEA,OAAO,IAAI/E,uBAAuB;QAChCyB,MAAM,CAAC,QAAQ,EAAEgD,UAAU,KAAK,CAAC;QACjCnD,QAAQoD;IACV;AACF"}
1
+ {"version":3,"sources":["../../src/schema/buildMutationInputType.ts"],"sourcesContent":["import type { GraphQLInputFieldConfig, GraphQLScalarType, GraphQLType } from 'graphql'\nimport type {\n ArrayField,\n BlocksField,\n CheckboxField,\n CodeField,\n CollapsibleField,\n DateField,\n EmailField,\n Field,\n GraphQLInfo,\n GroupField,\n JSONField,\n NumberField,\n PointField,\n RadioField,\n RelationshipField,\n RichTextField,\n RowField,\n SanitizedCollectionConfig,\n SanitizedConfig,\n SelectField,\n SlugField,\n TabsField,\n TextareaField,\n TextField,\n UploadField,\n} from 'payload'\n\nimport {\n GraphQLBoolean,\n GraphQLEnumType,\n GraphQLFloat,\n GraphQLInputObjectType,\n GraphQLInt,\n GraphQLList,\n GraphQLNonNull,\n GraphQLString,\n} from 'graphql'\nimport { flattenTopLevelFields, toWords } from 'payload'\nimport { fieldAffectsData, optionIsObject, tabHasName } from 'payload/shared'\n\nimport { GraphQLJSON } from '../packages/graphql-type-json/index.js'\nimport { combineParentName } from '../utilities/combineParentName.js'\nimport { formatName } from '../utilities/formatName.js'\nimport { groupOrTabHasRequiredSubfield } from '../utilities/groupOrTabHasRequiredSubfield.js'\nimport { withNullableType } from './withNullableType.js'\n\nfunction buildMutationInputFields({\n fields,\n fieldToSchemaMap,\n initialInputFields = {},\n}: {\n fields: Field[]\n fieldToSchemaMap: Partial<\n Record<Field['type'], (inputFields: InputObjectTypeConfig, field: Field) => object>\n >\n initialInputFields?: InputObjectTypeConfig\n}): InputObjectTypeConfig {\n return fields.reduce((inputFields, field) => {\n if ('hidden' in field && field.hidden) {\n return inputFields\n }\n\n const buildFieldSchema = fieldToSchemaMap[field.type]\n\n return typeof buildFieldSchema === 'function'\n ? { ...inputFields, ...buildFieldSchema(inputFields, field) }\n : inputFields\n }, initialInputFields)\n}\n\nconst idFieldTypes = {\n number: GraphQLInt,\n text: GraphQLString,\n}\n\nexport const getCollectionIDType = (\n type: keyof typeof idFieldTypes,\n collection: SanitizedCollectionConfig,\n): GraphQLScalarType => {\n const idField = flattenTopLevelFields(collection.fields).find(\n (field) => fieldAffectsData(field) && field.name === 'id',\n )\n\n if (!idField) {\n return idFieldTypes[type]\n }\n\n return idFieldTypes[idField.type]\n}\n\nexport type InputObjectTypeConfig = {\n [path: string]: GraphQLInputFieldConfig\n}\n\ntype BuildMutationInputTypeArgs = {\n config: SanitizedConfig\n fields: Field[]\n forceNullable?: boolean\n graphqlResult: GraphQLInfo\n name: string\n parentIsLocalized: boolean\n parentName: string\n}\n\nexport function buildMutationInputType({\n name,\n config,\n fields,\n forceNullable = false,\n graphqlResult,\n parentIsLocalized,\n parentName,\n}: BuildMutationInputTypeArgs): GraphQLInputObjectType | null {\n const fieldToSchemaMap = {\n slug: (inputObjectTypeConfig: InputObjectTypeConfig, field: SlugField) => ({\n ...inputObjectTypeConfig,\n [formatName(field.name)]: {\n type: withNullableType({ type: GraphQLString, field, forceNullable, parentIsLocalized }),\n },\n }),\n array: (inputObjectTypeConfig: InputObjectTypeConfig, field: ArrayField) => {\n const fullName = combineParentName(parentName, toWords(field.name, true))\n let type: GraphQLList<GraphQLType> | GraphQLType = buildMutationInputType({\n name: fullName,\n config,\n fields: field.fields,\n forceNullable,\n graphqlResult,\n parentIsLocalized: parentIsLocalized || field.localized,\n parentName: fullName,\n })\n\n if (!type) {\n return inputObjectTypeConfig\n }\n\n type = new GraphQLList(withNullableType({ type, field, forceNullable, parentIsLocalized }))\n return {\n ...inputObjectTypeConfig,\n [formatName(field.name)]: { type },\n }\n },\n blocks: (inputObjectTypeConfig: InputObjectTypeConfig, field: BlocksField) => ({\n ...inputObjectTypeConfig,\n [formatName(field.name)]: { type: GraphQLJSON },\n }),\n checkbox: (inputObjectTypeConfig: InputObjectTypeConfig, field: CheckboxField) => ({\n ...inputObjectTypeConfig,\n [formatName(field.name)]: { type: GraphQLBoolean },\n }),\n code: (inputObjectTypeConfig: InputObjectTypeConfig, field: CodeField) => ({\n ...inputObjectTypeConfig,\n [formatName(field.name)]: {\n type: withNullableType({ type: GraphQLString, field, forceNullable, parentIsLocalized }),\n },\n }),\n collapsible: (inputObjectTypeConfig: InputObjectTypeConfig, field: CollapsibleField) =>\n buildMutationInputFields({\n fields: field.fields,\n fieldToSchemaMap,\n initialInputFields: inputObjectTypeConfig,\n }),\n date: (inputObjectTypeConfig: InputObjectTypeConfig, field: DateField) => ({\n ...inputObjectTypeConfig,\n [formatName(field.name)]: {\n type: withNullableType({ type: GraphQLString, field, forceNullable, parentIsLocalized }),\n },\n }),\n email: (inputObjectTypeConfig: InputObjectTypeConfig, field: EmailField) => ({\n ...inputObjectTypeConfig,\n [formatName(field.name)]: {\n type: withNullableType({ type: GraphQLString, field, forceNullable, parentIsLocalized }),\n },\n }),\n group: (inputObjectTypeConfig: InputObjectTypeConfig, field: GroupField) => {\n if (fieldAffectsData(field)) {\n const requiresAtLeastOneField = groupOrTabHasRequiredSubfield(field)\n const fullName = combineParentName(parentName, toWords(field.name, true))\n let type: GraphQLType = buildMutationInputType({\n name: fullName,\n config,\n fields: field.fields,\n forceNullable,\n graphqlResult,\n parentIsLocalized: parentIsLocalized || field.localized,\n parentName: fullName,\n })\n\n if (!type) {\n return inputObjectTypeConfig\n }\n\n if (requiresAtLeastOneField && !forceNullable) {\n type = new GraphQLNonNull(type)\n }\n return {\n ...inputObjectTypeConfig,\n [formatName(field.name)]: { type },\n }\n } else {\n return buildMutationInputFields({\n fields: field.fields,\n fieldToSchemaMap,\n initialInputFields: inputObjectTypeConfig,\n })\n }\n },\n json: (inputObjectTypeConfig: InputObjectTypeConfig, field: JSONField) => ({\n ...inputObjectTypeConfig,\n [formatName(field.name)]: {\n type: withNullableType({ type: GraphQLJSON, field, forceNullable, parentIsLocalized }),\n },\n }),\n number: (inputObjectTypeConfig: InputObjectTypeConfig, field: NumberField) => {\n const type = field.name === 'id' ? GraphQLInt : GraphQLFloat\n return {\n ...inputObjectTypeConfig,\n [formatName(field.name)]: {\n type: withNullableType({\n type: field.hasMany === true ? new GraphQLList(type) : type,\n field,\n forceNullable,\n parentIsLocalized,\n }),\n },\n }\n },\n point: (inputObjectTypeConfig: InputObjectTypeConfig, field: PointField) => ({\n ...inputObjectTypeConfig,\n [formatName(field.name)]: {\n type: withNullableType({\n type: new GraphQLList(GraphQLFloat),\n field,\n forceNullable,\n parentIsLocalized,\n }),\n },\n }),\n radio: (inputObjectTypeConfig: InputObjectTypeConfig, field: RadioField) => ({\n ...inputObjectTypeConfig,\n [formatName(field.name)]: {\n type: withNullableType({ type: GraphQLString, field, forceNullable, parentIsLocalized }),\n },\n }),\n relationship: (inputObjectTypeConfig: InputObjectTypeConfig, field: RelationshipField) => {\n const { relationTo } = field\n type PayloadGraphQLRelationshipType =\n | GraphQLInputObjectType\n | GraphQLList<GraphQLScalarType>\n | GraphQLScalarType\n let type: PayloadGraphQLRelationshipType\n\n if (Array.isArray(relationTo)) {\n const fullName = `${combineParentName(\n parentName,\n toWords(field.name, true),\n )}RelationshipInput`\n type = new GraphQLInputObjectType({\n name: fullName,\n fields: {\n relationTo: {\n type: new GraphQLEnumType({\n name: `${fullName}RelationTo`,\n values: relationTo.reduce(\n (values, option) => ({\n ...values,\n [formatName(option)]: {\n value: option,\n },\n }),\n {},\n ),\n }),\n },\n value: { type: GraphQLJSON },\n },\n })\n } else {\n type = getCollectionIDType(\n config.db.defaultIDType,\n graphqlResult.collections[relationTo].config,\n )\n }\n\n return {\n ...inputObjectTypeConfig,\n [formatName(field.name)]: { type: field.hasMany ? new GraphQLList(type) : type },\n }\n },\n richText: (inputObjectTypeConfig: InputObjectTypeConfig, field: RichTextField) => ({\n ...inputObjectTypeConfig,\n [formatName(field.name)]: {\n type: withNullableType({ type: GraphQLJSON, field, forceNullable, parentIsLocalized }),\n },\n }),\n row: (inputObjectTypeConfig: InputObjectTypeConfig, field: RowField) =>\n buildMutationInputFields({\n fields: field.fields,\n fieldToSchemaMap,\n initialInputFields: inputObjectTypeConfig,\n }),\n select: (inputObjectTypeConfig: InputObjectTypeConfig, field: SelectField) => {\n const formattedName = `${combineParentName(parentName, field.name)}_MutationInput`\n let type: GraphQLType = new GraphQLEnumType({\n name: formattedName,\n values: field.options.reduce((values, option) => {\n if (optionIsObject(option)) {\n return {\n ...values,\n [formatName(option.value)]: {\n value: option.value,\n },\n }\n }\n\n return {\n ...values,\n [formatName(option)]: {\n value: option,\n },\n }\n }, {}),\n })\n\n type = field.hasMany ? new GraphQLList(type) : type\n type = withNullableType({ type, field, forceNullable, parentIsLocalized })\n\n return {\n ...inputObjectTypeConfig,\n [formatName(field.name)]: { type },\n }\n },\n tabs: (inputObjectTypeConfig: InputObjectTypeConfig, field: TabsField) => {\n return field.tabs.reduce((acc, tab) => {\n if (tabHasName(tab)) {\n const fullName = combineParentName(parentName, toWords(tab.name, true))\n const requiresAtLeastOneField = groupOrTabHasRequiredSubfield(field)\n let type: GraphQLType = buildMutationInputType({\n name: fullName,\n config,\n fields: tab.fields,\n forceNullable,\n graphqlResult,\n parentIsLocalized: parentIsLocalized || tab.localized,\n parentName: fullName,\n })\n\n if (!type) {\n return acc\n }\n\n if (requiresAtLeastOneField && !forceNullable) {\n type = new GraphQLNonNull(type)\n }\n return {\n ...acc,\n [tab.name]: { type },\n }\n }\n\n return buildMutationInputFields({\n fields: tab.fields,\n fieldToSchemaMap,\n initialInputFields: acc,\n })\n }, inputObjectTypeConfig)\n },\n text: (inputObjectTypeConfig: InputObjectTypeConfig, field: TextField) => ({\n ...inputObjectTypeConfig,\n [formatName(field.name)]: {\n type: withNullableType({\n type: field.hasMany === true ? new GraphQLList(GraphQLString) : GraphQLString,\n field,\n forceNullable,\n parentIsLocalized,\n }),\n },\n }),\n textarea: (inputObjectTypeConfig: InputObjectTypeConfig, field: TextareaField) => ({\n ...inputObjectTypeConfig,\n [formatName(field.name)]: {\n type: withNullableType({ type: GraphQLString, field, forceNullable, parentIsLocalized }),\n },\n }),\n upload: (inputObjectTypeConfig: InputObjectTypeConfig, field: UploadField) => {\n const { relationTo } = field\n type PayloadGraphQLRelationshipType =\n | GraphQLInputObjectType\n | GraphQLList<GraphQLScalarType>\n | GraphQLScalarType\n let type: PayloadGraphQLRelationshipType\n\n if (Array.isArray(relationTo)) {\n const fullName = `${combineParentName(\n parentName,\n toWords(field.name, true),\n )}RelationshipInput`\n type = new GraphQLInputObjectType({\n name: fullName,\n fields: {\n relationTo: {\n type: new GraphQLEnumType({\n name: `${fullName}RelationTo`,\n values: relationTo.reduce(\n (values, option) => ({\n ...values,\n [formatName(option)]: {\n value: option,\n },\n }),\n {},\n ),\n }),\n },\n value: { type: GraphQLJSON },\n },\n })\n } else {\n type = getCollectionIDType(\n config.db.defaultIDType,\n graphqlResult.collections[relationTo].config,\n )\n }\n\n return {\n ...inputObjectTypeConfig,\n [formatName(field.name)]: { type: field.hasMany ? new GraphQLList(type) : type },\n }\n },\n }\n\n const fieldName = formatName(name)\n const fieldSchemas = buildMutationInputFields({ fields, fieldToSchemaMap })\n\n if (Object.keys(fieldSchemas).length === 0) {\n return null\n }\n\n return new GraphQLInputObjectType({\n name: `mutation${fieldName}Input`,\n fields: fieldSchemas,\n })\n}\n"],"names":["GraphQLBoolean","GraphQLEnumType","GraphQLFloat","GraphQLInputObjectType","GraphQLInt","GraphQLList","GraphQLNonNull","GraphQLString","flattenTopLevelFields","toWords","fieldAffectsData","optionIsObject","tabHasName","GraphQLJSON","combineParentName","formatName","groupOrTabHasRequiredSubfield","withNullableType","buildMutationInputFields","fields","fieldToSchemaMap","initialInputFields","reduce","inputFields","field","hidden","buildFieldSchema","type","idFieldTypes","number","text","getCollectionIDType","collection","idField","find","name","buildMutationInputType","config","forceNullable","graphqlResult","parentIsLocalized","parentName","slug","inputObjectTypeConfig","array","fullName","localized","blocks","checkbox","code","collapsible","date","email","group","requiresAtLeastOneField","json","hasMany","point","radio","relationship","relationTo","Array","isArray","values","option","value","db","defaultIDType","collections","richText","row","select","formattedName","options","tabs","acc","tab","textarea","upload","fieldName","fieldSchemas","Object","keys","length"],"mappings":"AA6BA,SACEA,cAAc,EACdC,eAAe,EACfC,YAAY,EACZC,sBAAsB,EACtBC,UAAU,EACVC,WAAW,EACXC,cAAc,EACdC,aAAa,QACR,UAAS;AAChB,SAASC,qBAAqB,EAAEC,OAAO,QAAQ,UAAS;AACxD,SAASC,gBAAgB,EAAEC,cAAc,EAAEC,UAAU,QAAQ,iBAAgB;AAE7E,SAASC,WAAW,QAAQ,yCAAwC;AACpE,SAASC,iBAAiB,QAAQ,oCAAmC;AACrE,SAASC,UAAU,QAAQ,6BAA4B;AACvD,SAASC,6BAA6B,QAAQ,gDAA+C;AAC7F,SAASC,gBAAgB,QAAQ,wBAAuB;AAExD,SAASC,yBAAyB,EAChCC,MAAM,EACNC,gBAAgB,EAChBC,qBAAqB,CAAC,CAAC,EAOxB;IACC,OAAOF,OAAOG,MAAM,CAAC,CAACC,aAAaC;QACjC,IAAI,YAAYA,SAASA,MAAMC,MAAM,EAAE;YACrC,OAAOF;QACT;QAEA,MAAMG,mBAAmBN,gBAAgB,CAACI,MAAMG,IAAI,CAAC;QAErD,OAAO,OAAO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gB;gCACxBkC,MAAM,GAAGU,SAAS,UAAU,CAAC;gCAC7BkB,QAAQH,WAAWtC,MAAM,CACvB,CAACyC,QAAQC,SAAY,CAAA;wCACnB,GAAGD,MAAM;wCACT,CAAChD,WAAWiD,QAAQ,EAAE;4CACpBC,OAAOD;wCACT;oCACF,CAAA,GACA,CAAC;4BAEL;wBACF;wBACAC,OAAO;4BAAEtC,MAAMd;wBAAY;oBAC7B;gBACF;YACF,OAAO;gBACLc,OAAOI,oBACLM,OAAO6B,EAAE,CAACC,aAAa,EACvB5B,cAAc6B,WAAW,CAACR,WAAW,CAACvB,MAAM;YAEhD;YAEA,OAAO;gBACL,GAAGM,qBAAqB;gBACxB,CAAC5B,WAAWS,MAAMW,IAAI,EAAE,EAAE;oBAAER,MAAMH,MAAMgC,OAAO,GAAG,IAAInD,YAAYsB,QAAQA;gBAAK;YACjF;QACF;IACF;IAEA,MAAMoD,YAAYhE,WAAWoB;IAC7B,MAAM6C,eAAe9D,yBAAyB;QAAEC;QAAQC;IAAiB;IAEzE,IAAI6D,OAAOC,IAAI,CAACF,cAAcG,MAAM,KAAK,GAAG;QAC1C,OAAO;IACT;IAEA,OAAO,IAAIhF,uBAAuB;QAChCgC,MAAM,CAAC,QAAQ,EAAE4C,UAAU,KAAK,CAAC;QACjC5D,QAAQ6D;IACV;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"buildPaginatedListType.d.ts","sourceRoot":"","sources":["../../src/schema/buildPaginatedListType.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2D,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAEpG,eAAO,MAAM,sBAAsB,GAAI,SAAI,EAAE,YAAO,gCAkBhD,CAAA"}
1
+ {"version":3,"file":"buildPaginatedListType.d.ts","sourceRoot":"","sources":["../../src/schema/buildPaginatedListType.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2D,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAEpG,eAAO,MAAM,sBAAsB,0DAkB/B,CAAA"}
@@ -1,18 +1,19 @@
1
1
  import type { CollectionConfig, Field, GlobalConfig, SanitizedConfig } from 'payload';
2
2
  import { GraphQLObjectType } from 'graphql';
3
- type OperationType = 'create' | 'delete' | 'read' | 'readVersions' | 'unlock' | 'update';
3
+ type OperationType = 'create' | 'delete' | 'read' | 'readVersions' | 'unlock' | 'update' | 'validate';
4
4
  type AccessScopes = 'docAccess' | undefined;
5
+ type ObjectTypeFields = {
6
+ [key in 'fields' | OperationType]?: {
7
+ type: GraphQLObjectType;
8
+ };
9
+ };
5
10
  type BuildEntityPolicy = {
6
11
  entityFields: Field[];
7
12
  name: string;
8
13
  operations: OperationType[];
9
14
  scope: AccessScopes;
10
15
  };
11
- export declare const buildEntityPolicy: (args: BuildEntityPolicy) => {
12
- fields: {
13
- type: GraphQLObjectType<any, any>;
14
- };
15
- };
16
+ export declare const buildEntityPolicy: (args: BuildEntityPolicy) => ObjectTypeFields;
16
17
  type BuildPolicyType = {
17
18
  scope?: AccessScopes;
18
19
  typeSuffix?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"buildPoliciesType.d.ts","sourceRoot":"","sources":["../../src/schema/buildPoliciesType.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,KAAK,EACL,YAAY,EAEZ,eAAe,EAEhB,MAAM,SAAS,CAAA;AAEhB,OAAO,EAAkC,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAM3E,KAAK,aAAa,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM,GAAG,cAAc,GAAG,QAAQ,GAAG,QAAQ,CAAA;AAExF,KAAK,YAAY,GAAG,WAAW,GAAG,SAAS,CAAA;AA0F3C,KAAK,iBAAiB,GAAG;IACvB,YAAY,EAAE,KAAK,EAAE,CAAA;IACrB,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,EAAE,aAAa,EAAE,CAAA;IAC3B,KAAK,EAAE,YAAY,CAAA;CACpB,CAAA;AACD,eAAO,MAAM,iBAAiB,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YAAY,CAAA;IACpB,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB,GAAG,CACA;IACE,MAAM,EAAE,gBAAgB,CAAA;IACxB,IAAI,EAAE,YAAY,CAAA;CACnB,GACD;IACE,MAAM,EAAE,YAAY,CAAA;IACpB,IAAI,EAAE,QAAQ,CAAA;CACf,CACJ,CAAA;AACD,wBAAgB,eAAe,CAAC,IAAI,EAAE,eAAe,GAAG,iBAAiB,CAyDxE;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,eAAe,GAAG,iBAAiB,CAyC5E"}
@@ -11,7 +11,8 @@ const buildFields = (label, fieldsToBuild)=>fieldsToBuild.reduce((builtFields, f
11
11
  'create',
12
12
  'read',
13
13
  'update',
14
- 'delete'
14
+ 'delete',
15
+ 'validate'
15
16
  ].reduce((operations, operation)=>{
16
17
  const capitalizedOperation = operation.charAt(0).toUpperCase() + operation.slice(1);
17
18
  return {
@@ -28,11 +29,12 @@ const buildFields = (label, fieldsToBuild)=>fieldsToBuild.reduce((builtFields, f
28
29
  }
29
30
  };
30
31
  }, {});
31
- if (field.fields) {
32
+ const subFields = field.fields && buildFields(`${label}_${fieldName}`, field.fields);
33
+ if (subFields && Object.keys(subFields).length > 0) {
32
34
  objectTypeFields.fields = {
33
35
  type: new GraphQLObjectType({
34
36
  name: `${label}_${fieldName}_Fields`,
35
- fields: buildFields(`${label}_${fieldName}`, field.fields)
37
+ fields: subFields
36
38
  })
37
39
  };
38
40
  }
@@ -56,12 +58,13 @@ const buildFields = (label, fieldsToBuild)=>fieldsToBuild.reduce((builtFields, f
56
58
  if (field.type === 'tabs') {
57
59
  return field.tabs.reduce((fieldsWithTabFields, tab)=>{
58
60
  if ('name' in tab) {
59
- if (tab.fields.length) {
60
- const tabName = formatName(tab.name);
61
+ const tabName = formatName(tab.name);
62
+ const subFields = buildFields(`${label}_${tabName}`, tab.fields);
63
+ if (Object.keys(subFields).length > 0) {
61
64
  fieldsWithTabFields[tabName] = {
62
65
  type: new GraphQLObjectType({
63
66
  name: `${label}_${tabName}`,
64
- fields: buildFields(`${label}_${tabName}`, tab.fields)
67
+ fields: subFields
65
68
  })
66
69
  };
67
70
  }
@@ -81,14 +84,16 @@ const buildFields = (label, fieldsToBuild)=>fieldsToBuild.reduce((builtFields, f
81
84
  export const buildEntityPolicy = (args)=>{
82
85
  const { name, entityFields, operations, scope } = args;
83
86
  const fieldsTypeName = toWords(`${name}-${scope || ''}-Fields`, true);
84
- const fields = {
85
- fields: {
87
+ const policyFields = buildFields(fieldsTypeName, entityFields);
88
+ const fields = {};
89
+ if (Object.keys(policyFields).length > 0) {
90
+ fields.fields = {
86
91
  type: new GraphQLObjectType({
87
92
  name: fieldsTypeName,
88
- fields: buildFields(fieldsTypeName, entityFields)
93
+ fields: policyFields
89
94
  })
90
- }
91
- };
95
+ };
96
+ }
92
97
  operations.forEach((operation)=>{
93
98
  const operationTypeName = toWords(`${name}-${operation}-${scope || 'Access'}`, true);
94
99
  fields[operation] = {
@@ -119,7 +124,8 @@ export function buildPolicyType(args) {
119
124
  'create',
120
125
  'read',
121
126
  'update',
122
- 'delete'
127
+ 'delete',
128
+ 'validate'
123
129
  ];
124
130
  if (entity.auth && typeof entity.auth === 'object' && typeof entity.auth.maxLoginAttempts !== 'undefined' && entity.auth.maxLoginAttempts !== 0) {
125
131
  operations.push('unlock');
@@ -141,7 +147,8 @@ export function buildPolicyType(args) {
141
147
  // else create global type
142
148
  operations = [
143
149
  'read',
144
- 'update'
150
+ 'update',
151
+ 'validate'
145
152
  ];
146
153
  if (entity.versions) {
147
154
  operations.push('readVersions');
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/schema/buildPoliciesType.ts"],"sourcesContent":["import type {\n CollectionConfig,\n Field,\n GlobalConfig,\n SanitizedCollectionConfig,\n SanitizedConfig,\n SanitizedGlobalConfig,\n} from 'payload'\n\nimport { GraphQLBoolean, GraphQLNonNull, GraphQLObjectType } from 'graphql'\nimport { toWords } from 'payload'\n\nimport { GraphQLJSONObject } from '../packages/graphql-type-json/index.js'\nimport { formatName } from '../utilities/formatName.js'\n\ntype OperationType = 'create' | 'delete' | 'read' | 'readVersions' | 'unlock' | 'update'\n\ntype AccessScopes = 'docAccess' | undefined\n\ntype ObjectTypeFields = {\n [key in 'fields' | OperationType]?: { type: GraphQLObjectType }\n}\n\nconst buildFields = (label, fieldsToBuild) =>\n fieldsToBuild.reduce((builtFields, field) => {\n const includeField = !field.hidden && field.type !== 'ui'\n if (includeField) {\n if (field.name) {\n const fieldName = formatName(field.name)\n\n const objectTypeFields: ObjectTypeFields = ['create', 'read', 'update', 'delete'].reduce(\n (operations, operation) => {\n const capitalizedOperation = operation.charAt(0).toUpperCase() + operation.slice(1)\n\n return {\n ...operations,\n [operation]: {\n type: new GraphQLObjectType({\n name: `${label}_${fieldName}_${capitalizedOperation}`,\n fields: {\n permission: {\n type: new GraphQLNonNull(GraphQLBoolean),\n },\n },\n }),\n },\n }\n },\n {},\n )\n\n if (field.fields) {\n objectTypeFields.fields = {\n type: new GraphQLObjectType({\n name: `${label}_${fieldName}_Fields`,\n fields: buildFields(`${label}_${fieldName}`, field.fields),\n }),\n }\n }\n\n return {\n ...builtFields,\n [formatName(field.name)]: {\n type: new GraphQLObjectType({\n name: `${label}_${fieldName}`,\n fields: objectTypeFields,\n }),\n },\n }\n }\n\n if (!field.name && field.fields && field.fields.length) {\n const subFields = buildFields(label, field.fields)\n\n return {\n ...builtFields,\n ...subFields,\n }\n }\n\n if (field.type === 'tabs') {\n return field.tabs.reduce(\n (fieldsWithTabFields, tab) => {\n if ('name' in tab) {\n if (tab.fields.length) {\n const tabName = formatName(tab.name)\n fieldsWithTabFields[tabName] = {\n type: new GraphQLObjectType({\n name: `${label}_${tabName}`,\n fields: buildFields(`${label}_${tabName}`, tab.fields),\n }),\n }\n }\n return fieldsWithTabFields\n }\n return {\n ...fieldsWithTabFields,\n ...buildFields(label, tab.fields),\n }\n },\n { ...builtFields },\n )\n }\n }\n return builtFields\n }, {})\n\ntype BuildEntityPolicy = {\n entityFields: Field[]\n name: string\n operations: OperationType[]\n scope: AccessScopes\n}\nexport const buildEntityPolicy = (args: BuildEntityPolicy) => {\n const { name, entityFields, operations, scope } = args\n\n const fieldsTypeName = toWords(`${name}-${scope || ''}-Fields`, true)\n const fields = {\n fields: {\n type: new GraphQLObjectType({\n name: fieldsTypeName,\n fields: buildFields(fieldsTypeName, entityFields),\n }),\n },\n }\n\n operations.forEach((operation) => {\n const operationTypeName = toWords(`${name}-${operation}-${scope || 'Access'}`, true)\n\n fields[operation] = {\n type: new GraphQLObjectType({\n name: operationTypeName,\n fields: {\n permission: { type: new GraphQLNonNull(GraphQLBoolean) },\n where: { type: GraphQLJSONObject },\n },\n }),\n }\n })\n\n return fields\n}\n\ntype BuildPolicyType = {\n scope?: AccessScopes\n typeSuffix?: string\n} & (\n | {\n entity: CollectionConfig\n type: 'collection'\n }\n | {\n entity: GlobalConfig\n type: 'global'\n }\n)\nexport function buildPolicyType(args: BuildPolicyType): GraphQLObjectType {\n const { type, entity, scope, typeSuffix } = args\n const { slug, fields, graphQL, versions } = entity\n\n let operations = []\n\n if (graphQL === false) {\n return null\n }\n\n if (type === 'collection') {\n operations = ['create', 'read', 'update', 'delete']\n\n if (\n entity.auth &&\n typeof entity.auth === 'object' &&\n typeof entity.auth.maxLoginAttempts !== 'undefined' &&\n entity.auth.maxLoginAttempts !== 0\n ) {\n operations.push('unlock')\n }\n\n if (versions) {\n operations.push('readVersions')\n }\n\n const collectionTypeName = formatName(`${slug}${typeSuffix || ''}`)\n\n return new GraphQLObjectType({\n name: collectionTypeName,\n fields: buildEntityPolicy({\n name: slug,\n entityFields: fields,\n operations,\n scope,\n }),\n })\n }\n\n // else create global type\n operations = ['read', 'update']\n\n if (entity.versions) {\n operations.push('readVersions')\n }\n\n const globalTypeName = formatName(`${global?.graphQL?.name || slug}${typeSuffix || ''}`)\n\n return new GraphQLObjectType({\n name: globalTypeName,\n fields: buildEntityPolicy({\n name: entity.graphQL ? entity?.graphQL?.name || slug : slug,\n entityFields: entity.fields,\n operations,\n scope,\n }),\n })\n}\n\nexport function buildPoliciesType(config: SanitizedConfig): GraphQLObjectType {\n const fields = {\n canAccessAdmin: {\n type: new GraphQLNonNull(GraphQLBoolean),\n },\n }\n\n Object.values(config.collections).forEach((collection: SanitizedCollectionConfig) => {\n if (collection.graphQL === false) {\n return\n }\n const collectionPolicyType = buildPolicyType({\n type: 'collection',\n entity: collection,\n typeSuffix: 'Access',\n })\n\n fields[formatName(collection.slug)] = {\n type: collectionPolicyType,\n }\n })\n\n Object.values(config.globals).forEach((global: SanitizedGlobalConfig) => {\n if (global.graphQL === false) {\n return\n }\n const globalPolicyType = buildPolicyType({\n type: 'global',\n entity: global,\n typeSuffix: 'Access',\n })\n\n fields[formatName(global.slug)] = {\n type: globalPolicyType,\n }\n })\n\n return new GraphQLObjectType({\n name: 'Access',\n fields,\n })\n}\n"],"names":["GraphQLBoolean","GraphQLNonNull","GraphQLObjectType","toWords","GraphQLJSONObject","formatName","buildFields","label","fieldsToBuild","reduce","builtFields","field","includeField","hidden","type","name","fieldName","objectTypeFields","operations","operation","capitalizedOperation","charAt","toUpperCase","slice","fields","permission","length","subFields","tabs","fieldsWithTabFields","tab","tabName","buildEntityPolicy","args","entityFields","scope","fieldsTypeName","forEach","operationTypeName","where","buildPolicyType","entity","typeSuffix","slug","graphQL","versions","auth","maxLoginAttempts","push","collectionTypeName","globalTypeName","global","buildPoliciesType","config","canAccessAdmin","Object","values","collections","collection","collectionPolicyType","globals","globalPolicyType"],"mappings":"AASA,SAASA,cAAc,EAAEC,cAAc,EAAEC,iBAAiB,QAAQ,UAAS;AAC3E,SAASC,OAAO,QAAQ,UAAS;AAEjC,SAASC,iBAAiB,QAAQ,yCAAwC;AAC1E,SAASC,UAAU,QAAQ,6BAA4B;AAUvD,MAAMC,cAAc,CAACC,OAAOC,gBAC1BA,cAAcC,MAAM,CAAC,CAACC,aAAaC;QACjC,MAAMC,eAAe,CAACD,MAAME,MAAM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C3BN;YACAiB;QACF;IACF;AACF;AAEA,OAAO,SAASiB,kBAAkBC,MAAuB;IACvD,MAAM7B,SAAS;QACb8B,gBAAgB;YACdxC,MAAM,IAAIb,eAAeD;QAC3B;IACF;IAEAuD,OAAOC,MAAM,CAACH,OAAOI,WAAW,EAAEpB,OAAO,CAAC,CAACqB;QACzC,IAAIA,WAAWd,OAAO,KAAK,OAAO;YAChC;QACF;QACA,MAAMe,uBAAuBnB,gBAAgB;YAC3C1B,MAAM;YACN2B,QAAQiB;YACRhB,YAAY;QACd;QAEAlB,MAAM,CAACnB,WAAWqD,WAAWf,IAAI,EAAE,GAAG;YACpC7B,MAAM6C;QACR;IACF;IAEAJ,OAAOC,MAAM,CAACH,OAAOO,OAAO,EAAEvB,OAAO,CAAC,CAACc;QACrC,IAAIA,QAAOP,OAAO,KAAK,OAAO;YAC5B;QACF;QACA,MAAMiB,mBAAmBrB,gBAAgB;YACvC1B,MAAM;YACN2B,QAAQU;YACRT,YAAY;QACd;QAEAlB,MAAM,CAACnB,WAAW8C,QAAOR,IAAI,EAAE,GAAG;YAChC7B,MAAM+C;QACR;IACF;IAEA,OAAO,IAAI3D,kBAAkB;QAC3Ba,MAAM;QACNS;IACF;AACF"}
1
+ {"version":3,"sources":["../../src/schema/buildPoliciesType.ts"],"sourcesContent":["import type {\n CollectionConfig,\n Field,\n GlobalConfig,\n SanitizedCollectionConfig,\n SanitizedConfig,\n SanitizedGlobalConfig,\n} from 'payload'\n\nimport { GraphQLBoolean, GraphQLNonNull, GraphQLObjectType } from 'graphql'\nimport { toWords } from 'payload'\n\nimport { GraphQLJSONObject } from '../packages/graphql-type-json/index.js'\nimport { formatName } from '../utilities/formatName.js'\n\ntype OperationType =\n | 'create'\n | 'delete'\n | 'read'\n | 'readVersions'\n | 'unlock'\n | 'update'\n | 'validate'\n\ntype AccessScopes = 'docAccess' | undefined\n\ntype ObjectTypeFields = {\n [key in 'fields' | OperationType]?: { type: GraphQLObjectType }\n}\n\nconst buildFields = (label, fieldsToBuild) =>\n fieldsToBuild.reduce((builtFields, field) => {\n const includeField = !field.hidden && field.type !== 'ui'\n if (includeField) {\n if (field.name) {\n const fieldName = formatName(field.name)\n\n const objectTypeFields: ObjectTypeFields = [\n 'create',\n 'read',\n 'update',\n 'delete',\n 'validate',\n ].reduce((operations, operation) => {\n const capitalizedOperation = operation.charAt(0).toUpperCase() + operation.slice(1)\n\n return {\n ...operations,\n [operation]: {\n type: new GraphQLObjectType({\n name: `${label}_${fieldName}_${capitalizedOperation}`,\n fields: {\n permission: {\n type: new GraphQLNonNull(GraphQLBoolean),\n },\n },\n }),\n },\n }\n }, {})\n\n const subFields = field.fields && buildFields(`${label}_${fieldName}`, field.fields)\n\n if (subFields && Object.keys(subFields).length > 0) {\n objectTypeFields.fields = {\n type: new GraphQLObjectType({\n name: `${label}_${fieldName}_Fields`,\n fields: subFields,\n }),\n }\n }\n\n return {\n ...builtFields,\n [formatName(field.name)]: {\n type: new GraphQLObjectType({\n name: `${label}_${fieldName}`,\n fields: objectTypeFields,\n }),\n },\n }\n }\n\n if (!field.name && field.fields && field.fields.length) {\n const subFields = buildFields(label, field.fields)\n\n return {\n ...builtFields,\n ...subFields,\n }\n }\n\n if (field.type === 'tabs') {\n return field.tabs.reduce(\n (fieldsWithTabFields, tab) => {\n if ('name' in tab) {\n const tabName = formatName(tab.name)\n const subFields = buildFields(`${label}_${tabName}`, tab.fields)\n\n if (Object.keys(subFields).length > 0) {\n fieldsWithTabFields[tabName] = {\n type: new GraphQLObjectType({\n name: `${label}_${tabName}`,\n fields: subFields,\n }),\n }\n }\n return fieldsWithTabFields\n }\n return {\n ...fieldsWithTabFields,\n ...buildFields(label, tab.fields),\n }\n },\n { ...builtFields },\n )\n }\n }\n return builtFields\n }, {})\n\ntype BuildEntityPolicy = {\n entityFields: Field[]\n name: string\n operations: OperationType[]\n scope: AccessScopes\n}\nexport const buildEntityPolicy = (args: BuildEntityPolicy) => {\n const { name, entityFields, operations, scope } = args\n\n const fieldsTypeName = toWords(`${name}-${scope || ''}-Fields`, true)\n const policyFields = buildFields(fieldsTypeName, entityFields)\n const fields: ObjectTypeFields = {}\n\n if (Object.keys(policyFields).length > 0) {\n fields.fields = {\n type: new GraphQLObjectType({\n name: fieldsTypeName,\n fields: policyFields,\n }),\n }\n }\n\n operations.forEach((operation) => {\n const operationTypeName = toWords(`${name}-${operation}-${scope || 'Access'}`, true)\n\n fields[operation] = {\n type: new GraphQLObjectType({\n name: operationTypeName,\n fields: {\n permission: { type: new GraphQLNonNull(GraphQLBoolean) },\n where: { type: GraphQLJSONObject },\n },\n }),\n }\n })\n\n return fields\n}\n\ntype BuildPolicyType = {\n scope?: AccessScopes\n typeSuffix?: string\n} & (\n | {\n entity: CollectionConfig\n type: 'collection'\n }\n | {\n entity: GlobalConfig\n type: 'global'\n }\n)\nexport function buildPolicyType(args: BuildPolicyType): GraphQLObjectType {\n const { type, entity, scope, typeSuffix } = args\n const { slug, fields, graphQL, versions } = entity\n\n let operations = []\n\n if (graphQL === false) {\n return null\n }\n\n if (type === 'collection') {\n operations = ['create', 'read', 'update', 'delete', 'validate']\n\n if (\n entity.auth &&\n typeof entity.auth === 'object' &&\n typeof entity.auth.maxLoginAttempts !== 'undefined' &&\n entity.auth.maxLoginAttempts !== 0\n ) {\n operations.push('unlock')\n }\n\n if (versions) {\n operations.push('readVersions')\n }\n\n const collectionTypeName = formatName(`${slug}${typeSuffix || ''}`)\n\n return new GraphQLObjectType({\n name: collectionTypeName,\n fields: buildEntityPolicy({\n name: slug,\n entityFields: fields,\n operations,\n scope,\n }),\n })\n }\n\n // else create global type\n operations = ['read', 'update', 'validate']\n\n if (entity.versions) {\n operations.push('readVersions')\n }\n\n const globalTypeName = formatName(`${global?.graphQL?.name || slug}${typeSuffix || ''}`)\n\n return new GraphQLObjectType({\n name: globalTypeName,\n fields: buildEntityPolicy({\n name: entity.graphQL ? entity?.graphQL?.name || slug : slug,\n entityFields: entity.fields,\n operations,\n scope,\n }),\n })\n}\n\nexport function buildPoliciesType(config: SanitizedConfig): GraphQLObjectType {\n const fields = {\n canAccessAdmin: {\n type: new GraphQLNonNull(GraphQLBoolean),\n },\n }\n\n Object.values(config.collections).forEach((collection: SanitizedCollectionConfig) => {\n if (collection.graphQL === false) {\n return\n }\n const collectionPolicyType = buildPolicyType({\n type: 'collection',\n entity: collection,\n typeSuffix: 'Access',\n })\n\n fields[formatName(collection.slug)] = {\n type: collectionPolicyType,\n }\n })\n\n Object.values(config.globals).forEach((global: SanitizedGlobalConfig) => {\n if (global.graphQL === false) {\n return\n }\n const globalPolicyType = buildPolicyType({\n type: 'global',\n entity: global,\n typeSuffix: 'Access',\n })\n\n fields[formatName(global.slug)] = {\n type: globalPolicyType,\n }\n })\n\n return new GraphQLObjectType({\n name: 'Access',\n fields,\n })\n}\n"],"names":["GraphQLBoolean","GraphQLNonNull","GraphQLObjectType","toWords","GraphQLJSONObject","formatName","buildFields","label","fieldsToBuild","reduce","builtFields","field","includeField","hidden","type","name","fieldName","objectTypeFields","operations","operation","capitalizedOperation","charAt","toUpperCase","slice","fields","permission","subFields","Object","keys","length","tabs","fieldsWithTabFields","tab","tabName","buildEntityPolicy","args","entityFields","scope","fieldsTypeName","policyFields","forEach","operationTypeName","where","buildPolicyType","entity","typeSuffix","slug","graphQL","versions","auth","maxLoginAttempts","push","collectionTypeName","globalTypeName","global","buildPoliciesType","config","canAccessAdmin","values","collections","collection","collectionPolicyType","globals","globalPolicyType"],"mappings":"AASA,SAASA,cAAc,EAAEC,cAAc,EAAEC,iBAAiB,QAAQ,UAAS;AAC3E,SAASC,OAAO,QAAQ,UAAS;AAEjC,SAASC,iBAAiB,QAAQ,yCAAwC;AAC1E,SAASC,UAAU,QAAQ,6BAA4B;AAiBvD,MAAMC,cAAc,CAACC,OAAOC,gBAC1BA,cAAcC,MAAM,CAAC,CAACC,aAAaC;QACjC,MAAMC,eAAe,CAACD,MAAME,MAAM,IAAIF,MAAMG,IAAI,KAAK;QACrD,IAAIF,cAAc;Y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;IAEvF,OAAO,IAAI3C,kBAAkB;QAC3Ba,MAAMsC;QACN7B,QAAQU,kBAAkB;YACxBnB,MAAM6B,OAAOG,OAAO,GAAGH,QAAQG,SAAShC,QAAQ+B,OAAOA;YACvDV,cAAcQ,OAAOpB,MAAM;YAC3BN;YACAmB;QACF;IACF;AACF;AAEA,OAAO,SAASkB,kBAAkBC,MAAuB;IACvD,MAAMhC,SAAS;QACbiC,gBAAgB;YACd3C,MAAM,IAAIb,eAAeD;QAC3B;IACF;IAEA2B,OAAO+B,MAAM,CAACF,OAAOG,WAAW,EAAEnB,OAAO,CAAC,CAACoB;QACzC,IAAIA,WAAWb,OAAO,KAAK,OAAO;YAChC;QACF;QACA,MAAMc,uBAAuBlB,gBAAgB;YAC3C7B,MAAM;YACN8B,QAAQgB;YACRf,YAAY;QACd;QAEArB,MAAM,CAACnB,WAAWuD,WAAWd,IAAI,EAAE,GAAG;YACpChC,MAAM+C;QACR;IACF;IAEAlC,OAAO+B,MAAM,CAACF,OAAOM,OAAO,EAAEtB,OAAO,CAAC,CAACc;QACrC,IAAIA,QAAOP,OAAO,KAAK,OAAO;YAC5B;QACF;QACA,MAAMgB,mBAAmBpB,gBAAgB;YACvC7B,MAAM;YACN8B,QAAQU;YACRT,YAAY;QACd;QAEArB,MAAM,CAACnB,WAAWiD,QAAOR,IAAI,EAAE,GAAG;YAChChC,MAAMiD;QACR;IACF;IAEA,OAAO,IAAI7D,kBAAkB;QAC3Ba,MAAM;QACNS;IACF;AACF"}
@@ -0,0 +1,3 @@
1
+ import { GraphQLObjectType } from 'graphql';
2
+ export declare const buildValidationResultType: () => GraphQLObjectType;
3
+ //# sourceMappingURL=buildValidationResultType.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildValidationResultType.d.ts","sourceRoot":"","sources":["../../src/schema/buildValidationResultType.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,iBAAiB,EAElB,MAAM,SAAS,CAAA;AAWhB,eAAO,MAAM,yBAAyB,QAAO,iBAU5C,CAAA"}
@@ -0,0 +1,30 @@
1
+ import { GraphQLBoolean, GraphQLList, GraphQLNonNull, GraphQLObjectType, GraphQLString } from 'graphql';
2
+ const validationFieldErrorType = new GraphQLObjectType({
3
+ name: 'PayloadValidationFieldError',
4
+ fields: {
5
+ locale: {
6
+ type: GraphQLString
7
+ },
8
+ message: {
9
+ type: new GraphQLNonNull(GraphQLString)
10
+ },
11
+ path: {
12
+ type: new GraphQLNonNull(GraphQLString)
13
+ }
14
+ }
15
+ });
16
+ export const buildValidationResultType = ()=>{
17
+ return new GraphQLObjectType({
18
+ name: 'PayloadValidationResult',
19
+ fields: {
20
+ errors: {
21
+ type: new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(validationFieldErrorType)))
22
+ },
23
+ valid: {
24
+ type: new GraphQLNonNull(GraphQLBoolean)
25
+ }
26
+ }
27
+ });
28
+ };
29
+
30
+ //# sourceMappingURL=buildValidationResultType.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/schema/buildValidationResultType.ts"],"sourcesContent":["import {\n GraphQLBoolean,\n GraphQLList,\n GraphQLNonNull,\n GraphQLObjectType,\n GraphQLString,\n} from 'graphql'\n\nconst validationFieldErrorType = new GraphQLObjectType({\n name: 'PayloadValidationFieldError',\n fields: {\n locale: { type: GraphQLString },\n message: { type: new GraphQLNonNull(GraphQLString) },\n path: { type: new GraphQLNonNull(GraphQLString) },\n },\n})\n\nexport const buildValidationResultType = (): GraphQLObjectType => {\n return new GraphQLObjectType({\n name: 'PayloadValidationResult',\n fields: {\n errors: {\n type: new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(validationFieldErrorType))),\n },\n valid: { type: new GraphQLNonNull(GraphQLBoolean) },\n },\n })\n}\n"],"names":["GraphQLBoolean","GraphQLList","GraphQLNonNull","GraphQLObjectType","GraphQLString","validationFieldErrorType","name","fields","locale","type","message","path","buildValidationResultType","errors","valid"],"mappings":"AAAA,SACEA,cAAc,EACdC,WAAW,EACXC,cAAc,EACdC,iBAAiB,EACjBC,aAAa,QACR,UAAS;AAEhB,MAAMC,2BAA2B,IAAIF,kBAAkB;IACrDG,MAAM;IACNC,QAAQ;QACNC,QAAQ;YAAEC,MAAML;QAAc;QAC9BM,SAAS;YAAED,MAAM,IAAIP,eAAeE;QAAe;QACnDO,MAAM;YAAEF,MAAM,IAAIP,eAAeE;QAAe;IAClD;AACF;AAEA,OAAO,MAAMQ,4BAA4B;IACvC,OAAO,IAAIT,kBAAkB;QAC3BG,MAAM;QACNC,QAAQ;YACNM,QAAQ;gBACNJ,MAAM,IAAIP,eAAe,IAAID,YAAY,IAAIC,eAAeG;YAC9D;YACAS,OAAO;gBAAEL,MAAM,IAAIP,eAAeF;YAAgB;QACpD;IACF;AACF,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"buildWhereInputType.d.ts","sourceRoot":"","sources":["../../src/schema/buildWhereInputType.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAsB,MAAM,SAAS,CAAA;AAExD,OAAO,EAAE,sBAAsB,EAAe,MAAM,SAAS,CAAA;AAQ7D,KAAK,IAAI,GAAG;IACV,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,mBAAmB,GAAI,8BAA8B,IAAI,KAAG,sBAgFxE,CAAA"}
1
+ {"version":3,"file":"buildWhereInputType.d.ts","sourceRoot":"","sources":["../../src/schema/buildWhereInputType.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAsB,MAAM,SAAS,CAAA;AAExD,OAAO,EAAE,sBAAsB,EAAe,MAAM,SAAS,CAAA;AAQ7D,KAAK,IAAI,GAAG;IACV,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,mBAAmB,iCAAkC,IAAI,KAAG,sBAgFxE,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/schema/buildWhereInputType.ts"],"sourcesContent":["import type { Field, FieldAffectingData } from 'payload'\n\nimport { GraphQLInputObjectType, GraphQLList } from 'graphql'\nimport { flattenTopLevelFields } from 'payload'\nimport { fieldAffectsData, fieldHasSubFields, fieldIsPresentationalOnly } from 'payload/shared'\n\nimport { formatName } from '../utilities/formatName.js'\nimport { fieldToSchemaMap } from './fieldToWhereInputSchemaMap.js'\nimport { withOperators } from './withOperators.js'\n\ntype Args = {\n fields: Field[]\n name: string\n parentName: string\n}\n\n/** This does as the function name suggests. It builds a where GraphQL input type\n * for all the fields which are passed to the function.\n * Each field has different operators which may be valid for a where input type.\n * For example, a text field may have a \"contains\" operator, but a number field\n * may not.\n *\n * buildWhereInputType is similar to buildObjectType and operates\n * on a field basis with a few distinct differences.\n *\n * 1. Everything needs to be a GraphQLInputObjectType or scalar / enum\n * 2. Relationships, groups, repeaters and flex content are not\n * directly searchable. Instead, we need to build a chained pathname\n * using dot notation so MongoDB can properly search nested paths.\n */\nexport const buildWhereInputType = ({ name, fields, parentName }: Args): GraphQLInputObjectType => {\n // This is the function that builds nested paths for all\n // field types with nested paths.\n\n const idField = flattenTopLevelFields(fields).find(\n (field) => fieldAffectsData(field) && field.name === 'id',\n )\n\n const fieldTypes = fields.reduce((schema, field) => {\n if (!fieldIsPresentationalOnly(field) && !field.hidden) {\n const getFieldSchema = fieldToSchemaMap({\n parentName,\n })[field.type]\n\n if (getFieldSchema) {\n const fieldSchema = getFieldSchema(field)\n\n if (fieldHasSubFields(field) || field.type === 'tabs') {\n return {\n ...schema,\n ...fieldSchema.reduce(\n (subFields, subField) => ({\n ...subFields,\n [formatName(subField.key)]: subField.type,\n }),\n {},\n ),\n }\n }\n\n return {\n ...schema,\n [formatName(field.name)]: fieldSchema,\n }\n }\n }\n\n return schema\n }, {})\n\n if (!idField) {\n fieldTypes.id = {\n type: withOperators({ name: 'id', type: 'text' } as FieldAffectingData, parentName),\n }\n }\n\n const fieldName = formatName(name)\n\n const recursiveFields = {\n AND: {\n type: new GraphQLList(\n new GraphQLInputObjectType({\n name: `${fieldName}_where_and`,\n fields: () => ({\n ...fieldTypes,\n ...recursiveFields,\n }),\n }),\n ),\n },\n OR: {\n type: new GraphQLList(\n new GraphQLInputObjectType({\n name: `${fieldName}_where_or`,\n fields: () => ({\n ...fieldTypes,\n ...recursiveFields,\n }),\n }),\n ),\n },\n }\n\n return new GraphQLInputObjectType({\n name: `${fieldName}_where`,\n fields: {\n ...fieldTypes,\n ...recursiveFields,\n },\n })\n}\n"],"names":["GraphQLInputObjectType","GraphQLList","flattenTopLevelFields","fieldAffectsData","fieldHasSubFields","fieldIsPresentationalOnly","formatName","fieldToSchemaMap","withOperators","buildWhereInputType","name","fields","parentName","idField","find","field","fieldTypes","reduce","schema","hidden","getFieldSchema","type","fieldSchema","subFields","subField","key","id","fieldName","recursiveFields","AND","OR"],"mappings":"AAEA,SAASA,sBAAsB,EAAEC,WAAW,QAAQ,UAAS;AAC7D,SAASC,qBAAqB,QAAQ,UAAS;AAC/C,SAASC,gBAAgB,EAAEC,iBAAiB,EAAEC,yBAAyB,QAAQ,iBAAgB;AAE/F,SAASC,UAAU,QAAQ,6BAA4B;AACvD,SAASC,gBAAgB,QAAQ,kCAAiC;AAClE,SAASC,aAAa,QAAQ,qBAAoB;AAQlD;;;;;;;;;;;;;CAaC,GACD,OAAO,MAAMC,sBAAsB,CAAC,EAAEC,IAAI,EAAEC,MAAM,EAAEC,UAAU,EAAQ;IACpE,wDAAwD;IACxD,iCAAiC;IAEjC,MAAMC,UAAUX,sBAAsBS,QAAQG,IAAI,CAChD,CAACC,QAAUZ,iBAAiBY,UAAUA,MAAML,IAAI,KAAK;IAGvD,MAAMM,aAAaL,OAAOM,MAAM,CAAC,CAACC,QAAQH;QACxC,IAAI,CA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GAAGY,eAAe;QACpB;IACF;AACF,EAAC"}
1
+ {"version":3,"sources":["../../src/schema/buildWhereInputType.ts"],"sourcesContent":["import type { Field, FieldAffectingData } from 'payload'\n\nimport { GraphQLInputObjectType, GraphQLList } from 'graphql'\nimport { flattenTopLevelFields } from 'payload'\nimport { fieldAffectsData, fieldHasSubFields, fieldIsPresentationalOnly } from 'payload/shared'\n\nimport { formatName } from '../utilities/formatName.js'\nimport { fieldToSchemaMap } from './fieldToWhereInputSchemaMap.js'\nimport { withOperators } from './withOperators.js'\n\ntype Args = {\n fields: Field[]\n name: string\n parentName: string\n}\n\n/** This does as the function name suggests. It builds a where GraphQL input type\n * for all the fields which are passed to the function.\n * Each field has different operators which may be valid for a where input type.\n * For example, a text field may have a \"contains\" operator, but a number field\n * may not.\n *\n * buildWhereInputType is similar to buildObjectType and operates\n * on a field basis with a few distinct differences.\n *\n * 1. Everything needs to be a GraphQLInputObjectType or scalar / enum\n * 2. Relationships, groups, repeaters and flex content are not\n * directly searchable. Instead, we need to build a chained pathname\n * using dot notation so MongoDB can properly search nested paths.\n */\nexport const buildWhereInputType = ({ name, fields, parentName }: Args): GraphQLInputObjectType => {\n // This is the function that builds nested paths for all\n // field types with nested paths.\n\n const idField = flattenTopLevelFields(fields).find(\n (field) => fieldAffectsData(field) && field.name === 'id',\n )\n\n const fieldTypes = fields.reduce((schema, field) => {\n if (!fieldIsPresentationalOnly(field) && !field.hidden) {\n const getFieldSchema = fieldToSchemaMap({\n parentName,\n })[field.type]\n\n if (getFieldSchema) {\n const fieldSchema = getFieldSchema(field)\n\n if (fieldHasSubFields(field) || field.type === 'tabs') {\n return {\n ...schema,\n ...fieldSchema.reduce(\n (subFields, subField) => ({\n ...subFields,\n [formatName(subField.key)]: subField.type,\n }),\n {},\n ),\n }\n }\n\n return {\n ...schema,\n [formatName(field.name)]: fieldSchema,\n }\n }\n }\n\n return schema\n }, {})\n\n if (!idField) {\n fieldTypes.id = {\n type: withOperators({ name: 'id', type: 'text' }, parentName),\n }\n }\n\n const fieldName = formatName(name)\n\n const recursiveFields = {\n AND: {\n type: new GraphQLList(\n new GraphQLInputObjectType({\n name: `${fieldName}_where_and`,\n fields: () => ({\n ...fieldTypes,\n ...recursiveFields,\n }),\n }),\n ),\n },\n OR: {\n type: new GraphQLList(\n new GraphQLInputObjectType({\n name: `${fieldName}_where_or`,\n fields: () => ({\n ...fieldTypes,\n ...recursiveFields,\n }),\n }),\n ),\n },\n }\n\n return new GraphQLInputObjectType({\n name: `${fieldName}_where`,\n fields: {\n ...fieldTypes,\n ...recursiveFields,\n },\n })\n}\n"],"names":["GraphQLInputObjectType","GraphQLList","flattenTopLevelFields","fieldAffectsData","fieldHasSubFields","fieldIsPresentationalOnly","formatName","fieldToSchemaMap","withOperators","buildWhereInputType","name","fields","parentName","idField","find","field","fieldTypes","reduce","schema","hidden","getFieldSchema","type","fieldSchema","subFields","subField","key","id","fieldName","recursiveFields","AND","OR"],"mappings":"AAEA,SAASA,sBAAsB,EAAEC,WAAW,QAAQ,UAAS;AAC7D,SAASC,qBAAqB,QAAQ,UAAS;AAC/C,SAASC,gBAAgB,EAAEC,iBAAiB,EAAEC,yBAAyB,QAAQ,iBAAgB;AAE/F,SAASC,UAAU,QAAQ,6BAA4B;AACvD,SAASC,gBAAgB,QAAQ,kCAAiC;AAClE,SAASC,aAAa,QAAQ,qBAAoB;AAQlD;;;;;;;;;;;;;CAaC,GACD,OAAO,MAAMC,sBAAsB,CAAC,EAAEC,IAAI,EAAEC,MAAM,EAAEC,UAAU,EAAQ;IACpE,wDAAwD;IACxD,iCAAiC;IAEjC,MAAMC,UAAUX,sBAAsBS,QAAQG,IAAI,CAChD,CAACC,QAAUZ,iBAAiBY,UAAUA,MAAML,IAAI,KAAK;IAGvD,MAAMM,aAAaL,OAAOM,MAAM,CAAC,CAACC,QAAQH;QACxC,IAAI,CAACV,0BAA0BU,UAAU,CAACA,MAAMI,MAAM,EAAE;YACtD,MAAMC,iBAAiBb,iBAAiB;gBACt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xField, CodeField, CollapsibleField, DateField, EmailField, GraphQLInfo, GroupField, JoinField, JSONField, NumberField, PointField, RadioField, RelationshipField, RichTextField, RowField, SanitizedConfig, SelectField, TabsField, TextareaField, TextField, UploadField } from 'payload';
1
+ import type { ArrayField, BlocksField, CheckboxField, CodeField, CollapsibleField, DateField, EmailField, GraphQLInfo, GroupField, JoinField, JSONField, NumberField, PointField, RadioField, RelationshipField, RichTextField, RowField, SanitizedConfig, SelectField, SlugField, TabsField, TextareaField, TextField, UploadField } from 'payload';
2
2
  import { GraphQLObjectType } from 'graphql';
3
3
  import { type ObjectTypeConfig } from './buildObjectType.js';
4
4
  type SharedArgs = {
@@ -63,6 +63,9 @@ type FieldToSchemaMap = {
63
63
  select: (args: {
64
64
  field: SelectField;
65
65
  } & SharedArgs) => ObjectTypeConfig;
66
+ slug: (args: {
67
+ field: SlugField;
68
+ } & SharedArgs) => ObjectTypeConfig;
66
69
  tabs: (args: {
67
70
  field: TabsField;
68
71
  } & SharedArgs) => ObjectTypeConfig;
@@ -1 +1 @@
1
- {"version":3,"file":"fieldToSchemaMap.d.ts","sourceRoot":"","sources":["../../src/schema/fieldToSchemaMap.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,UAAU,EACV,WAAW,EACX,aAAa,EACb,SAAS,EACT,gBAAgB,EAChB,SAAS,EACT,UAAU,EAGV,WAAW,EACX,UAAU,EACV,SAAS,EACT,SAAS,EACT,WAAW,EACX,UAAU,EACV,UAAU,EACV,iBAAiB,EAEjB,aAAa,EACb,QAAQ,EACR,eAAe,EACf,WAAW,EACX,SAAS,EACT,aAAa,EACb,SAAS,EACT,WAAW,EACZ,MAAM,SAAS,CAAA;AAEhB,OAAO,EAOL,iBAAiB,EAGlB,MAAM,SAAS,CAAA;AAYhB,OAAO,EAAmB,KAAK,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAwB7E,KAAK,UAAU,GAAG;IAChB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,MAAM,EAA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AAE,GAAG,UAAU,KAAK,gBAAgB,CAAA;IAC3E,GAAG,EAAE,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,QAAQ,CAAA;KAAE,GAAG,UAAU,KAAK,gBAAgB,CAAA;IACjE,MAAM,EAAE,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,WAAW,CAAA;KAAE,GAAG,UAAU,KAAK,gBAAgB,CAAA;IACvE,IAAI,EAAE,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,SAAS,CAAA;KAAE,GAAG,UAAU,KAAK,gBAAgB,CAAA;IACnE,IAAI,EAAE,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,SAAS,CAAA;KAAE,GAAG,UAAU,KAAK,gBAAgB,CAAA;IACnE,IAAI,EAAE,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,SAAS,CAAA;KAAE,GAAG,UAAU,KAAK,gBAAgB,CAAA;IACnE,QAAQ,EAAE,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,aAAa,CAAA;KAAE,GAAG,UAAU,KAAK,gBAAgB,CAAA;IAC3E,MAAM,EAAE,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,WAAW,CAAA;KAAE,GAAG,UAAU,KAAK,gBAAgB,CAAA;CACxE,CAAA;AAED,eAAO,MAAM,gBAAgB,EAAE,gBAklC9B,CAAA"}
@@ -1,8 +1,9 @@
1
1
  import { GraphQLBoolean, GraphQLEnumType, GraphQLFloat, GraphQLInt, GraphQLList, GraphQLNonNull, GraphQLObjectType, GraphQLString, GraphQLUnionType } from 'graphql';
2
2
  import { DateTimeResolver, EmailAddressResolver } from 'graphql-scalars';
3
- import { combineQueries, createDataloaderCacheKey, MissingEditorProp, toWords } from 'payload';
3
+ import { combineQueries, createDataloaderCacheKey, MissingEditorProp, resolveBranch, toWords } from 'payload';
4
4
  import { fieldAffectsData, tabHasName } from 'payload/shared';
5
5
  import { GraphQLJSON } from '../packages/graphql-type-json/index.js';
6
+ import { getGraphQLRequestForNestedField } from '../resolvers/getGraphQLRequest.js';
6
7
  import { combineParentName } from '../utilities/combineParentName.js';
7
8
  import { formatName } from '../utilities/formatName.js';
8
9
  import { formatOptions } from '../utilities/formatOptions.js';
@@ -26,6 +27,18 @@ function formattedNameResolver({ field, ...rest }) {
26
27
  return rest;
27
28
  }
28
29
  export const fieldToSchemaMap = {
30
+ slug: ({ field, forceNullable, objectTypeConfig, parentIsLocalized })=>({
31
+ ...objectTypeConfig,
32
+ [formatName(field.name)]: formattedNameResolver({
33
+ type: withNullableType({
34
+ type: GraphQLString,
35
+ field,
36
+ forceNullable,
37
+ parentIsLocalized
38
+ }),
39
+ field
40
+ })
41
+ }),
29
42
  array: ({ config, field, forceNullable, graphqlResult, objectTypeConfig, parentIsLocalized, parentName })=>{
30
43
  const interfaceName = field?.interfaceName || combineParentName(parentName, toWords(field.name, true));
31
44
  if (!graphqlResult.types.arrayTypes[interfaceName]) {
@@ -63,7 +76,7 @@ export const fieldToSchemaMap = {
63
76
  };
64
77
  },
65
78
  blocks: ({ config, field, forceNullable, graphqlResult, objectTypeConfig, parentIsLocalized, parentName })=>{
66
- const blockTypes = (field.blockReferences ?? field.blocks).reduce((acc, _block)=>{
79
+ const blockTypes = field.blocks.reduce((acc, _block)=>{
67
80
  const blockSlug = typeof _block === 'string' ? _block : _block.slug;
68
81
  if (!graphqlResult.types.blockTypes[blockSlug]) {
69
82
  // TODO: iterate over blocks mapped to block slug in v4, or pass through payload.blocks
@@ -284,9 +297,12 @@ export const fieldToSchemaMap = {
284
297
  async resolve (parent, args, context, info) {
285
298
  const { collection } = field;
286
299
  const { count = false, limit, page, sort, where } = args;
287
- const { req } = context;
288
- const draft = Boolean(args.draft ?? context.req.query?.draft);
289
- const select = resolveSelect(info, context.select);
300
+ const req = getGraphQLRequestForNestedField({
301
+ context,
302
+ info
303
+ });
304
+ const draft = Boolean(args.draft ?? req.query?.draft);
305
+ const select = resolveSelect(info, context.select, context);
290
306
  const targetField = field.targetField;
291
307
  const fullWhere = combineQueries(where, Array.isArray(targetField.relationTo) ? {
292
308
  [field.on]: {
@@ -476,12 +492,16 @@ export const fieldToSchemaMap = {
476
492
  field
477
493
  },
478
494
  async resolve (parent, args, context, info) {
495
+ const req = getGraphQLRequestForNestedField({
496
+ context,
497
+ info
498
+ });
479
499
  const value = parent[field.name];
480
- const locale = args.locale || context.req.locale;
481
- const fallbackLocale = args.fallbackLocale || context.req.fallbackLocale;
500
+ const locale = args.locale || req.locale;
501
+ const fallbackLocale = args.fallbackLocale || req.fallbackLocale;
482
502
  let relatedCollectionSlug = field.relationTo;
483
- const draft = Boolean(args.draft ?? context.req.query?.draft);
484
- const select = resolveSelect(info, context.select);
503
+ const draft = Boolean(args.draft ?? req.query?.draft);
504
+ const select = resolveSelect(info, context.select, context);
485
505
  if (hasManyValues) {
486
506
  const results = [];
487
507
  const resultPromises = [];
@@ -494,7 +514,8 @@ export const fieldToSchemaMap = {
494
514
  collectionSlug = relatedDoc.relationTo;
495
515
  id = relatedDoc.value;
496
516
  }
497
- const result = await context.req.payloadDataLoader.load(createDataloaderCacheKey({
517
+ const result = await req.payloadDataLoader.load(createDataloaderCacheKey({
518
+ branch: resolveBranch(req),
498
519
  collectionSlug: collectionSlug,
499
520
  currentDepth: 0,
500
521
  depth: 0,
@@ -505,7 +526,7 @@ export const fieldToSchemaMap = {
505
526
  overrideAccess: false,
506
527
  select,
507
528
  showHiddenFields: false,
508
- transactionID: context.req.transactionID
529
+ transactionID: req.transactionID
509
530
  }));
510
531
  if (result) {
511
532
  if (isRelatedToManyCollections) {
@@ -537,7 +558,8 @@ export const fieldToSchemaMap = {
537
558
  }
538
559
  if (id) {
539
560
  if (graphQLCollections.some((collection)=>collection.slug === relatedCollectionSlug)) {
540
- const relatedDocument = await context.req.payloadDataLoader.load(createDataloaderCacheKey({
561
+ const relatedDocument = await req.payloadDataLoader.load(createDataloaderCacheKey({
562
+ branch: resolveBranch(req),
541
563
  collectionSlug: relatedCollectionSlug,
542
564
  currentDepth: 0,
543
565
  depth: 0,
@@ -548,7 +570,7 @@ export const fieldToSchemaMap = {
548
570
  overrideAccess: false,
549
571
  select,
550
572
  showHiddenFields: false,
551
- transactionID: context.req.transactionID
573
+ transactionID: req.transactionID
552
574
  }));
553
575
  if (relatedDocument) {
554
576
  if (isRelatedToManyCollections) {
@@ -590,7 +612,11 @@ export const fieldToSchemaMap = {
590
612
  extensions: {
591
613
  field
592
614
  },
593
- async resolve (parent, args, context) {
615
+ async resolve (parent, args, context, info) {
616
+ const req = getGraphQLRequestForNestedField({
617
+ context,
618
+ info
619
+ });
594
620
  let depth = config.defaultDepth;
595
621
  if (typeof args.depth !== 'undefined') {
596
622
  depth = args.depth;
@@ -613,7 +639,10 @@ export const fieldToSchemaMap = {
613
639
  const populationPromises = [];
614
640
  const populateDepth = field?.maxDepth !== undefined && field?.maxDepth < depth ? field?.maxDepth : depth;
615
641
  editor?.graphQLPopulationPromises({
616
- context,
642
+ context: {
643
+ ...context,
644
+ req
645
+ },
617
646
  depth: populateDepth,
618
647
  draft: args.draft,
619
648
  field,
@@ -623,7 +652,7 @@ export const fieldToSchemaMap = {
623
652
  overrideAccess: false,
624
653
  parentIsLocalized,
625
654
  populationPromises,
626
- req: context.req,
655
+ req,
627
656
  showHiddenFields: false,
628
657
  siblingDoc: parent
629
658
  });
@@ -821,12 +850,16 @@ export const fieldToSchemaMap = {
821
850
  field
822
851
  },
823
852
  async resolve (parent, args, context, info) {
853
+ const req = getGraphQLRequestForNestedField({
854
+ context,
855
+ info
856
+ });
824
857
  const value = parent[field.name];
825
- const locale = args.locale || context.req.locale;
826
- const fallbackLocale = args.fallbackLocale || context.req.fallbackLocale;
858
+ const locale = args.locale || req.locale;
859
+ const fallbackLocale = args.fallbackLocale || req.fallbackLocale;
827
860
  let relatedCollectionSlug = field.relationTo;
828
- const draft = Boolean(args.draft ?? context.req.query?.draft);
829
- const select = resolveSelect(info, context.select);
861
+ const draft = Boolean(args.draft ?? req.query?.draft);
862
+ const select = resolveSelect(info, context.select, context);
830
863
  if (hasManyValues) {
831
864
  const results = [];
832
865
  const resultPromises = [];
@@ -839,7 +872,8 @@ export const fieldToSchemaMap = {
839
872
  collectionSlug = relatedDoc.relationTo;
840
873
  id = relatedDoc.value;
841
874
  }
842
- const result = await context.req.payloadDataLoader.load(createDataloaderCacheKey({
875
+ const result = await req.payloadDataLoader.load(createDataloaderCacheKey({
876
+ branch: resolveBranch(req),
843
877
  collectionSlug: collectionSlug,
844
878
  currentDepth: 0,
845
879
  depth: 0,
@@ -850,7 +884,7 @@ export const fieldToSchemaMap = {
850
884
  overrideAccess: false,
851
885
  select,
852
886
  showHiddenFields: false,
853
- transactionID: context.req.transactionID
887
+ transactionID: req.transactionID
854
888
  }));
855
889
  if (result) {
856
890
  if (isRelatedToManyCollections) {
@@ -882,7 +916,8 @@ export const fieldToSchemaMap = {
882
916
  }
883
917
  if (id) {
884
918
  if (graphQLCollections.some((collection)=>collection.slug === relatedCollectionSlug)) {
885
- const relatedDocument = await context.req.payloadDataLoader.load(createDataloaderCacheKey({
919
+ const relatedDocument = await req.payloadDataLoader.load(createDataloaderCacheKey({
920
+ branch: resolveBranch(req),
886
921
  collectionSlug: relatedCollectionSlug,
887
922
  currentDepth: 0,
888
923
  depth: 0,
@@ -893,7 +928,7 @@ export const fieldToSchemaMap = {
893
928
  overrideAccess: false,
894
929
  select,
895
930
  showHiddenFields: false,
896
- transactionID: context.req.transactionID
931
+ transactionID: req.transactionID
897
932
  }));
898
933
  if (relatedDocument) {
899
934
  if (isRelatedToManyCollections) {