@payloadcms/graphql 3.0.0-canary.0374de4 → 3.0.0-canary.0992b47

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.
@@ -1 +1 @@
1
- {"version":3,"file":"buildObjectType.d.ts","sourceRoot":"","sources":["../../src/schema/buildObjectType.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAe,MAAM,SAAS,CAAA;AAC9D,OAAO,KAAK,EAQV,KAAK,EACL,WAAW,EAUX,eAAe,EAMhB,MAAM,SAAS,CAAA;AAEhB,OAAO,EAOL,iBAAiB,EAGlB,MAAM,SAAS,CAAA;AAchB,MAAM,MAAM,gBAAgB,GAAG;IAC7B,CAAC,IAAI,EAAE,MAAM,GAAG,kBAAkB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;CAC7C,CAAA;AAED,KAAK,IAAI,GAAG;IACV,UAAU,CAAC,EAAE,gBAAgB,CAAA;IAC7B,MAAM,EAAE,eAAe,CAAA;IACvB,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,aAAa,EAAE,WAAW,CAAA;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,wBAAgB,eAAe,CAAC,EAC9B,IAAI,EACJ,UAAe,EACf,MAAM,EACN,MAAM,EACN,aAAa,EACb,aAAa,EACb,UAAU,GACX,EAAE,IAAI,GAAG,iBAAiB,CAkvB1B"}
1
+ {"version":3,"file":"buildObjectType.d.ts","sourceRoot":"","sources":["../../src/schema/buildObjectType.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAe,MAAM,SAAS,CAAA;AAC9D,OAAO,KAAK,EAQV,KAAK,EACL,WAAW,EAUX,eAAe,EAMhB,MAAM,SAAS,CAAA;AAEhB,OAAO,EAOL,iBAAiB,EAGlB,MAAM,SAAS,CAAA;AAchB,MAAM,MAAM,gBAAgB,GAAG;IAC7B,CAAC,IAAI,EAAE,MAAM,GAAG,kBAAkB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;CAC7C,CAAA;AAED,KAAK,IAAI,GAAG;IACV,UAAU,CAAC,EAAE,gBAAgB,CAAA;IAC7B,MAAM,EAAE,eAAe,CAAA;IACvB,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,aAAa,EAAE,WAAW,CAAA;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,wBAAgB,eAAe,CAAC,EAC9B,IAAI,EACJ,UAAe,EACf,MAAM,EACN,MAAM,EACN,aAAa,EACb,aAAa,EACb,UAAU,GACX,EAAE,IAAI,GAAG,iBAAiB,CA+tB1B"}
@@ -172,19 +172,17 @@ export function buildObjectType({ name, baseFields = {}, config, fields, forceNu
172
172
  const relationshipName = combineParentName(parentName, toWords(field.name, true));
173
173
  let type;
174
174
  let relationToType = null;
175
- const graphQLCollections = config.collections.filter((collectionConfig)=>collectionConfig.graphQL !== false);
176
175
  if (Array.isArray(relationTo)) {
177
176
  relationToType = new GraphQLEnumType({
178
177
  name: `${relationshipName}_RelationTo`,
179
- values: relationTo.filter((relation)=>graphQLCollections.some((collection)=>collection.slug === relation)).reduce((relations, relation)=>({
178
+ values: relationTo.reduce((relations, relation)=>({
180
179
  ...relations,
181
180
  [formatName(relation)]: {
182
181
  value: relation
183
182
  }
184
183
  }), {})
185
184
  });
186
- // Only pass collections that are GraphQL enabled
187
- const types = relationTo.filter((relation)=>graphQLCollections.some((collection)=>collection.slug === relation)).map((relation)=>graphqlResult.collections[relation]?.graphQL.type);
185
+ const types = relationTo.map((relation)=>graphqlResult.collections[relation].graphQL.type);
188
186
  type = new GraphQLObjectType({
189
187
  name: `${relationshipName}_Relationship`,
190
188
  fields: {
@@ -213,7 +211,7 @@ export function buildObjectType({ name, baseFields = {}, config, fields, forceNu
213
211
  const relationshipArgs = {};
214
212
  const relationsUseDrafts = (Array.isArray(relationTo) ? relationTo : [
215
213
  relationTo
216
- ]).filter((relation)=>graphQLCollections.some((collection)=>collection.slug === relation)).some((relation)=>graphqlResult.collections[relation].config.versions?.drafts);
214
+ ]).some((relation)=>graphqlResult.collections[relation].config.versions?.drafts);
217
215
  if (relationsUseDrafts) {
218
216
  relationshipArgs.draft = {
219
217
  type: GraphQLBoolean
@@ -245,35 +243,33 @@ export function buildObjectType({ name, baseFields = {}, config, fields, forceNu
245
243
  const createPopulationPromise = async (relatedDoc, i)=>{
246
244
  let id = relatedDoc;
247
245
  let collectionSlug = field.relationTo;
248
- if (graphQLCollections.some((collection)=>collection.slug === collectionSlug)) {
246
+ if (isRelatedToManyCollections) {
247
+ collectionSlug = relatedDoc.relationTo;
248
+ id = relatedDoc.value;
249
+ }
250
+ const result = await context.req.payloadDataLoader.load(createDataloaderCacheKey({
251
+ collectionSlug: collectionSlug,
252
+ currentDepth: 0,
253
+ depth: 0,
254
+ docID: id,
255
+ draft,
256
+ fallbackLocale,
257
+ locale,
258
+ overrideAccess: false,
259
+ showHiddenFields: false,
260
+ transactionID: context.req.transactionID
261
+ }));
262
+ if (result) {
249
263
  if (isRelatedToManyCollections) {
250
- collectionSlug = relatedDoc.relationTo;
251
- id = relatedDoc.value;
252
- }
253
- const result = await context.req.payloadDataLoader.load(createDataloaderCacheKey({
254
- collectionSlug: collectionSlug,
255
- currentDepth: 0,
256
- depth: 0,
257
- docID: id,
258
- draft,
259
- fallbackLocale,
260
- locale,
261
- overrideAccess: false,
262
- showHiddenFields: false,
263
- transactionID: context.req.transactionID
264
- }));
265
- if (result) {
266
- if (isRelatedToManyCollections) {
267
- results[i] = {
268
- relationTo: collectionSlug,
269
- value: {
270
- ...result,
271
- collection: collectionSlug
272
- }
273
- };
274
- } else {
275
- results[i] = result;
276
- }
264
+ results[i] = {
265
+ relationTo: collectionSlug,
266
+ value: {
267
+ ...result,
268
+ collection: collectionSlug
269
+ }
270
+ };
271
+ } else {
272
+ results[i] = result;
277
273
  }
278
274
  }
279
275
  };
@@ -291,31 +287,29 @@ export function buildObjectType({ name, baseFields = {}, config, fields, forceNu
291
287
  relatedCollectionSlug = value.relationTo;
292
288
  }
293
289
  if (id) {
294
- if (graphQLCollections.some((collection)=>collection.slug === relatedCollectionSlug)) {
295
- const relatedDocument = await context.req.payloadDataLoader.load(createDataloaderCacheKey({
296
- collectionSlug: relatedCollectionSlug,
297
- currentDepth: 0,
298
- depth: 0,
299
- docID: id,
300
- draft,
301
- fallbackLocale,
302
- locale,
303
- overrideAccess: false,
304
- showHiddenFields: false,
305
- transactionID: context.req.transactionID
306
- }));
307
- if (relatedDocument) {
308
- if (isRelatedToManyCollections) {
309
- return {
310
- relationTo: relatedCollectionSlug,
311
- value: {
312
- ...relatedDocument,
313
- collection: relatedCollectionSlug
314
- }
315
- };
316
- }
317
- return relatedDocument;
290
+ const relatedDocument = await context.req.payloadDataLoader.load(createDataloaderCacheKey({
291
+ collectionSlug: relatedCollectionSlug,
292
+ currentDepth: 0,
293
+ depth: 0,
294
+ docID: id,
295
+ draft,
296
+ fallbackLocale,
297
+ locale,
298
+ overrideAccess: false,
299
+ showHiddenFields: false,
300
+ transactionID: context.req.transactionID
301
+ }));
302
+ if (relatedDocument) {
303
+ if (isRelatedToManyCollections) {
304
+ return {
305
+ relationTo: relatedCollectionSlug,
306
+ value: {
307
+ ...relatedDocument,
308
+ collection: relatedCollectionSlug
309
+ }
310
+ };
318
311
  }
312
+ return relatedDocument;
319
313
  }
320
314
  return null;
321
315
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/schema/buildObjectType.ts"],"sourcesContent":["import type { GraphQLFieldConfig, 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 RichTextAdapter,\n RichTextField,\n RowField,\n SanitizedConfig,\n SelectField,\n TabsField,\n TextareaField,\n TextField,\n UploadField,\n} from 'payload'\n\nimport {\n GraphQLBoolean,\n GraphQLEnumType,\n GraphQLFloat,\n GraphQLInt,\n GraphQLList,\n GraphQLNonNull,\n GraphQLObjectType,\n GraphQLString,\n GraphQLUnionType,\n} from 'graphql'\nimport { DateTimeResolver, EmailAddressResolver } from 'graphql-scalars'\nimport { createDataloaderCacheKey, MissingEditorProp, toWords } from 'payload'\nimport { tabHasName } from 'payload/shared'\n\nimport type { Context } from '../resolvers/types.js'\n\nimport { GraphQLJSON } from '../packages/graphql-type-json/index.js'\nimport { combineParentName } from '../utilities/combineParentName.js'\nimport { formatName } from '../utilities/formatName.js'\nimport { formatOptions } from '../utilities/formatOptions.js'\nimport { isFieldNullable } from './isFieldNullable.js'\nimport { withNullableType } from './withNullableType.js'\n\nexport type ObjectTypeConfig = {\n [path: string]: GraphQLFieldConfig<any, any>\n}\n\ntype Args = {\n baseFields?: ObjectTypeConfig\n config: SanitizedConfig\n fields: Field[]\n forceNullable?: boolean\n graphqlResult: GraphQLInfo\n name: string\n parentName: string\n}\n\nexport function buildObjectType({\n name,\n baseFields = {},\n config,\n fields,\n forceNullable,\n graphqlResult,\n parentName,\n}: Args): GraphQLObjectType {\n const fieldToSchemaMap = {\n array: (objectTypeConfig: ObjectTypeConfig, field: ArrayField) => {\n const interfaceName =\n field?.interfaceName || combineParentName(parentName, toWords(field.name, true))\n\n if (!graphqlResult.types.arrayTypes[interfaceName]) {\n const objectType = buildObjectType({\n name: interfaceName,\n config,\n fields: field.fields,\n forceNullable: isFieldNullable(field, forceNullable),\n graphqlResult,\n parentName: interfaceName,\n })\n\n if (Object.keys(objectType.getFields()).length) {\n graphqlResult.types.arrayTypes[interfaceName] = objectType\n }\n }\n\n if (!graphqlResult.types.arrayTypes[interfaceName]) {\n return objectTypeConfig\n }\n\n const arrayType = new GraphQLList(\n new GraphQLNonNull(graphqlResult.types.arrayTypes[interfaceName]),\n )\n\n return {\n ...objectTypeConfig,\n [field.name]: { type: withNullableType(field, arrayType) },\n }\n },\n blocks: (objectTypeConfig: ObjectTypeConfig, field: BlocksField) => {\n const blockTypes: GraphQLObjectType<any, any>[] = field.blocks.reduce((acc, block) => {\n if (!graphqlResult.types.blockTypes[block.slug]) {\n const interfaceName =\n block?.interfaceName || block?.graphQL?.singularName || toWords(block.slug, true)\n\n const objectType = buildObjectType({\n name: interfaceName,\n config,\n fields: [\n ...block.fields,\n {\n name: 'blockType',\n type: 'text',\n },\n ],\n forceNullable,\n graphqlResult,\n parentName: interfaceName,\n })\n\n if (Object.keys(objectType.getFields()).length) {\n graphqlResult.types.blockTypes[block.slug] = objectType\n }\n }\n\n if (graphqlResult.types.blockTypes[block.slug]) {\n acc.push(graphqlResult.types.blockTypes[block.slug])\n }\n\n return acc\n }, [])\n\n if (blockTypes.length === 0) {\n return objectTypeConfig\n }\n\n const fullName = combineParentName(parentName, toWords(field.name, true))\n\n const type = new GraphQLList(\n new GraphQLNonNull(\n new GraphQLUnionType({\n name: fullName,\n resolveType: (data) => graphqlResult.types.blockTypes[data.blockType].name,\n types: blockTypes,\n }),\n ),\n )\n\n return {\n ...objectTypeConfig,\n [field.name]: { type: withNullableType(field, type) },\n }\n },\n checkbox: (objectTypeConfig: ObjectTypeConfig, field: CheckboxField) => ({\n ...objectTypeConfig,\n [field.name]: { type: withNullableType(field, GraphQLBoolean, forceNullable) },\n }),\n code: (objectTypeConfig: ObjectTypeConfig, field: CodeField) => ({\n ...objectTypeConfig,\n [field.name]: { type: withNullableType(field, GraphQLString, forceNullable) },\n }),\n collapsible: (objectTypeConfig: ObjectTypeConfig, field: CollapsibleField) =>\n field.fields.reduce((objectTypeConfigWithCollapsibleFields, subField) => {\n const addSubField = fieldToSchemaMap[subField.type]\n if (addSubField) {\n return addSubField(objectTypeConfigWithCollapsibleFields, subField)\n }\n return objectTypeConfigWithCollapsibleFields\n }, objectTypeConfig),\n date: (objectTypeConfig: ObjectTypeConfig, field: DateField) => ({\n ...objectTypeConfig,\n [field.name]: { type: withNullableType(field, DateTimeResolver, forceNullable) },\n }),\n email: (objectTypeConfig: ObjectTypeConfig, field: EmailField) => ({\n ...objectTypeConfig,\n [field.name]: { type: withNullableType(field, EmailAddressResolver, forceNullable) },\n }),\n group: (objectTypeConfig: ObjectTypeConfig, field: GroupField) => {\n const interfaceName =\n field?.interfaceName || combineParentName(parentName, toWords(field.name, true))\n\n if (!graphqlResult.types.groupTypes[interfaceName]) {\n const objectType = buildObjectType({\n name: interfaceName,\n config,\n fields: field.fields,\n forceNullable: isFieldNullable(field, forceNullable),\n graphqlResult,\n parentName: interfaceName,\n })\n\n if (Object.keys(objectType.getFields()).length) {\n graphqlResult.types.groupTypes[interfaceName] = objectType\n }\n }\n\n if (!graphqlResult.types.groupTypes[interfaceName]) {\n return objectTypeConfig\n }\n\n return {\n ...objectTypeConfig,\n [field.name]: { type: graphqlResult.types.groupTypes[interfaceName] },\n }\n },\n json: (objectTypeConfig: ObjectTypeConfig, field: JSONField) => ({\n ...objectTypeConfig,\n [field.name]: { type: withNullableType(field, GraphQLJSON, forceNullable) },\n }),\n number: (objectTypeConfig: ObjectTypeConfig, field: NumberField) => {\n const type = field?.name === 'id' ? GraphQLInt : GraphQLFloat\n return {\n ...objectTypeConfig,\n [field.name]: {\n type: withNullableType(\n field,\n field?.hasMany === true ? new GraphQLList(type) : type,\n forceNullable,\n ),\n },\n }\n },\n point: (objectTypeConfig: ObjectTypeConfig, field: PointField) => ({\n ...objectTypeConfig,\n [field.name]: {\n type: withNullableType(\n field,\n new GraphQLList(new GraphQLNonNull(GraphQLFloat)),\n forceNullable,\n ),\n },\n }),\n radio: (objectTypeConfig: ObjectTypeConfig, field: RadioField) => ({\n ...objectTypeConfig,\n [field.name]: {\n type: withNullableType(\n field,\n new GraphQLEnumType({\n name: combineParentName(parentName, field.name),\n values: formatOptions(field),\n }),\n forceNullable,\n ),\n },\n }),\n relationship: (objectTypeConfig: ObjectTypeConfig, field: RelationshipField) => {\n const { relationTo } = field\n const isRelatedToManyCollections = Array.isArray(relationTo)\n const hasManyValues = field.hasMany\n const relationshipName = combineParentName(parentName, toWords(field.name, true))\n\n let type\n let relationToType = null\n\n const graphQLCollections = config.collections.filter(\n (collectionConfig) => collectionConfig.graphQL !== false,\n )\n\n if (Array.isArray(relationTo)) {\n relationToType = new GraphQLEnumType({\n name: `${relationshipName}_RelationTo`,\n values: relationTo\n .filter((relation) =>\n graphQLCollections.some((collection) => collection.slug === relation),\n )\n .reduce(\n (relations, relation) => ({\n ...relations,\n [formatName(relation)]: {\n value: relation,\n },\n }),\n {},\n ),\n })\n\n // Only pass collections that are GraphQL enabled\n const types = relationTo\n .filter((relation) =>\n graphQLCollections.some((collection) => collection.slug === relation),\n )\n .map((relation) => graphqlResult.collections[relation]?.graphQL.type)\n\n type = new GraphQLObjectType({\n name: `${relationshipName}_Relationship`,\n fields: {\n relationTo: {\n type: relationToType,\n },\n value: {\n type: new GraphQLUnionType({\n name: relationshipName,\n resolveType(data) {\n return graphqlResult.collections[data.collection].graphQL.type.name\n },\n types,\n }),\n },\n },\n })\n } else {\n ;({ type } = graphqlResult.collections[relationTo].graphQL)\n }\n\n // If the relationshipType is undefined at this point,\n // it can be assumed that this blockType can have a relationship\n // to itself. Therefore, we set the relationshipType equal to the blockType\n // that is currently being created.\n\n type = type || newlyCreatedBlockType\n\n const relationshipArgs: {\n draft?: unknown\n fallbackLocale?: unknown\n limit?: unknown\n locale?: unknown\n page?: unknown\n where?: unknown\n } = {}\n\n const relationsUseDrafts = (Array.isArray(relationTo) ? relationTo : [relationTo])\n .filter((relation) => graphQLCollections.some((collection) => collection.slug === relation))\n .some((relation) => graphqlResult.collections[relation].config.versions?.drafts)\n\n if (relationsUseDrafts) {\n relationshipArgs.draft = {\n type: GraphQLBoolean,\n }\n }\n\n if (config.localization) {\n relationshipArgs.locale = {\n type: graphqlResult.types.localeInputType,\n }\n\n relationshipArgs.fallbackLocale = {\n type: graphqlResult.types.fallbackLocaleInputType,\n }\n }\n\n const relationship = {\n type: withNullableType(\n field,\n hasManyValues ? new GraphQLList(new GraphQLNonNull(type)) : type,\n forceNullable,\n ),\n args: relationshipArgs,\n extensions: { complexity: 10 },\n async resolve(parent, args, context: Context) {\n const value = parent[field.name]\n const locale = args.locale || context.req.locale\n const fallbackLocale = args.fallbackLocale || context.req.fallbackLocale\n let relatedCollectionSlug = field.relationTo\n const draft = Boolean(args.draft ?? context.req.query?.draft)\n\n if (hasManyValues) {\n const results = []\n const resultPromises = []\n\n const createPopulationPromise = async (relatedDoc, i) => {\n let id = relatedDoc\n let collectionSlug = field.relationTo\n\n if (graphQLCollections.some((collection) => collection.slug === collectionSlug)) {\n if (isRelatedToManyCollections) {\n collectionSlug = relatedDoc.relationTo\n id = relatedDoc.value\n }\n\n const result = await context.req.payloadDataLoader.load(\n createDataloaderCacheKey({\n collectionSlug: collectionSlug as string,\n currentDepth: 0,\n depth: 0,\n docID: id,\n draft,\n fallbackLocale,\n locale,\n overrideAccess: false,\n showHiddenFields: false,\n transactionID: context.req.transactionID,\n }),\n )\n\n if (result) {\n if (isRelatedToManyCollections) {\n results[i] = {\n relationTo: collectionSlug,\n value: {\n ...result,\n collection: collectionSlug,\n },\n }\n } else {\n results[i] = result\n }\n }\n }\n }\n\n if (value) {\n value.forEach((relatedDoc, i) => {\n resultPromises.push(createPopulationPromise(relatedDoc, i))\n })\n }\n\n await Promise.all(resultPromises)\n return results\n }\n\n let id = value\n if (isRelatedToManyCollections && value) {\n id = value.value\n relatedCollectionSlug = value.relationTo\n }\n\n if (id) {\n if (\n graphQLCollections.some((collection) => collection.slug === relatedCollectionSlug)\n ) {\n const relatedDocument = await context.req.payloadDataLoader.load(\n createDataloaderCacheKey({\n collectionSlug: relatedCollectionSlug as string,\n currentDepth: 0,\n depth: 0,\n docID: id,\n draft,\n fallbackLocale,\n locale,\n overrideAccess: false,\n showHiddenFields: false,\n transactionID: context.req.transactionID,\n }),\n )\n\n if (relatedDocument) {\n if (isRelatedToManyCollections) {\n return {\n relationTo: relatedCollectionSlug,\n value: {\n ...relatedDocument,\n collection: relatedCollectionSlug,\n },\n }\n }\n\n return relatedDocument\n }\n }\n\n return null\n }\n\n return null\n },\n }\n\n return {\n ...objectTypeConfig,\n [field.name]: relationship,\n }\n },\n richText: (objectTypeConfig: ObjectTypeConfig, field: RichTextField) => ({\n ...objectTypeConfig,\n [field.name]: {\n type: withNullableType(field, GraphQLJSON, forceNullable),\n args: {\n depth: {\n type: GraphQLInt,\n },\n },\n async resolve(parent, args, context: Context) {\n let depth = config.defaultDepth\n if (typeof args.depth !== 'undefined') {\n depth = args.depth\n }\n if (!field?.editor) {\n throw new MissingEditorProp(field) // while we allow disabling editor functionality, you should not have any richText fields defined if you do not have an editor\n }\n\n if (typeof field?.editor === 'function') {\n throw new Error('Attempted to access unsanitized rich text editor.')\n }\n\n const editor: RichTextAdapter = field?.editor\n\n // RichText fields have their own depth argument in GraphQL.\n // This is why the populationPromise (which populates richtext fields like uploads and relationships)\n // is run here again, with the provided depth.\n // In the graphql find.ts resolver, the depth is then hard-coded to 0.\n // Effectively, this means that the populationPromise for GraphQL is only run here, and not in the find.ts resolver / normal population promise.\n if (editor?.graphQLPopulationPromises) {\n const fieldPromises = []\n const populationPromises = []\n const populateDepth =\n field?.maxDepth !== undefined && field?.maxDepth < depth ? field?.maxDepth : depth\n\n editor?.graphQLPopulationPromises({\n context,\n depth: populateDepth,\n draft: args.draft,\n field,\n fieldPromises,\n findMany: false,\n flattenLocales: false,\n overrideAccess: false,\n populationPromises,\n req: context.req,\n showHiddenFields: false,\n siblingDoc: parent,\n })\n await Promise.all(fieldPromises)\n await Promise.all(populationPromises)\n }\n\n return parent[field.name]\n },\n },\n }),\n row: (objectTypeConfig: ObjectTypeConfig, field: RowField) =>\n field.fields.reduce((objectTypeConfigWithRowFields, subField) => {\n const addSubField = fieldToSchemaMap[subField.type]\n if (addSubField) {\n return addSubField(objectTypeConfigWithRowFields, subField)\n }\n return objectTypeConfigWithRowFields\n }, objectTypeConfig),\n select: (objectTypeConfig: ObjectTypeConfig, field: SelectField) => {\n const fullName = combineParentName(parentName, field.name)\n\n let type: GraphQLType = new GraphQLEnumType({\n name: fullName,\n values: formatOptions(field),\n })\n\n type = field.hasMany ? new GraphQLList(new GraphQLNonNull(type)) : type\n type = withNullableType(field, type, forceNullable)\n\n return {\n ...objectTypeConfig,\n [field.name]: { type },\n }\n },\n tabs: (objectTypeConfig: ObjectTypeConfig, field: TabsField) =>\n field.tabs.reduce((tabSchema, tab) => {\n if (tabHasName(tab)) {\n const interfaceName =\n tab?.interfaceName || combineParentName(parentName, toWords(tab.name, true))\n\n if (!graphqlResult.types.groupTypes[interfaceName]) {\n const objectType = buildObjectType({\n name: interfaceName,\n config,\n fields: tab.fields,\n forceNullable,\n graphqlResult,\n parentName: interfaceName,\n })\n\n if (Object.keys(objectType.getFields()).length) {\n graphqlResult.types.groupTypes[interfaceName] = objectType\n }\n }\n\n if (!graphqlResult.types.groupTypes[interfaceName]) {\n return tabSchema\n }\n\n return {\n ...tabSchema,\n [tab.name]: { type: graphqlResult.types.groupTypes[interfaceName] },\n }\n }\n\n return {\n ...tabSchema,\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 }, tabSchema),\n }\n }, objectTypeConfig),\n text: (objectTypeConfig: ObjectTypeConfig, field: TextField) => ({\n ...objectTypeConfig,\n [field.name]: {\n type: withNullableType(\n field,\n field.hasMany === true ? new GraphQLList(GraphQLString) : GraphQLString,\n forceNullable,\n ),\n },\n }),\n textarea: (objectTypeConfig: ObjectTypeConfig, field: TextareaField) => ({\n ...objectTypeConfig,\n [field.name]: { type: withNullableType(field, GraphQLString, forceNullable) },\n }),\n upload: (objectTypeConfig: ObjectTypeConfig, field: UploadField) => {\n const { relationTo } = field\n const isRelatedToManyCollections = Array.isArray(relationTo)\n const hasManyValues = field.hasMany\n const relationshipName = combineParentName(parentName, toWords(field.name, true))\n\n let type\n let relationToType = null\n\n if (Array.isArray(relationTo)) {\n relationToType = new GraphQLEnumType({\n name: `${relationshipName}_RelationTo`,\n values: relationTo.reduce(\n (relations, relation) => ({\n ...relations,\n [formatName(relation)]: {\n value: relation,\n },\n }),\n {},\n ),\n })\n\n const types = relationTo.map((relation) => graphqlResult.collections[relation].graphQL.type)\n\n type = new GraphQLObjectType({\n name: `${relationshipName}_Relationship`,\n fields: {\n relationTo: {\n type: relationToType,\n },\n value: {\n type: new GraphQLUnionType({\n name: relationshipName,\n resolveType(data) {\n return graphqlResult.collections[data.collection].graphQL.type.name\n },\n types,\n }),\n },\n },\n })\n } else {\n ;({ type } = graphqlResult.collections[relationTo].graphQL)\n }\n\n // If the relationshipType is undefined at this point,\n // it can be assumed that this blockType can have a relationship\n // to itself. Therefore, we set the relationshipType equal to the blockType\n // that is currently being created.\n\n type = type || newlyCreatedBlockType\n\n const relationshipArgs: {\n draft?: unknown\n fallbackLocale?: unknown\n limit?: unknown\n locale?: unknown\n page?: unknown\n where?: unknown\n } = {}\n\n const relationsUseDrafts = (Array.isArray(relationTo) ? relationTo : [relationTo]).some(\n (relation) => graphqlResult.collections[relation].config.versions?.drafts,\n )\n\n if (relationsUseDrafts) {\n relationshipArgs.draft = {\n type: GraphQLBoolean,\n }\n }\n\n if (config.localization) {\n relationshipArgs.locale = {\n type: graphqlResult.types.localeInputType,\n }\n\n relationshipArgs.fallbackLocale = {\n type: graphqlResult.types.fallbackLocaleInputType,\n }\n }\n\n const relationship = {\n type: withNullableType(\n field,\n hasManyValues ? new GraphQLList(new GraphQLNonNull(type)) : type,\n forceNullable,\n ),\n args: relationshipArgs,\n extensions: { complexity: 10 },\n async resolve(parent, args, context: Context) {\n const value = parent[field.name]\n const locale = args.locale || context.req.locale\n const fallbackLocale = args.fallbackLocale || context.req.fallbackLocale\n let relatedCollectionSlug = field.relationTo\n const draft = Boolean(args.draft ?? context.req.query?.draft)\n\n if (hasManyValues) {\n const results = []\n const resultPromises = []\n\n const createPopulationPromise = async (relatedDoc, i) => {\n let id = relatedDoc\n let collectionSlug = field.relationTo\n\n if (isRelatedToManyCollections) {\n collectionSlug = relatedDoc.relationTo\n id = relatedDoc.value\n }\n\n const result = await context.req.payloadDataLoader.load(\n createDataloaderCacheKey({\n collectionSlug,\n currentDepth: 0,\n depth: 0,\n docID: id,\n draft,\n fallbackLocale,\n locale,\n overrideAccess: false,\n showHiddenFields: false,\n transactionID: context.req.transactionID,\n }),\n )\n\n if (result) {\n if (isRelatedToManyCollections) {\n results[i] = {\n relationTo: collectionSlug,\n value: {\n ...result,\n collection: collectionSlug,\n },\n }\n } else {\n results[i] = result\n }\n }\n }\n\n if (value) {\n value.forEach((relatedDoc, i) => {\n resultPromises.push(createPopulationPromise(relatedDoc, i))\n })\n }\n\n await Promise.all(resultPromises)\n return results\n }\n\n let id = value\n if (isRelatedToManyCollections && value) {\n id = value.value\n relatedCollectionSlug = value.relationTo\n }\n\n if (id) {\n const relatedDocument = await context.req.payloadDataLoader.load(\n createDataloaderCacheKey({\n collectionSlug: relatedCollectionSlug,\n currentDepth: 0,\n depth: 0,\n docID: id,\n draft,\n fallbackLocale,\n locale,\n overrideAccess: false,\n showHiddenFields: false,\n transactionID: context.req.transactionID,\n }),\n )\n\n if (relatedDocument) {\n if (isRelatedToManyCollections) {\n return {\n relationTo: relatedCollectionSlug,\n value: {\n ...relatedDocument,\n collection: relatedCollectionSlug,\n },\n }\n }\n\n return relatedDocument\n }\n\n return null\n }\n\n return null\n },\n }\n\n return {\n ...objectTypeConfig,\n [field.name]: relationship,\n }\n },\n }\n\n const objectSchema = {\n name,\n fields: () =>\n fields.reduce((objectTypeConfig, field) => {\n const fieldSchema = fieldToSchemaMap[field.type]\n\n if (typeof fieldSchema !== 'function') {\n return objectTypeConfig\n }\n\n return {\n ...objectTypeConfig,\n ...fieldSchema(objectTypeConfig, field),\n }\n }, baseFields),\n }\n\n const newlyCreatedBlockType = new GraphQLObjectType(objectSchema)\n\n return newlyCreatedBlockType\n}\n"],"names":["GraphQLBoolean","GraphQLEnumType","GraphQLFloat","GraphQLInt","GraphQLList","GraphQLNonNull","GraphQLObjectType","GraphQLString","GraphQLUnionType","DateTimeResolver","EmailAddressResolver","createDataloaderCacheKey","MissingEditorProp","toWords","tabHasName","GraphQLJSON","combineParentName","formatName","formatOptions","isFieldNullable","withNullableType","buildObjectType","name","baseFields","config","fields","forceNullable","graphqlResult","parentName","fieldToSchemaMap","array","objectTypeConfig","field","interfaceName","types","arrayTypes","objectType","Object","keys","getFields","length","arrayType","type","blocks","blockTypes","reduce","acc","block","slug","graphQL","singularName","push","fullName","resolveType","data","blockType","checkbox","code","collapsible","objectTypeConfigWithCollapsibleFields","subField","addSubField","date","email","group","groupTypes","json","number","hasMany","point","radio","values","relationship","relationTo","isRelatedToManyCollections","Array","isArray","hasManyValues","relationshipName","relationToType","graphQLCollections","collections","filter","collectionConfig","relation","some","collection","relations","value","map","newlyCreatedBlockType","relationshipArgs","relationsUseDrafts","versions","drafts","draft","localization","locale","localeInputType","fallbackLocale","fallbackLocaleInputType","args","extensions","complexity","resolve","parent","context","req","relatedCollectionSlug","Boolean","query","results","resultPromises","createPopulationPromise","relatedDoc","i","id","collectionSlug","result","payloadDataLoader","load","currentDepth","depth","docID","overrideAccess","showHiddenFields","transactionID","forEach","Promise","all","relatedDocument","richText","defaultDepth","editor","Error","graphQLPopulationPromises","fieldPromises","populationPromises","populateDepth","maxDepth","undefined","findMany","flattenLocales","siblingDoc","row","objectTypeConfigWithRowFields","select","tabs","tabSchema","tab","subFieldSchema","text","textarea","upload","objectSchema","fieldSchema"],"mappings":"AA4BA,SACEA,cAAc,EACdC,eAAe,EACfC,YAAY,EACZC,UAAU,EACVC,WAAW,EACXC,cAAc,EACdC,iBAAiB,EACjBC,aAAa,EACbC,gBAAgB,QACX,UAAS;AAChB,SAASC,gBAAgB,EA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AC9D7G,yBAAyB;4BACvB0G,gBAAgBT;4BAChBa,cAAc;4BACdC,OAAO;4BACPC,OAAOP;4BACPrB;4BACAI;4BACAF;4BACA2B,gBAAgB;4BAChBC,kBAAkB;4BAClBC,eAAepB,QAAQC,GAAG,CAACmB,aAAa;wBAC1C;wBAGF,IAAII,iBAAiB;4BACnB,IAAIxD,4BAA4B;gCAC9B,OAAO;oCACLD,YAAYmC;oCACZpB,OAAO;wCACL,GAAG0C,eAAe;wCAClB5C,YAAYsB;oCACd;gCACF;4BACF;4BAEA,OAAOsB;wBACT;wBAEA,OAAO;oBACT;oBAEA,OAAO;gBACT;YACF;YAEA,OAAO;gBACL,GAAGnG,gBAAgB;gBACnB,CAACC,MAAMV,IAAI,CAAC,EAAEkD;YAChB;QACF;IACF;IAEA,MAAMkF,eAAe;QACnBpI;QACAG,QAAQ,IACNA,OAAOoB,MAAM,CAAC,CAACd,kBAAkBC;gBAC/B,MAAM2H,cAAc9H,gBAAgB,CAACG,MAAMU,IAAI,CAAC;gBAEhD,IAAI,OAAOiH,gBAAgB,YAAY;oBACrC,OAAO5H;gBACT;gBAEA,OAAO;oBACL,GAAGA,gBAAgB;oBACnB,GAAG4H,YAAY5H,kBAAkBC,MAAM;gBACzC;YACF,GAAGT;IACP;IAEA,MAAMmE,wBAAwB,IAAIpF,kBAAkBoJ;IAEpD,OAAOhE;AACT"}
1
+ {"version":3,"sources":["../../src/schema/buildObjectType.ts"],"sourcesContent":["import type { GraphQLFieldConfig, 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 RichTextAdapter,\n RichTextField,\n RowField,\n SanitizedConfig,\n SelectField,\n TabsField,\n TextareaField,\n TextField,\n UploadField,\n} from 'payload'\n\nimport {\n GraphQLBoolean,\n GraphQLEnumType,\n GraphQLFloat,\n GraphQLInt,\n GraphQLList,\n GraphQLNonNull,\n GraphQLObjectType,\n GraphQLString,\n GraphQLUnionType,\n} from 'graphql'\nimport { DateTimeResolver, EmailAddressResolver } from 'graphql-scalars'\nimport { createDataloaderCacheKey, MissingEditorProp, toWords } from 'payload'\nimport { tabHasName } from 'payload/shared'\n\nimport type { Context } from '../resolvers/types.js'\n\nimport { GraphQLJSON } from '../packages/graphql-type-json/index.js'\nimport { combineParentName } from '../utilities/combineParentName.js'\nimport { formatName } from '../utilities/formatName.js'\nimport { formatOptions } from '../utilities/formatOptions.js'\nimport { isFieldNullable } from './isFieldNullable.js'\nimport { withNullableType } from './withNullableType.js'\n\nexport type ObjectTypeConfig = {\n [path: string]: GraphQLFieldConfig<any, any>\n}\n\ntype Args = {\n baseFields?: ObjectTypeConfig\n config: SanitizedConfig\n fields: Field[]\n forceNullable?: boolean\n graphqlResult: GraphQLInfo\n name: string\n parentName: string\n}\n\nexport function buildObjectType({\n name,\n baseFields = {},\n config,\n fields,\n forceNullable,\n graphqlResult,\n parentName,\n}: Args): GraphQLObjectType {\n const fieldToSchemaMap = {\n array: (objectTypeConfig: ObjectTypeConfig, field: ArrayField) => {\n const interfaceName =\n field?.interfaceName || combineParentName(parentName, toWords(field.name, true))\n\n if (!graphqlResult.types.arrayTypes[interfaceName]) {\n const objectType = buildObjectType({\n name: interfaceName,\n config,\n fields: field.fields,\n forceNullable: isFieldNullable(field, forceNullable),\n graphqlResult,\n parentName: interfaceName,\n })\n\n if (Object.keys(objectType.getFields()).length) {\n graphqlResult.types.arrayTypes[interfaceName] = objectType\n }\n }\n\n if (!graphqlResult.types.arrayTypes[interfaceName]) {\n return objectTypeConfig\n }\n\n const arrayType = new GraphQLList(\n new GraphQLNonNull(graphqlResult.types.arrayTypes[interfaceName]),\n )\n\n return {\n ...objectTypeConfig,\n [field.name]: { type: withNullableType(field, arrayType) },\n }\n },\n blocks: (objectTypeConfig: ObjectTypeConfig, field: BlocksField) => {\n const blockTypes: GraphQLObjectType<any, any>[] = field.blocks.reduce((acc, block) => {\n if (!graphqlResult.types.blockTypes[block.slug]) {\n const interfaceName =\n block?.interfaceName || block?.graphQL?.singularName || toWords(block.slug, true)\n\n const objectType = buildObjectType({\n name: interfaceName,\n config,\n fields: [\n ...block.fields,\n {\n name: 'blockType',\n type: 'text',\n },\n ],\n forceNullable,\n graphqlResult,\n parentName: interfaceName,\n })\n\n if (Object.keys(objectType.getFields()).length) {\n graphqlResult.types.blockTypes[block.slug] = objectType\n }\n }\n\n if (graphqlResult.types.blockTypes[block.slug]) {\n acc.push(graphqlResult.types.blockTypes[block.slug])\n }\n\n return acc\n }, [])\n\n if (blockTypes.length === 0) {\n return objectTypeConfig\n }\n\n const fullName = combineParentName(parentName, toWords(field.name, true))\n\n const type = new GraphQLList(\n new GraphQLNonNull(\n new GraphQLUnionType({\n name: fullName,\n resolveType: (data) => graphqlResult.types.blockTypes[data.blockType].name,\n types: blockTypes,\n }),\n ),\n )\n\n return {\n ...objectTypeConfig,\n [field.name]: { type: withNullableType(field, type) },\n }\n },\n checkbox: (objectTypeConfig: ObjectTypeConfig, field: CheckboxField) => ({\n ...objectTypeConfig,\n [field.name]: { type: withNullableType(field, GraphQLBoolean, forceNullable) },\n }),\n code: (objectTypeConfig: ObjectTypeConfig, field: CodeField) => ({\n ...objectTypeConfig,\n [field.name]: { type: withNullableType(field, GraphQLString, forceNullable) },\n }),\n collapsible: (objectTypeConfig: ObjectTypeConfig, field: CollapsibleField) =>\n field.fields.reduce((objectTypeConfigWithCollapsibleFields, subField) => {\n const addSubField = fieldToSchemaMap[subField.type]\n if (addSubField) {\n return addSubField(objectTypeConfigWithCollapsibleFields, subField)\n }\n return objectTypeConfigWithCollapsibleFields\n }, objectTypeConfig),\n date: (objectTypeConfig: ObjectTypeConfig, field: DateField) => ({\n ...objectTypeConfig,\n [field.name]: { type: withNullableType(field, DateTimeResolver, forceNullable) },\n }),\n email: (objectTypeConfig: ObjectTypeConfig, field: EmailField) => ({\n ...objectTypeConfig,\n [field.name]: { type: withNullableType(field, EmailAddressResolver, forceNullable) },\n }),\n group: (objectTypeConfig: ObjectTypeConfig, field: GroupField) => {\n const interfaceName =\n field?.interfaceName || combineParentName(parentName, toWords(field.name, true))\n\n if (!graphqlResult.types.groupTypes[interfaceName]) {\n const objectType = buildObjectType({\n name: interfaceName,\n config,\n fields: field.fields,\n forceNullable: isFieldNullable(field, forceNullable),\n graphqlResult,\n parentName: interfaceName,\n })\n\n if (Object.keys(objectType.getFields()).length) {\n graphqlResult.types.groupTypes[interfaceName] = objectType\n }\n }\n\n if (!graphqlResult.types.groupTypes[interfaceName]) {\n return objectTypeConfig\n }\n\n return {\n ...objectTypeConfig,\n [field.name]: { type: graphqlResult.types.groupTypes[interfaceName] },\n }\n },\n json: (objectTypeConfig: ObjectTypeConfig, field: JSONField) => ({\n ...objectTypeConfig,\n [field.name]: { type: withNullableType(field, GraphQLJSON, forceNullable) },\n }),\n number: (objectTypeConfig: ObjectTypeConfig, field: NumberField) => {\n const type = field?.name === 'id' ? GraphQLInt : GraphQLFloat\n return {\n ...objectTypeConfig,\n [field.name]: {\n type: withNullableType(\n field,\n field?.hasMany === true ? new GraphQLList(type) : type,\n forceNullable,\n ),\n },\n }\n },\n point: (objectTypeConfig: ObjectTypeConfig, field: PointField) => ({\n ...objectTypeConfig,\n [field.name]: {\n type: withNullableType(\n field,\n new GraphQLList(new GraphQLNonNull(GraphQLFloat)),\n forceNullable,\n ),\n },\n }),\n radio: (objectTypeConfig: ObjectTypeConfig, field: RadioField) => ({\n ...objectTypeConfig,\n [field.name]: {\n type: withNullableType(\n field,\n new GraphQLEnumType({\n name: combineParentName(parentName, field.name),\n values: formatOptions(field),\n }),\n forceNullable,\n ),\n },\n }),\n relationship: (objectTypeConfig: ObjectTypeConfig, field: RelationshipField) => {\n const { relationTo } = field\n const isRelatedToManyCollections = Array.isArray(relationTo)\n const hasManyValues = field.hasMany\n const relationshipName = combineParentName(parentName, toWords(field.name, true))\n\n let type\n let relationToType = null\n\n if (Array.isArray(relationTo)) {\n relationToType = new GraphQLEnumType({\n name: `${relationshipName}_RelationTo`,\n values: relationTo.reduce(\n (relations, relation) => ({\n ...relations,\n [formatName(relation)]: {\n value: relation,\n },\n }),\n {},\n ),\n })\n\n const types = relationTo.map((relation) => graphqlResult.collections[relation].graphQL.type)\n\n type = new GraphQLObjectType({\n name: `${relationshipName}_Relationship`,\n fields: {\n relationTo: {\n type: relationToType,\n },\n value: {\n type: new GraphQLUnionType({\n name: relationshipName,\n resolveType(data) {\n return graphqlResult.collections[data.collection].graphQL.type.name\n },\n types,\n }),\n },\n },\n })\n } else {\n ;({ type } = graphqlResult.collections[relationTo].graphQL)\n }\n\n // If the relationshipType is undefined at this point,\n // it can be assumed that this blockType can have a relationship\n // to itself. Therefore, we set the relationshipType equal to the blockType\n // that is currently being created.\n\n type = type || newlyCreatedBlockType\n\n const relationshipArgs: {\n draft?: unknown\n fallbackLocale?: unknown\n limit?: unknown\n locale?: unknown\n page?: unknown\n where?: unknown\n } = {}\n\n const relationsUseDrafts = (Array.isArray(relationTo) ? relationTo : [relationTo]).some(\n (relation) => graphqlResult.collections[relation].config.versions?.drafts,\n )\n\n if (relationsUseDrafts) {\n relationshipArgs.draft = {\n type: GraphQLBoolean,\n }\n }\n\n if (config.localization) {\n relationshipArgs.locale = {\n type: graphqlResult.types.localeInputType,\n }\n\n relationshipArgs.fallbackLocale = {\n type: graphqlResult.types.fallbackLocaleInputType,\n }\n }\n\n const relationship = {\n type: withNullableType(\n field,\n hasManyValues ? new GraphQLList(new GraphQLNonNull(type)) : type,\n forceNullable,\n ),\n args: relationshipArgs,\n extensions: { complexity: 10 },\n async resolve(parent, args, context: Context) {\n const value = parent[field.name]\n const locale = args.locale || context.req.locale\n const fallbackLocale = args.fallbackLocale || context.req.fallbackLocale\n let relatedCollectionSlug = field.relationTo\n const draft = Boolean(args.draft ?? context.req.query?.draft)\n\n if (hasManyValues) {\n const results = []\n const resultPromises = []\n\n const createPopulationPromise = async (relatedDoc, i) => {\n let id = relatedDoc\n let collectionSlug = field.relationTo\n\n if (isRelatedToManyCollections) {\n collectionSlug = relatedDoc.relationTo\n id = relatedDoc.value\n }\n\n const result = await context.req.payloadDataLoader.load(\n createDataloaderCacheKey({\n collectionSlug: collectionSlug as string,\n currentDepth: 0,\n depth: 0,\n docID: id,\n draft,\n fallbackLocale,\n locale,\n overrideAccess: false,\n showHiddenFields: false,\n transactionID: context.req.transactionID,\n }),\n )\n\n if (result) {\n if (isRelatedToManyCollections) {\n results[i] = {\n relationTo: collectionSlug,\n value: {\n ...result,\n collection: collectionSlug,\n },\n }\n } else {\n results[i] = result\n }\n }\n }\n\n if (value) {\n value.forEach((relatedDoc, i) => {\n resultPromises.push(createPopulationPromise(relatedDoc, i))\n })\n }\n\n await Promise.all(resultPromises)\n return results\n }\n\n let id = value\n if (isRelatedToManyCollections && value) {\n id = value.value\n relatedCollectionSlug = value.relationTo\n }\n\n if (id) {\n const relatedDocument = await context.req.payloadDataLoader.load(\n createDataloaderCacheKey({\n collectionSlug: relatedCollectionSlug as string,\n currentDepth: 0,\n depth: 0,\n docID: id,\n draft,\n fallbackLocale,\n locale,\n overrideAccess: false,\n showHiddenFields: false,\n transactionID: context.req.transactionID,\n }),\n )\n\n if (relatedDocument) {\n if (isRelatedToManyCollections) {\n return {\n relationTo: relatedCollectionSlug,\n value: {\n ...relatedDocument,\n collection: relatedCollectionSlug,\n },\n }\n }\n\n return relatedDocument\n }\n\n return null\n }\n\n return null\n },\n }\n\n return {\n ...objectTypeConfig,\n [field.name]: relationship,\n }\n },\n richText: (objectTypeConfig: ObjectTypeConfig, field: RichTextField) => ({\n ...objectTypeConfig,\n [field.name]: {\n type: withNullableType(field, GraphQLJSON, forceNullable),\n args: {\n depth: {\n type: GraphQLInt,\n },\n },\n async resolve(parent, args, context: Context) {\n let depth = config.defaultDepth\n if (typeof args.depth !== 'undefined') {\n depth = args.depth\n }\n if (!field?.editor) {\n throw new MissingEditorProp(field) // while we allow disabling editor functionality, you should not have any richText fields defined if you do not have an editor\n }\n\n if (typeof field?.editor === 'function') {\n throw new Error('Attempted to access unsanitized rich text editor.')\n }\n\n const editor: RichTextAdapter = field?.editor\n\n // RichText fields have their own depth argument in GraphQL.\n // This is why the populationPromise (which populates richtext fields like uploads and relationships)\n // is run here again, with the provided depth.\n // In the graphql find.ts resolver, the depth is then hard-coded to 0.\n // Effectively, this means that the populationPromise for GraphQL is only run here, and not in the find.ts resolver / normal population promise.\n if (editor?.graphQLPopulationPromises) {\n const fieldPromises = []\n const populationPromises = []\n const populateDepth =\n field?.maxDepth !== undefined && field?.maxDepth < depth ? field?.maxDepth : depth\n\n editor?.graphQLPopulationPromises({\n context,\n depth: populateDepth,\n draft: args.draft,\n field,\n fieldPromises,\n findMany: false,\n flattenLocales: false,\n overrideAccess: false,\n populationPromises,\n req: context.req,\n showHiddenFields: false,\n siblingDoc: parent,\n })\n await Promise.all(fieldPromises)\n await Promise.all(populationPromises)\n }\n\n return parent[field.name]\n },\n },\n }),\n row: (objectTypeConfig: ObjectTypeConfig, field: RowField) =>\n field.fields.reduce((objectTypeConfigWithRowFields, subField) => {\n const addSubField = fieldToSchemaMap[subField.type]\n if (addSubField) {\n return addSubField(objectTypeConfigWithRowFields, subField)\n }\n return objectTypeConfigWithRowFields\n }, objectTypeConfig),\n select: (objectTypeConfig: ObjectTypeConfig, field: SelectField) => {\n const fullName = combineParentName(parentName, field.name)\n\n let type: GraphQLType = new GraphQLEnumType({\n name: fullName,\n values: formatOptions(field),\n })\n\n type = field.hasMany ? new GraphQLList(new GraphQLNonNull(type)) : type\n type = withNullableType(field, type, forceNullable)\n\n return {\n ...objectTypeConfig,\n [field.name]: { type },\n }\n },\n tabs: (objectTypeConfig: ObjectTypeConfig, field: TabsField) =>\n field.tabs.reduce((tabSchema, tab) => {\n if (tabHasName(tab)) {\n const interfaceName =\n tab?.interfaceName || combineParentName(parentName, toWords(tab.name, true))\n\n if (!graphqlResult.types.groupTypes[interfaceName]) {\n const objectType = buildObjectType({\n name: interfaceName,\n config,\n fields: tab.fields,\n forceNullable,\n graphqlResult,\n parentName: interfaceName,\n })\n\n if (Object.keys(objectType.getFields()).length) {\n graphqlResult.types.groupTypes[interfaceName] = objectType\n }\n }\n\n if (!graphqlResult.types.groupTypes[interfaceName]) {\n return tabSchema\n }\n\n return {\n ...tabSchema,\n [tab.name]: { type: graphqlResult.types.groupTypes[interfaceName] },\n }\n }\n\n return {\n ...tabSchema,\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 }, tabSchema),\n }\n }, objectTypeConfig),\n text: (objectTypeConfig: ObjectTypeConfig, field: TextField) => ({\n ...objectTypeConfig,\n [field.name]: {\n type: withNullableType(\n field,\n field.hasMany === true ? new GraphQLList(GraphQLString) : GraphQLString,\n forceNullable,\n ),\n },\n }),\n textarea: (objectTypeConfig: ObjectTypeConfig, field: TextareaField) => ({\n ...objectTypeConfig,\n [field.name]: { type: withNullableType(field, GraphQLString, forceNullable) },\n }),\n upload: (objectTypeConfig: ObjectTypeConfig, field: UploadField) => {\n const { relationTo } = field\n const isRelatedToManyCollections = Array.isArray(relationTo)\n const hasManyValues = field.hasMany\n const relationshipName = combineParentName(parentName, toWords(field.name, true))\n\n let type\n let relationToType = null\n\n if (Array.isArray(relationTo)) {\n relationToType = new GraphQLEnumType({\n name: `${relationshipName}_RelationTo`,\n values: relationTo.reduce(\n (relations, relation) => ({\n ...relations,\n [formatName(relation)]: {\n value: relation,\n },\n }),\n {},\n ),\n })\n\n const types = relationTo.map((relation) => graphqlResult.collections[relation].graphQL.type)\n\n type = new GraphQLObjectType({\n name: `${relationshipName}_Relationship`,\n fields: {\n relationTo: {\n type: relationToType,\n },\n value: {\n type: new GraphQLUnionType({\n name: relationshipName,\n resolveType(data) {\n return graphqlResult.collections[data.collection].graphQL.type.name\n },\n types,\n }),\n },\n },\n })\n } else {\n ;({ type } = graphqlResult.collections[relationTo].graphQL)\n }\n\n // If the relationshipType is undefined at this point,\n // it can be assumed that this blockType can have a relationship\n // to itself. Therefore, we set the relationshipType equal to the blockType\n // that is currently being created.\n\n type = type || newlyCreatedBlockType\n\n const relationshipArgs: {\n draft?: unknown\n fallbackLocale?: unknown\n limit?: unknown\n locale?: unknown\n page?: unknown\n where?: unknown\n } = {}\n\n const relationsUseDrafts = (Array.isArray(relationTo) ? relationTo : [relationTo]).some(\n (relation) => graphqlResult.collections[relation].config.versions?.drafts,\n )\n\n if (relationsUseDrafts) {\n relationshipArgs.draft = {\n type: GraphQLBoolean,\n }\n }\n\n if (config.localization) {\n relationshipArgs.locale = {\n type: graphqlResult.types.localeInputType,\n }\n\n relationshipArgs.fallbackLocale = {\n type: graphqlResult.types.fallbackLocaleInputType,\n }\n }\n\n const relationship = {\n type: withNullableType(\n field,\n hasManyValues ? new GraphQLList(new GraphQLNonNull(type)) : type,\n forceNullable,\n ),\n args: relationshipArgs,\n extensions: { complexity: 10 },\n async resolve(parent, args, context: Context) {\n const value = parent[field.name]\n const locale = args.locale || context.req.locale\n const fallbackLocale = args.fallbackLocale || context.req.fallbackLocale\n let relatedCollectionSlug = field.relationTo\n const draft = Boolean(args.draft ?? context.req.query?.draft)\n\n if (hasManyValues) {\n const results = []\n const resultPromises = []\n\n const createPopulationPromise = async (relatedDoc, i) => {\n let id = relatedDoc\n let collectionSlug = field.relationTo\n\n if (isRelatedToManyCollections) {\n collectionSlug = relatedDoc.relationTo\n id = relatedDoc.value\n }\n\n const result = await context.req.payloadDataLoader.load(\n createDataloaderCacheKey({\n collectionSlug,\n currentDepth: 0,\n depth: 0,\n docID: id,\n draft,\n fallbackLocale,\n locale,\n overrideAccess: false,\n showHiddenFields: false,\n transactionID: context.req.transactionID,\n }),\n )\n\n if (result) {\n if (isRelatedToManyCollections) {\n results[i] = {\n relationTo: collectionSlug,\n value: {\n ...result,\n collection: collectionSlug,\n },\n }\n } else {\n results[i] = result\n }\n }\n }\n\n if (value) {\n value.forEach((relatedDoc, i) => {\n resultPromises.push(createPopulationPromise(relatedDoc, i))\n })\n }\n\n await Promise.all(resultPromises)\n return results\n }\n\n let id = value\n if (isRelatedToManyCollections && value) {\n id = value.value\n relatedCollectionSlug = value.relationTo\n }\n\n if (id) {\n const relatedDocument = await context.req.payloadDataLoader.load(\n createDataloaderCacheKey({\n collectionSlug: relatedCollectionSlug,\n currentDepth: 0,\n depth: 0,\n docID: id,\n draft,\n fallbackLocale,\n locale,\n overrideAccess: false,\n showHiddenFields: false,\n transactionID: context.req.transactionID,\n }),\n )\n\n if (relatedDocument) {\n if (isRelatedToManyCollections) {\n return {\n relationTo: relatedCollectionSlug,\n value: {\n ...relatedDocument,\n collection: relatedCollectionSlug,\n },\n }\n }\n\n return relatedDocument\n }\n\n return null\n }\n\n return null\n },\n }\n\n return {\n ...objectTypeConfig,\n [field.name]: relationship,\n }\n },\n }\n\n const objectSchema = {\n name,\n fields: () =>\n fields.reduce((objectTypeConfig, field) => {\n const fieldSchema = fieldToSchemaMap[field.type]\n\n if (typeof fieldSchema !== 'function') {\n return objectTypeConfig\n }\n\n return {\n ...objectTypeConfig,\n ...fieldSchema(objectTypeConfig, field),\n }\n }, baseFields),\n }\n\n const newlyCreatedBlockType = new GraphQLObjectType(objectSchema)\n\n return newlyCreatedBlockType\n}\n"],"names":["GraphQLBoolean","GraphQLEnumType","GraphQLFloat","GraphQLInt","GraphQLList","GraphQLNonNull","GraphQLObjectType","GraphQLString","GraphQLUnionType","DateTimeResolver","EmailAddressResolver","createDataloaderCacheKey","MissingEditorProp","toWords","tabHasName","GraphQLJSON","combineParentName","formatName","formatOptions","isFieldNullable","withNullableType","buildObjectType","name","baseFields","config","fields","forceNullable","graphqlResult","parentName","fieldToSchemaMap","array","objectTypeConfig","field","interfaceName","types","arrayTypes","objectType","Object","keys","getFields","length","arrayType","type","blocks","blockTypes","reduce","acc","block","slug","graphQL","singularName","push","fullName","resolveType","data","blockType","checkbox","code","collapsible","objectTypeConfigWithCollapsibleFields","subField","addSubField","date","email","group","groupTypes","json","number","hasMany","point","radio","values","relationship","relationTo","isRelatedToManyCollections","Array","isArray","hasManyValues","relationshipName","relationToType","relations","relation","value","map","collections","collection","newlyCreatedBlockType","relationshipArgs","relationsUseDrafts","some","versions","drafts","draft","localization","locale","localeInputType","fallbackLocale","fallbackLocaleInputType","args","extensions","complexity","resolve","parent","context","req","relatedCollectionSlug","Boolean","query","results","resultPromises","createPopulationPromise","relatedDoc","i","id","collectionSlug","result","payloadDataLoader","load","currentDepth","depth","docID","overrideAccess","showHiddenFields","transactionID","forEach","Promise","all","relatedDocument","richText","defaultDepth","editor","Error","graphQLPopulationPromises","fieldPromises","populationPromises","populateDepth","maxDepth","undefined","findMany","flattenLocales","siblingDoc","row","objectTypeConfigWithRowFields","select","tabs","tabSchema","tab","subFieldSchema","text","textarea","upload","objectSchema","fieldSchema"],"mappings":"AA4BA,SACEA,cAAc,EACdC,eAAe,EACfC,YAAY,EACZC,UAAU,EACVC,WAAW,EACXC,cAAc,EACdC,iBAAiB,EACjBC,aAAa,EACbC,gBAAgB,QACX,UAAS;AAChB,SAASC,gBAAgB,EAAEC,oBAAoB,QAAQ,kBAAiB;AACxE,SAASC,wBAAwB,EAAEC,iBAAiB,EAAEC,OAAO,QAAQ,UAAS;AAC9E,SAASC,UAAU,QAAQ,iBAAgB;AAI3C,SAASC,WAAW,QAAQ,yCAAwC;AACpE,SAASC,iBAAiB,QAAQ,oCAAmC;AACrE,SAASC,UAAU,QAAQ,6BAA4B;AACvD,SAASC,aAAa,QAAQ,gCAA+B;AAC7D,SAASC,eAAe,QAAQ,uBAAsB;AACtD,SAASC,gBAAgB,QAAQ,wBAAuB;AAgBxD,OAAO,SAASC,gBAAgB,EAC9BC,IAAI,EACJC,aAAa,CAAC,CAAC,EACfC,MAAM,EACNC,MAAM,EACNC,aAAa,EACbC,aAAa,EACbC,UAAU,EACL;IACL,MAAMC,mBAAmB;QACvB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8BAA8BQ,OAAO;wBACvC+B,KAAK/B,MAAMA,KAAK;wBAChBuB,wBAAwBvB,MAAMT,UAAU;oBAC1C;oBAEA,IAAIwC,IAAI;wBACN,MAAMc,kBAAkB,MAAMxB,QAAQC,GAAG,CAACY,iBAAiB,CAACC,IAAI,CAC9D1G,yBAAyB;4BACvBuG,gBAAgBT;4BAChBa,cAAc;4BACdC,OAAO;4BACPC,OAAOP;4BACPrB;4BACAI;4BACAF;4BACA2B,gBAAgB;4BAChBC,kBAAkB;4BAClBC,eAAepB,QAAQC,GAAG,CAACmB,aAAa;wBAC1C;wBAGF,IAAII,iBAAiB;4BACnB,IAAIrD,4BAA4B;gCAC9B,OAAO;oCACLD,YAAYgC;oCACZvB,OAAO;wCACL,GAAG6C,eAAe;wCAClB1C,YAAYoB;oCACd;gCACF;4BACF;4BAEA,OAAOsB;wBACT;wBAEA,OAAO;oBACT;oBAEA,OAAO;gBACT;YACF;YAEA,OAAO;gBACL,GAAGhG,gBAAgB;gBACnB,CAACC,MAAMV,IAAI,CAAC,EAAEkD;YAChB;QACF;IACF;IAEA,MAAM+E,eAAe;QACnBjI;QACAG,QAAQ,IACNA,OAAOoB,MAAM,CAAC,CAACd,kBAAkBC;gBAC/B,MAAMwH,cAAc3H,gBAAgB,CAACG,MAAMU,IAAI,CAAC;gBAEhD,IAAI,OAAO8G,gBAAgB,YAAY;oBACrC,OAAOzH;gBACT;gBAEA,OAAO;oBACL,GAAGA,gBAAgB;oBACnB,GAAGyH,YAAYzH,kBAAkBC,MAAM;gBACzC;YACF,GAAGT;IACP;IAEA,MAAM+D,wBAAwB,IAAIhF,kBAAkBiJ;IAEpD,OAAOjE;AACT"}
@@ -63,7 +63,7 @@ export function initCollections({ config, graphqlResult }) {
63
63
  ];
64
64
  if (!hasIDField) {
65
65
  baseFields.id = {
66
- type: new GraphQLNonNull(idType)
66
+ type: idType
67
67
  };
68
68
  whereInputFields.push({
69
69
  name: 'id',
@@ -269,7 +269,7 @@ export function initCollections({ config, graphqlResult }) {
269
269
  if (collectionConfig.versions) {
270
270
  const versionIDType = config.db.defaultIDType === 'text' ? GraphQLString : GraphQLInt;
271
271
  const versionCollectionFields = [
272
- ...buildVersionCollectionFields(config, collectionConfig),
272
+ ...buildVersionCollectionFields(collectionConfig),
273
273
  {
274
274
  name: 'id',
275
275
  type: config.db.defaultIDType
@@ -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 } from 'payload/shared'\n\nimport type { ObjectTypeConfig } from './buildObjectType.js'\n\nimport { forgotPassword } from '../resolvers/auth/forgotPassword.js'\nimport { init } from '../resolvers/auth/init.js'\nimport { login } from '../resolvers/auth/login.js'\nimport { logout } from '../resolvers/auth/logout.js'\nimport { me } from '../resolvers/auth/me.js'\nimport { refresh } from '../resolvers/auth/refresh.js'\nimport { resetPassword } from '../resolvers/auth/resetPassword.js'\nimport { unlock } from '../resolvers/auth/unlock.js'\nimport { verifyEmail } from '../resolvers/auth/verifyEmail.js'\nimport { countResolver } from '../resolvers/collections/count.js'\nimport { createResolver } from '../resolvers/collections/create.js'\nimport { getDeleteResolver } from '../resolvers/collections/delete.js'\nimport { docAccessResolver } from '../resolvers/collections/docAccess.js'\nimport { duplicateResolver } from '../resolvers/collections/duplicate.js'\nimport { findResolver } from '../resolvers/collections/find.js'\nimport { findByIDResolver } from '../resolvers/collections/findByID.js'\nimport { findVersionByIDResolver } from '../resolvers/collections/findVersionByID.js'\nimport { findVersionsResolver } from '../resolvers/collections/findVersions.js'\nimport { restoreVersionResolver } from '../resolvers/collections/restoreVersion.js'\nimport { updateResolver } from '../resolvers/collections/update.js'\nimport { formatName } from '../utilities/formatName.js'\nimport { buildMutationInputType, getCollectionIDType } from './buildMutationInputType.js'\nimport { buildObjectType } from './buildObjectType.js'\nimport { buildPaginatedListType } from './buildPaginatedListType.js'\nimport { buildPolicyType } from './buildPoliciesType.js'\nimport { buildWhereInputType } from './buildWhereInputType.js'\n\ntype InitCollectionsGraphQLArgs = {\n config: SanitizedConfig\n graphqlResult: GraphQLInfo\n}\nexport function initCollections({ config, graphqlResult }: InitCollectionsGraphQLArgs): void {\n Object.keys(graphqlResult.collections).forEach((slug) => {\n const collection: Collection = graphqlResult.collections[slug]\n const {\n config: collectionConfig,\n config: { fields, graphQL = {} as SanitizedCollectionConfig['graphQL'], versions },\n } = collection\n\n if (!graphQL) {\n return\n }\n\n let singularName\n let pluralName\n const fromSlug = formatNames(collection.config.slug)\n if (graphQL.singularName) {\n singularName = toWords(graphQL.singularName, true)\n } else {\n singularName = fromSlug.singular\n }\n if (graphQL.pluralName) {\n pluralName = toWords(graphQL.pluralName, true)\n } else {\n pluralName = fromSlug.plural\n }\n\n // For collections named 'Media' or similar,\n // there is a possibility that the singular name\n // will equal the plural name. Append `all` to the beginning\n // of potential conflicts\n if (singularName === pluralName) {\n pluralName = `all${singularName}`\n }\n\n collection.graphQL = {} as Collection['graphQL']\n\n const hasIDField =\n flattenTopLevelFields(fields).findIndex(\n (field) => fieldAffectsData(field) && field.name === 'id',\n ) > -1\n\n const idType = getCollectionIDType(config.db.defaultIDType, collectionConfig)\n\n const baseFields: ObjectTypeConfig = {}\n\n const whereInputFields = [...fields]\n\n if (!hasIDField) {\n baseFields.id = { type: new GraphQLNonNull(idType) }\n whereInputFields.push({\n name: 'id',\n type: config.db.defaultIDType as 'text',\n })\n }\n\n const forceNullableObjectType = Boolean(versions?.drafts)\n\n collection.graphQL.type = buildObjectType({\n name: singularName,\n baseFields,\n 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 if (collectionConfig.auth && !collectionConfig.auth.disableLocalStrategy) {\n fields.push({\n name: 'password',\n type: 'text',\n label: 'Password',\n required: true,\n })\n }\n\n const createMutationInputType = buildMutationInputType({\n name: singularName,\n config,\n fields,\n graphqlResult,\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: fields.filter((field) => !(fieldAffectsData(field) && field.name === 'id')),\n forceNullable: true,\n graphqlResult,\n parentName: `${singularName}Update`,\n })\n if (updateMutationInputType) {\n collection.graphQL.updateMutationInputType = new GraphQLNonNull(updateMutationInputType)\n }\n\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 },\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 sort: { type: GraphQLString },\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 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 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 },\n resolve: updateResolver(collection),\n }\n\n graphqlResult.Mutation.fields[`delete${singularName}`] = {\n type: collection.graphQL.type,\n args: {\n id: { type: new GraphQLNonNull(idType) },\n },\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 },\n resolve: duplicateResolver(collection),\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: 'Created At',\n },\n {\n name: 'updatedAt',\n type: 'date',\n label: 'Updated At',\n },\n ]\n\n collection.graphQL.versionType = buildObjectType({\n name: `${singularName}Version`,\n config,\n fields: versionCollectionFields,\n forceNullable: forceNullableObjectType,\n graphqlResult,\n parentName: `${singularName}Version`,\n })\n\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 },\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 sort: { type: GraphQLString },\n },\n resolve: findVersionsResolver(collection),\n }\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 if (collectionConfig.auth) {\n const authFields: Field[] =\n collectionConfig.auth.disableLocalStrategy ||\n (collectionConfig.auth.loginWithUsername &&\n !collectionConfig.auth.loginWithUsername.allowEmailLogin &&\n !collectionConfig.auth.loginWithUsername.requireEmail)\n ? []\n : [\n {\n name: 'email',\n type: 'email',\n required: true,\n },\n ]\n collection.graphQL.JWT = buildObjectType({\n name: formatName(`${slug}JWT`),\n config,\n fields: [\n ...collectionConfig.fields.filter((field) => fieldAffectsData(field) && field.saveToJWT),\n ...authFields,\n {\n name: 'collection',\n type: 'text',\n required: true,\n },\n ],\n graphqlResult,\n parentName: formatName(`${slug}JWT`),\n })\n\n graphqlResult.Query.fields[`me${singularName}`] = {\n type: new GraphQLObjectType({\n name: formatName(`${slug}Me`),\n fields: {\n collection: {\n type: GraphQLString,\n },\n exp: {\n type: GraphQLInt,\n },\n strategy: {\n type: GraphQLString,\n },\n token: {\n type: GraphQLString,\n },\n user: {\n type: collection.graphQL.type,\n },\n },\n }),\n resolve: me(collection),\n }\n\n graphqlResult.Query.fields[`initialized${singularName}`] = {\n type: GraphQLBoolean,\n resolve: init(collection.config.slug),\n }\n\n graphqlResult.Mutation.fields[`refreshToken${singularName}`] = {\n type: new GraphQLObjectType({\n name: formatName(`${slug}Refreshed${singularName}`),\n fields: {\n exp: {\n type: GraphQLInt,\n },\n refreshedToken: {\n type: GraphQLString,\n },\n strategy: {\n type: GraphQLString,\n },\n user: {\n type: collection.graphQL.JWT,\n },\n },\n }),\n resolve: refresh(collection),\n }\n\n graphqlResult.Mutation.fields[`logout${singularName}`] = {\n type: GraphQLString,\n resolve: logout(collection),\n }\n\n if (!collectionConfig.auth.disableLocalStrategy) {\n const authArgs = {}\n\n const canLoginWithEmail =\n !collectionConfig.auth.loginWithUsername ||\n collectionConfig.auth.loginWithUsername?.allowEmailLogin\n const canLoginWithUsername = collectionConfig.auth.loginWithUsername\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 disableEmail: { type: GraphQLBoolean },\n expiration: { type: GraphQLInt },\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"],"names":["GraphQLBoolean","GraphQLInt","GraphQLNonNull","GraphQLObjectType","GraphQLString","buildVersionCollectionFields","flattenTopLevelFields","formatNames","toWords","fieldAffectsData","forgotPassword","init","login","logout","me","refresh","resetPassword","unlock","verifyEmail","countResolver","createResolver","getDeleteResolver","docAccessResolver","duplicateResolver","findResolver","findByIDResolver","findVersionByIDResolver","findVersionsResolver","restoreVersionResolver","updateResolver","formatName","buildMutationInputType","getCollectionIDType","buildObjectType","buildPaginatedListType","buildPolicyType","buildWhereInputType","initCollections","config","graphqlResult","Object","keys","collections","forEach","slug","collection","collectionConfig","fields","graphQL","versions","singularName","pluralName","fromSlug","singular","plural","hasIDField","findIndex","field","name","idType","db","defaultIDType","baseFields","whereInputFields","id","type","push","forceNullableObjectType","Boolean","drafts","forceNullable","parentName","paginatedType","whereInputType","auth","disableLocalStrategy","label","required","createMutationInputType","mutationInputType","updateMutationInputType","filter","Query","args","draft","localization","fallbackLocale","types","fallbackLocaleInputType","locale","localeInputType","resolve","where","limit","page","sort","totalDocs","entity","scope","typeSuffix","Mutation","data","autosave","disableDuplicate","versionIDType","versionCollectionFields","versionType","authFields","loginWithUsername","allowEmailLogin","requireEmail","JWT","saveToJWT","exp","strategy","token","user","refreshedToken","authArgs","canLoginWithEmail","canLoginWithUsername","maxLoginAttempts","password","disableEmail","expiration"],"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,QAAQ,iBAAgB;AAIjD,SAASC,cAAc,QAAQ,sCAAqC;AACpE,SAASC,IAAI,QAAQ,4BAA2B;AAChD,SAASC,KAAK,QAAQ,6BAA4B;AAClD,SAASC,MAAM,QAAQ,8BAA6B;AACpD,SAASC,EAAE,QAAQ,0BAAyB;AAC5C,SAASC,OAAO,QAAQ,+BAA8B;AACtD,SAASC,aAAa,QAAQ,qCAAoC;AAClE,SAASC,MAAM,QAAQ,8BAA6B;AACpD,SAASC,WAAW,QAAQ,mCAAkC;AAC9D,SAASC,aAAa,QAAQ,oCAAmC;AACjE,SAASC,cAAc,QAAQ,qCAAoC;AACnE,SAASC,iBAAiB,QAAQ,qCAAoC;AACtE,SAASC,iBAAiB,QAAQ,wCAAuC;AACzE,SAASC,iBAAiB,QAAQ,wCAAuC;AACzE,SAASC,YAAY,QAAQ,mCAAkC;AAC/D,SAASC,gBAAgB,QAAQ,uCAAsC;AACvE,SAASC,uBAAuB,QAAQ,8CAA6C;AACrF,SAASC,oBAAoB,QAAQ,2CAA0C;AAC/E,SAASC,sBAAsB,QAAQ,6CAA4C;AACnF,SAASC,cAAc,QAAQ,qCAAoC;AACnE,SAASC,UAAU,QAAQ,6BAA4B;AACvD,SAASC,sBAAsB,EAAEC,mBAAmB,QAAQ,8BAA6B;AACzF,SAASC,eAAe,QAAQ,uBAAsB;AACtD,SAASC,sBAAsB,QAAQ,8BAA6B;AACpE,SAASC,eAAe,QAAQ,yBAAwB;AACxD,SAASC,mBAAmB,QAAQ,2BAA0B;AAM9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aAAa,CAAC;wBACvCG,QAAQ;4BACNoE,OAAO;gCAAElD,MAAM7D;4BAAc;4BAC7BgH,MAAM;gCAAEnD,MAAMpB,WAAWG,OAAO,CAACiB,IAAI;4BAAC;wBACxC;oBACF;oBACAkB,MAAM;wBACJuC,UAAU;4BAAEzD,MAAM7D;wBAAc;wBAChC+G,OAAO;4BAAElD,MAAM7D;wBAAc;oBAC/B;oBACAuF,SAAS3E,cAAc6B;gBACzB;gBAEAN,cAAc6D,QAAQ,CAACrD,MAAM,CAAC,CAAC,WAAW,EAAEG,aAAa,CAAC,CAAC,GAAG;oBAC5De,MAAMjE;oBACNmF,MAAM;wBACJgC,OAAO;4BAAElD,MAAM7D;wBAAc;oBAC/B;oBACAuF,SAASzE,YAAY2B;gBACvB;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 } from 'payload/shared'\n\nimport type { ObjectTypeConfig } from './buildObjectType.js'\n\nimport { forgotPassword } from '../resolvers/auth/forgotPassword.js'\nimport { init } from '../resolvers/auth/init.js'\nimport { login } from '../resolvers/auth/login.js'\nimport { logout } from '../resolvers/auth/logout.js'\nimport { me } from '../resolvers/auth/me.js'\nimport { refresh } from '../resolvers/auth/refresh.js'\nimport { resetPassword } from '../resolvers/auth/resetPassword.js'\nimport { unlock } from '../resolvers/auth/unlock.js'\nimport { verifyEmail } from '../resolvers/auth/verifyEmail.js'\nimport { countResolver } from '../resolvers/collections/count.js'\nimport { createResolver } from '../resolvers/collections/create.js'\nimport { getDeleteResolver } from '../resolvers/collections/delete.js'\nimport { docAccessResolver } from '../resolvers/collections/docAccess.js'\nimport { duplicateResolver } from '../resolvers/collections/duplicate.js'\nimport { findResolver } from '../resolvers/collections/find.js'\nimport { findByIDResolver } from '../resolvers/collections/findByID.js'\nimport { findVersionByIDResolver } from '../resolvers/collections/findVersionByID.js'\nimport { findVersionsResolver } from '../resolvers/collections/findVersions.js'\nimport { restoreVersionResolver } from '../resolvers/collections/restoreVersion.js'\nimport { updateResolver } from '../resolvers/collections/update.js'\nimport { formatName } from '../utilities/formatName.js'\nimport { buildMutationInputType, getCollectionIDType } from './buildMutationInputType.js'\nimport { buildObjectType } from './buildObjectType.js'\nimport { buildPaginatedListType } from './buildPaginatedListType.js'\nimport { buildPolicyType } from './buildPoliciesType.js'\nimport { buildWhereInputType } from './buildWhereInputType.js'\n\ntype InitCollectionsGraphQLArgs = {\n config: SanitizedConfig\n graphqlResult: GraphQLInfo\n}\nexport function initCollections({ config, graphqlResult }: InitCollectionsGraphQLArgs): void {\n Object.keys(graphqlResult.collections).forEach((slug) => {\n const collection: Collection = graphqlResult.collections[slug]\n const {\n config: collectionConfig,\n config: { fields, graphQL = {} as SanitizedCollectionConfig['graphQL'], versions },\n } = collection\n\n if (!graphQL) {\n return\n }\n\n let singularName\n let pluralName\n const fromSlug = formatNames(collection.config.slug)\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: idType }\n whereInputFields.push({\n name: 'id',\n type: config.db.defaultIDType as 'text',\n })\n }\n\n const forceNullableObjectType = Boolean(versions?.drafts)\n\n collection.graphQL.type = buildObjectType({\n name: singularName,\n baseFields,\n 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 if (collectionConfig.auth && !collectionConfig.auth.disableLocalStrategy) {\n fields.push({\n name: 'password',\n type: 'text',\n label: 'Password',\n required: true,\n })\n }\n\n const createMutationInputType = buildMutationInputType({\n name: singularName,\n config,\n fields,\n graphqlResult,\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: fields.filter((field) => !(fieldAffectsData(field) && field.name === 'id')),\n forceNullable: true,\n graphqlResult,\n parentName: `${singularName}Update`,\n })\n if (updateMutationInputType) {\n collection.graphQL.updateMutationInputType = new GraphQLNonNull(updateMutationInputType)\n }\n\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 },\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 sort: { type: GraphQLString },\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 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 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 },\n resolve: updateResolver(collection),\n }\n\n graphqlResult.Mutation.fields[`delete${singularName}`] = {\n type: collection.graphQL.type,\n args: {\n id: { type: new GraphQLNonNull(idType) },\n },\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 },\n resolve: duplicateResolver(collection),\n }\n }\n\n if (collectionConfig.versions) {\n const versionIDType = config.db.defaultIDType === 'text' ? GraphQLString : GraphQLInt\n const versionCollectionFields: Field[] = [\n ...buildVersionCollectionFields(collectionConfig),\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 collection.graphQL.versionType = buildObjectType({\n name: `${singularName}Version`,\n config,\n fields: versionCollectionFields,\n forceNullable: forceNullableObjectType,\n graphqlResult,\n parentName: `${singularName}Version`,\n })\n\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 },\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 sort: { type: GraphQLString },\n },\n resolve: findVersionsResolver(collection),\n }\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 if (collectionConfig.auth) {\n const authFields: Field[] =\n collectionConfig.auth.disableLocalStrategy ||\n (collectionConfig.auth.loginWithUsername &&\n !collectionConfig.auth.loginWithUsername.allowEmailLogin &&\n !collectionConfig.auth.loginWithUsername.requireEmail)\n ? []\n : [\n {\n name: 'email',\n type: 'email',\n required: true,\n },\n ]\n collection.graphQL.JWT = buildObjectType({\n name: formatName(`${slug}JWT`),\n config,\n fields: [\n ...collectionConfig.fields.filter((field) => fieldAffectsData(field) && field.saveToJWT),\n ...authFields,\n {\n name: 'collection',\n type: 'text',\n required: true,\n },\n ],\n graphqlResult,\n parentName: formatName(`${slug}JWT`),\n })\n\n graphqlResult.Query.fields[`me${singularName}`] = {\n type: new GraphQLObjectType({\n name: formatName(`${slug}Me`),\n fields: {\n collection: {\n type: GraphQLString,\n },\n exp: {\n type: GraphQLInt,\n },\n strategy: {\n type: GraphQLString,\n },\n token: {\n type: GraphQLString,\n },\n user: {\n type: collection.graphQL.type,\n },\n },\n }),\n resolve: me(collection),\n }\n\n graphqlResult.Query.fields[`initialized${singularName}`] = {\n type: GraphQLBoolean,\n resolve: init(collection.config.slug),\n }\n\n graphqlResult.Mutation.fields[`refreshToken${singularName}`] = {\n type: new GraphQLObjectType({\n name: formatName(`${slug}Refreshed${singularName}`),\n fields: {\n exp: {\n type: GraphQLInt,\n },\n refreshedToken: {\n type: GraphQLString,\n },\n strategy: {\n type: GraphQLString,\n },\n user: {\n type: collection.graphQL.JWT,\n },\n },\n }),\n resolve: refresh(collection),\n }\n\n graphqlResult.Mutation.fields[`logout${singularName}`] = {\n type: GraphQLString,\n resolve: logout(collection),\n }\n\n if (!collectionConfig.auth.disableLocalStrategy) {\n const authArgs = {}\n\n const canLoginWithEmail =\n !collectionConfig.auth.loginWithUsername ||\n collectionConfig.auth.loginWithUsername?.allowEmailLogin\n const canLoginWithUsername = collectionConfig.auth.loginWithUsername\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 disableEmail: { type: GraphQLBoolean },\n expiration: { type: GraphQLInt },\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"],"names":["GraphQLBoolean","GraphQLInt","GraphQLNonNull","GraphQLObjectType","GraphQLString","buildVersionCollectionFields","flattenTopLevelFields","formatNames","toWords","fieldAffectsData","forgotPassword","init","login","logout","me","refresh","resetPassword","unlock","verifyEmail","countResolver","createResolver","getDeleteResolver","docAccessResolver","duplicateResolver","findResolver","findByIDResolver","findVersionByIDResolver","findVersionsResolver","restoreVersionResolver","updateResolver","formatName","buildMutationInputType","getCollectionIDType","buildObjectType","buildPaginatedListType","buildPolicyType","buildWhereInputType","initCollections","config","graphqlResult","Object","keys","collections","forEach","slug","collection","collectionConfig","fields","graphQL","versions","singularName","pluralName","fromSlug","singular","plural","hasIDField","findIndex","field","name","idType","db","defaultIDType","baseFields","whereInputFields","id","type","push","forceNullableObjectType","Boolean","drafts","forceNullable","parentName","paginatedType","whereInputType","auth","disableLocalStrategy","label","required","createMutationInputType","mutationInputType","updateMutationInputType","filter","Query","args","draft","localization","fallbackLocale","types","fallbackLocaleInputType","locale","localeInputType","resolve","where","limit","page","sort","totalDocs","entity","scope","typeSuffix","Mutation","data","autosave","disableDuplicate","versionIDType","versionCollectionFields","versionType","authFields","loginWithUsername","allowEmailLogin","requireEmail","JWT","saveToJWT","exp","strategy","token","user","refreshedToken","authArgs","canLoginWithEmail","canLoginWithUsername","maxLoginAttempts","password","disableEmail","expiration"],"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,QAAQ,iBAAgB;AAIjD,SAASC,cAAc,QAAQ,sCAAqC;AACpE,SAASC,IAAI,QAAQ,4BAA2B;AAChD,SAASC,KAAK,QAAQ,6BAA4B;AAClD,SAASC,MAAM,QAAQ,8BAA6B;AACpD,SAASC,EAAE,QAAQ,0BAAyB;AAC5C,SAASC,OAAO,QAAQ,+BAA8B;AACtD,SAASC,aAAa,QAAQ,qCAAoC;AAClE,SAASC,MAAM,QAAQ,8BAA6B;AACpD,SAASC,WAAW,QAAQ,mCAAkC;AAC9D,SAASC,aAAa,QAAQ,oCAAmC;AACjE,SAASC,cAAc,QAAQ,qCAAoC;AACnE,SAASC,iBAAiB,QAAQ,qCAAoC;AACtE,SAASC,iBAAiB,QAAQ,wCAAuC;AACzE,SAASC,iBAAiB,QAAQ,wCAAuC;AACzE,SAASC,YAAY,QAAQ,mCAAkC;AAC/D,SAASC,gBAAgB,QAAQ,uCAAsC;AACvE,SAASC,uBAAuB,QAAQ,8CAA6C;AACrF,SAASC,oBAAoB,QAAQ,2CAA0C;AAC/E,SAASC,sBAAsB,QAAQ,6CAA4C;AACnF,SAASC,c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W;wBAC/B,GAAGqH,QAAQ;oBACb;oBACA3B,SAASjF,eAAemC;gBAC1B;gBAEAN,cAAc6D,QAAQ,CAACrD,MAAM,CAAC,CAAC,aAAa,EAAEG,aAAa,CAAC,CAAC,GAAG;oBAC9De,MAAM,IAAI9D,kBAAkB;wBAC1BuD,MAAM5B,WAAW,CAAC,EAAEc,KAAK,aAAa,CAAC;wBACvCG,QAAQ;4BACNoE,OAAO;gCAAElD,MAAM7D;4BAAc;4BAC7BgH,MAAM;gCAAEnD,MAAMpB,WAAWG,OAAO,CAACiB,IAAI;4BAAC;wBACxC;oBACF;oBACAkB,MAAM;wBACJuC,UAAU;4BAAEzD,MAAM7D;wBAAc;wBAChC+G,OAAO;4BAAElD,MAAM7D;wBAAc;oBAC/B;oBACAuF,SAAS3E,cAAc6B;gBACzB;gBAEAN,cAAc6D,QAAQ,CAACrD,MAAM,CAAC,CAAC,WAAW,EAAEG,aAAa,CAAC,CAAC,GAAG;oBAC5De,MAAMjE;oBACNmF,MAAM;wBACJgC,OAAO;4BAAElD,MAAM7D;wBAAc;oBAC/B;oBACAuF,SAASzE,YAAY2B;gBACvB;YACF;QACF;IACF;AACF"}
@@ -92,7 +92,7 @@ export function initGlobals({ config, graphqlResult }) {
92
92
  if (global.versions) {
93
93
  const idType = config.db.defaultIDType === 'number' ? GraphQLInt : GraphQLString;
94
94
  const versionGlobalFields = [
95
- ...buildVersionGlobalFields(config, global),
95
+ ...buildVersionGlobalFields(global),
96
96
  {
97
97
  name: 'id',
98
98
  type: config.db.defaultIDType
@@ -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'\n\nimport { docAccessResolver } from '../resolvers/globals/docAccess.js'\nimport { findOne } from '../resolvers/globals/findOne.js'\nimport { findVersionByID } from '../resolvers/globals/findVersionByID.js'\nimport { findVersions } from '../resolvers/globals/findVersions.js'\nimport { restoreVersion } from '../resolvers/globals/restoreVersion.js'\nimport { update } from '../resolvers/globals/update.js'\nimport { formatName } from '../utilities/formatName.js'\nimport { buildMutationInputType } from './buildMutationInputType.js'\nimport { buildObjectType } from './buildObjectType.js'\nimport { buildPaginatedListType } from './buildPaginatedListType.js'\nimport { buildPolicyType } from './buildPoliciesType.js'\nimport { buildWhereInputType } from './buildWhereInputType.js'\n\ntype InitGlobalsGraphQLArgs = {\n config: SanitizedConfig\n graphqlResult: GraphQLInfo\n}\nexport function initGlobals({ config, graphqlResult }: InitGlobalsGraphQLArgs): void {\n Object.keys(graphqlResult.globals.config).forEach((slug) => {\n const global: SanitizedGlobalConfig = graphqlResult.globals.config[slug]\n const { fields, graphQL, versions } = 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 = Boolean(versions?.drafts)\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 parentName: formattedName,\n })\n graphqlResult.globals.graphQL[slug] = {\n type: buildObjectType({\n name: formattedName,\n config,\n fields,\n forceNullable: forceNullableObjectType,\n graphqlResult,\n parentName: formattedName,\n }),\n mutationInputType: updateMutationInputType\n ? new GraphQLNonNull(updateMutationInputType)\n : null,\n }\n\n 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 },\n resolve: findOne(global),\n }\n\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.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 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 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 },\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 sort: { type: GraphQLString },\n },\n resolve: findVersions(global),\n }\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"],"names":["GraphQLBoolean","GraphQLInt","GraphQLNonNull","GraphQLString","pluralize","singular","buildVersionGlobalFields","toWords","docAccessResolver","findOne","findVersionByID","findVersions","restoreVersion","update","formatName","buildMutationInputType","buildObjectType","buildPaginatedListType","buildPolicyType","buildWhereInputType","initGlobals","config","graphqlResult","Object","keys","globals","forEach","slug","global","fields","graphQL","versions","formattedName","name","forceNullableObjectType","Boolean","drafts","updateMutationInputType","parentName","type","forceNullable","mutationInputType","Query","args","draft","localization","fallbackLocale","types","fallbackLocaleInputType","locale","localeInputType","resolve","Mutation","data","entity","scope","typeSuffix","idType","db","defaultIDType","versionGlobalFields","label","versionType","id","where","limit","page","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;AAE3D,SAASC,iBAAiB,QAAQ,oCAAmC;AACrE,SAASC,OAAO,QAAQ,kCAAiC;AACzD,SAASC,eAAe,QAAQ,0CAAyC;AACzE,SAASC,YAAY,QAAQ,uCAAsC;AACnE,SAASC,cAAc,QAAQ,yCAAwC;AACvE,SAASC,MAAM,QAAQ,iCAAgC;AACvD,SAASC,UAAU,QAAQ,6BAA4B;AACvD,SAASC,sBAAsB,QAAQ,8BAA6B;AACpE,SAASC,eAAe,QAAQ,uBAAsB;AACtD,SAASC,sBAAsB,QAAQ,8BAA6B;AACpE,SAASC,eAAe,QAAQ,yBAAwB;AACxD,SAASC,mBAAmB,QAA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SAASxC,aAAaiB;YACxB;YACAN,cAAc8B,QAAQ,CAACvB,MAAM,CAAC,CAAC,cAAc,EAAEf,WAAWkB,eAAe,CAAC,CAAC,GAAG;gBAC5EO,MAAMjB,cAAcG,OAAO,CAACK,OAAO,CAACH,KAAK,CAACY,IAAI;gBAC9CI,MAAM;oBACJoB,IAAI;wBAAExB,MAAMkB;oBAAO;oBACnBb,OAAO;wBAAEL,MAAMvC;oBAAe;gBAChC;gBACAmD,SAASvC,eAAegB;YAC1B;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'\n\nimport { docAccessResolver } from '../resolvers/globals/docAccess.js'\nimport { findOne } from '../resolvers/globals/findOne.js'\nimport { findVersionByID } from '../resolvers/globals/findVersionByID.js'\nimport { findVersions } from '../resolvers/globals/findVersions.js'\nimport { restoreVersion } from '../resolvers/globals/restoreVersion.js'\nimport { update } from '../resolvers/globals/update.js'\nimport { formatName } from '../utilities/formatName.js'\nimport { buildMutationInputType } from './buildMutationInputType.js'\nimport { buildObjectType } from './buildObjectType.js'\nimport { buildPaginatedListType } from './buildPaginatedListType.js'\nimport { buildPolicyType } from './buildPoliciesType.js'\nimport { buildWhereInputType } from './buildWhereInputType.js'\n\ntype InitGlobalsGraphQLArgs = {\n config: SanitizedConfig\n graphqlResult: GraphQLInfo\n}\nexport function initGlobals({ config, graphqlResult }: InitGlobalsGraphQLArgs): void {\n Object.keys(graphqlResult.globals.config).forEach((slug) => {\n const global: SanitizedGlobalConfig = graphqlResult.globals.config[slug]\n const { fields, graphQL, versions } = 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 = Boolean(versions?.drafts)\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 parentName: formattedName,\n })\n graphqlResult.globals.graphQL[slug] = {\n type: buildObjectType({\n name: formattedName,\n config,\n fields,\n forceNullable: forceNullableObjectType,\n graphqlResult,\n parentName: formattedName,\n }),\n mutationInputType: updateMutationInputType\n ? new GraphQLNonNull(updateMutationInputType)\n : null,\n }\n\n 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 },\n resolve: findOne(global),\n }\n\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.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 if (global.versions) {\n const idType = config.db.defaultIDType === 'number' ? GraphQLInt : GraphQLString\n\n const versionGlobalFields: Field[] = [\n ...buildVersionGlobalFields(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 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 },\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 sort: { type: GraphQLString },\n },\n resolve: findVersions(global),\n }\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"],"names":["GraphQLBoolean","GraphQLInt","GraphQLNonNull","GraphQLString","pluralize","singular","buildVersionGlobalFields","toWords","docAccessResolver","findOne","findVersionByID","findVersions","restoreVersion","update","formatName","buildMutationInputType","buildObjectType","buildPaginatedListType","buildPolicyType","buildWhereInputType","initGlobals","config","graphqlResult","Object","keys","globals","forEach","slug","global","fields","graphQL","versions","formattedName","name","forceNullableObjectType","Boolean","drafts","updateMutationInputType","parentName","type","forceNullable","mutationInputType","Query","args","draft","localization","fallbackLocale","types","fallbackLocaleInputType","locale","localeInputType","resolve","Mutation","data","entity","scope","typeSuffix","idType","db","defaultIDType","versionGlobalFields","label","versionType","id","where","limit","page","sort"],"mappings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kB,eAAe,CAAC,EACtCV,cAAcG,OAAO,CAACK,OAAO,CAACH,KAAK,CAACmC,WAAW;gBAEjDnB,MAAM;oBACJqB,OAAO;wBACLzB,MAAMpB,oBAAoB;4BACxBc,MAAM,CAAC,QAAQ,EAAED,cAAc,CAAC;4BAChCH,QAAQ+B;4BACRtB,YAAY,CAAC,QAAQ,EAAEN,cAAc,CAAC;wBACxC;oBACF;oBACA,GAAIX,OAAOwB,YAAY,GACnB;wBACEC,gBAAgB;4BAAEP,MAAMjB,cAAcyB,KAAK,CAACC,uBAAuB;wBAAC;wBACpEC,QAAQ;4BAAEV,MAAMjB,cAAcyB,KAAK,CAACG,eAAe;wBAAC;oBACtD,IACA,CAAC,CAAC;oBACNe,OAAO;wBAAE1B,MAAMtC;oBAAW;oBAC1BiE,MAAM;wBAAE3B,MAAMtC;oBAAW;oBACzBkE,MAAM;wBAAE5B,MAAMpC;oBAAc;gBAC9B;gBACAgD,SAASxC,aAAaiB;YACxB;YACAN,cAAc8B,QAAQ,CAACvB,MAAM,CAAC,CAAC,cAAc,EAAEf,WAAWkB,eAAe,CAAC,CAAC,GAAG;gBAC5EO,MAAMjB,cAAcG,OAAO,CAACK,OAAO,CAACH,KAAK,CAACY,IAAI;gBAC9CI,MAAM;oBACJoB,IAAI;wBAAExB,MAAMkB;oBAAO;oBACnBb,OAAO;wBAAEL,MAAMvC;oBAAe;gBAChC;gBACAmD,SAASvC,eAAegB;YAC1B;QACF;IACF;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/graphql",
3
- "version": "3.0.0-canary.0374de4",
3
+ "version": "3.0.0-canary.0992b47",
4
4
  "homepage": "https://payloadcms.com",
5
5
  "repository": {
6
6
  "type": "git",
@@ -43,11 +43,11 @@
43
43
  "@types/pluralize": "^0.0.33",
44
44
  "graphql-http": "^1.22.0",
45
45
  "@payloadcms/eslint-config": "3.0.0-beta.97",
46
- "payload": "3.0.0-canary.0374de4"
46
+ "payload": "3.0.0-canary.0992b47"
47
47
  },
48
48
  "peerDependencies": {
49
49
  "graphql": "^16.8.1",
50
- "payload": "3.0.0-canary.0374de4"
50
+ "payload": "3.0.0-canary.0992b47"
51
51
  },
52
52
  "scripts": {
53
53
  "build": "pnpm build:types && pnpm build:swc",