@payloadcms/graphql 3.23.0 → 3.24.0-canary.05013b2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/schema/buildMutationInputType.d.ts +2 -1
- package/dist/schema/buildMutationInputType.d.ts.map +1 -1
- package/dist/schema/buildMutationInputType.js +76 -13
- package/dist/schema/buildMutationInputType.js.map +1 -1
- package/dist/schema/buildObjectType.d.ts +2 -1
- package/dist/schema/buildObjectType.d.ts.map +1 -1
- package/dist/schema/buildObjectType.js +120 -26
- package/dist/schema/buildObjectType.js.map +1 -1
- package/dist/schema/initCollections.d.ts.map +1 -1
- package/dist/schema/initCollections.js +2 -0
- package/dist/schema/initCollections.js.map +1 -1
- package/dist/schema/initGlobals.d.ts.map +1 -1
- package/dist/schema/initGlobals.js +1 -0
- package/dist/schema/initGlobals.js.map +1 -1
- package/dist/schema/isFieldNullable.d.ts +5 -1
- package/dist/schema/isFieldNullable.d.ts.map +1 -1
- package/dist/schema/isFieldNullable.js +2 -2
- package/dist/schema/isFieldNullable.js.map +1 -1
- package/dist/schema/withNullableType.d.ts +6 -1
- package/dist/schema/withNullableType.d.ts.map +1 -1
- package/dist/schema/withNullableType.js +2 -2
- package/dist/schema/withNullableType.js.map +1 -1
- package/package.json +3 -3
|
@@ -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 JoinField,\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 { combineQueries, 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]: {\n type: graphqlResult.types.groupTypes[interfaceName],\n resolve: (parent, args, context: Context) => {\n return {\n ...parent[field.name],\n _id: parent._id ?? parent.id,\n }\n },\n },\n }\n },\n join: (objectTypeConfig: ObjectTypeConfig, field: JoinField) => {\n const joinName = combineParentName(parentName, toWords(field.name, true))\n\n const joinType = {\n type: new GraphQLObjectType({\n name: joinName,\n fields: {\n docs: {\n type: new GraphQLList(graphqlResult.collections[field.collection].graphQL.type),\n },\n hasNextPage: { type: GraphQLBoolean },\n },\n }),\n args: {\n limit: {\n type: GraphQLInt,\n },\n sort: {\n type: GraphQLString,\n },\n where: {\n type: graphqlResult.collections[field.collection].graphQL.whereInputType,\n },\n },\n extensions: {\n complexity:\n typeof field?.graphQL?.complexity === 'number' ? field.graphQL.complexity : 10,\n },\n async resolve(parent, args, context: Context) {\n const { collection } = field\n const { limit, sort, where } = args\n const { req } = context\n\n const fullWhere = combineQueries(where, {\n [field.on]: { equals: parent._id ?? parent.id },\n })\n\n return await req.payload.find({\n collection,\n depth: 0,\n fallbackLocale: req.fallbackLocale,\n limit,\n locale: req.locale,\n overrideAccess: false,\n req,\n sort,\n where: fullWhere,\n })\n },\n }\n\n return {\n ...objectTypeConfig,\n [field.name]: joinType,\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: {\n complexity:\n typeof field?.graphQL?.complexity === 'number' ? field.graphQL.complexity : 10,\n },\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 const isValidGraphQLCollection = isRelatedToManyCollections\n ? graphQLCollections.some((collection) => collectionSlug.includes(collection.slug))\n : graphQLCollections.some((collection) => collectionSlug === collection.slug)\n\n if (isValidGraphQLCollection) {\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]: {\n type: graphqlResult.types.groupTypes[interfaceName],\n resolve(parent, args, context: Context) {\n return {\n ...parent[tab.name],\n _id: parent._id ?? parent.id,\n }\n },\n },\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: {\n complexity:\n typeof field?.graphQL?.complexity === 'number' ? field.graphQL.complexity : 10,\n },\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","combineQueries","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","resolve","parent","args","context","_id","id","join","joinName","joinType","docs","collections","collection","hasNextPage","limit","sort","where","whereInputType","extensions","complexity","req","fullWhere","on","equals","payload","find","depth","fallbackLocale","locale","overrideAccess","json","number","hasMany","point","radio","values","relationship","relationTo","isRelatedToManyCollections","Array","isArray","hasManyValues","relationshipName","relationToType","graphQLCollections","filter","collectionConfig","relation","some","relations","value","map","newlyCreatedBlockType","relationshipArgs","relationsUseDrafts","versions","drafts","draft","localization","localeInputType","fallbackLocaleInputType","relatedCollectionSlug","Boolean","query","results","resultPromises","createPopulationPromise","relatedDoc","i","collectionSlug","isValidGraphQLCollection","includes","result","payloadDataLoader","load","currentDepth","docID","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":"AA6BA,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,cAAc,EAAEC,wBAAwB,EAAEC,iBAAiB,EAAEC,OAAO,QAAQ,UAAS;AAC9F,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;AACt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,GAAGT;IACP;IAEA,MAAM8F,wBAAwB,IAAIhH,kBAAkBsK;IAEpD,OAAOtD;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 JoinField,\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 { combineQueries, 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 parentIsLocalized?: boolean\n parentName: string\n}\n\nexport function buildObjectType({\n name,\n baseFields = {},\n config,\n fields,\n forceNullable,\n graphqlResult,\n parentIsLocalized,\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, parentIsLocalized }),\n graphqlResult,\n parentIsLocalized: field.localized || parentIsLocalized,\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({ type: arrayType, field, parentIsLocalized }) },\n }\n },\n blocks: (objectTypeConfig: ObjectTypeConfig, field: BlocksField) => {\n const blockTypes: GraphQLObjectType<any, any>[] = (\n field.blockReferences ?? field.blocks\n ).reduce((acc, _block) => {\n const blockSlug = typeof _block === 'string' ? _block : _block.slug\n if (!graphqlResult.types.blockTypes[blockSlug]) {\n // TODO: iterate over blocks mapped to block slug in v4, or pass through payload.blocks\n const block =\n typeof _block === 'string' ? config.blocks.find((b) => b.slug === _block) : _block\n\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 parentIsLocalized,\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[blockSlug]) {\n acc.push(graphqlResult.types.blockTypes[blockSlug])\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({ type, field, parentIsLocalized }) },\n }\n },\n checkbox: (objectTypeConfig: ObjectTypeConfig, field: CheckboxField) => ({\n ...objectTypeConfig,\n [field.name]: {\n type: withNullableType({ type: GraphQLBoolean, field, forceNullable, parentIsLocalized }),\n },\n }),\n code: (objectTypeConfig: ObjectTypeConfig, field: CodeField) => ({\n ...objectTypeConfig,\n [field.name]: {\n type: withNullableType({ type: GraphQLString, field, forceNullable, parentIsLocalized }),\n },\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]: {\n type: withNullableType({ type: DateTimeResolver, field, forceNullable, parentIsLocalized }),\n },\n }),\n email: (objectTypeConfig: ObjectTypeConfig, field: EmailField) => ({\n ...objectTypeConfig,\n [field.name]: {\n type: withNullableType({\n type: EmailAddressResolver,\n field,\n forceNullable,\n parentIsLocalized,\n }),\n },\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, parentIsLocalized }),\n graphqlResult,\n parentIsLocalized: field.localized || parentIsLocalized,\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]: {\n type: graphqlResult.types.groupTypes[interfaceName],\n resolve: (parent, args, context: Context) => {\n return {\n ...parent[field.name],\n _id: parent._id ?? parent.id,\n }\n },\n },\n }\n },\n join: (objectTypeConfig: ObjectTypeConfig, field: JoinField) => {\n const joinName = combineParentName(parentName, toWords(field.name, true))\n\n const joinType = {\n type: new GraphQLObjectType({\n name: joinName,\n fields: {\n docs: {\n type: new GraphQLList(graphqlResult.collections[field.collection].graphQL.type),\n },\n hasNextPage: { type: GraphQLBoolean },\n },\n }),\n args: {\n limit: {\n type: GraphQLInt,\n },\n sort: {\n type: GraphQLString,\n },\n where: {\n type: graphqlResult.collections[field.collection].graphQL.whereInputType,\n },\n },\n extensions: {\n complexity:\n typeof field?.graphQL?.complexity === 'number' ? field.graphQL.complexity : 10,\n },\n async resolve(parent, args, context: Context) {\n const { collection } = field\n const { limit, sort, where } = args\n const { req } = context\n\n const fullWhere = combineQueries(where, {\n [field.on]: { equals: parent._id ?? parent.id },\n })\n\n return await req.payload.find({\n collection,\n depth: 0,\n fallbackLocale: req.fallbackLocale,\n limit,\n locale: req.locale,\n overrideAccess: false,\n req,\n sort,\n where: fullWhere,\n })\n },\n }\n\n return {\n ...objectTypeConfig,\n [field.name]: joinType,\n }\n },\n json: (objectTypeConfig: ObjectTypeConfig, field: JSONField) => ({\n ...objectTypeConfig,\n [field.name]: {\n type: withNullableType({ type: GraphQLJSON, field, forceNullable, parentIsLocalized }),\n },\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 type: field?.hasMany === true ? new GraphQLList(type) : type,\n field,\n forceNullable,\n parentIsLocalized,\n }),\n },\n }\n },\n point: (objectTypeConfig: ObjectTypeConfig, field: PointField) => ({\n ...objectTypeConfig,\n [field.name]: {\n type: withNullableType({\n type: new GraphQLList(new GraphQLNonNull(GraphQLFloat)),\n field,\n forceNullable,\n parentIsLocalized,\n }),\n },\n }),\n radio: (objectTypeConfig: ObjectTypeConfig, field: RadioField) => ({\n ...objectTypeConfig,\n [field.name]: {\n type: withNullableType({\n type: new GraphQLEnumType({\n name: combineParentName(parentName, field.name),\n values: formatOptions(field),\n }),\n field,\n forceNullable,\n parentIsLocalized,\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 type: hasManyValues ? new GraphQLList(new GraphQLNonNull(type)) : type,\n field,\n forceNullable,\n parentIsLocalized,\n }),\n args: relationshipArgs,\n extensions: {\n complexity:\n typeof field?.graphQL?.complexity === 'number' ? field.graphQL.complexity : 10,\n },\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 const isValidGraphQLCollection = isRelatedToManyCollections\n ? graphQLCollections.some((collection) => collectionSlug.includes(collection.slug))\n : graphQLCollections.some((collection) => collectionSlug === collection.slug)\n\n if (isValidGraphQLCollection) {\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({ type: GraphQLJSON, field, forceNullable, parentIsLocalized }),\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 parentIsLocalized,\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({ type, field, forceNullable, parentIsLocalized })\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 parentIsLocalized: tab.localized || parentIsLocalized,\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]: {\n type: graphqlResult.types.groupTypes[interfaceName],\n resolve(parent, args, context: Context) {\n return {\n ...parent[tab.name],\n _id: parent._id ?? parent.id,\n }\n },\n },\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 type: field.hasMany === true ? new GraphQLList(GraphQLString) : GraphQLString,\n field,\n forceNullable,\n parentIsLocalized,\n }),\n },\n }),\n textarea: (objectTypeConfig: ObjectTypeConfig, field: TextareaField) => ({\n ...objectTypeConfig,\n [field.name]: {\n type: withNullableType({ type: GraphQLString, field, forceNullable, parentIsLocalized }),\n },\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 type: hasManyValues ? new GraphQLList(new GraphQLNonNull(type)) : type,\n field,\n forceNullable,\n parentIsLocalized,\n }),\n args: relationshipArgs,\n extensions: {\n complexity:\n typeof field?.graphQL?.complexity === 'number' ? field.graphQL.complexity : 10,\n },\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","combineQueries","createDataloaderCacheKey","MissingEditorProp","toWords","tabHasName","GraphQLJSON","combineParentName","formatName","formatOptions","isFieldNullable","withNullableType","buildObjectType","name","baseFields","config","fields","forceNullable","graphqlResult","parentIsLocalized","parentName","fieldToSchemaMap","array","objectTypeConfig","field","interfaceName","types","arrayTypes","objectType","localized","Object","keys","getFields","length","arrayType","type","blocks","blockTypes","blockReferences","reduce","acc","_block","blockSlug","slug","block","find","b","graphQL","singularName","push","fullName","resolveType","data","blockType","checkbox","code","collapsible","objectTypeConfigWithCollapsibleFields","subField","addSubField","date","email","group","groupTypes","resolve","parent","args","context","_id","id","join","joinName","joinType","docs","collections","collection","hasNextPage","limit","sort","where","whereInputType","extensions","complexity","req","fullWhere","on","equals","payload","depth","fallbackLocale","locale","overrideAccess","json","number","hasMany","point","radio","values","relationship","relationTo","isRelatedToManyCollections","Array","isArray","hasManyValues","relationshipName","relationToType","graphQLCollections","filter","collectionConfig","relation","some","relations","value","map","newlyCreatedBlockType","relationshipArgs","relationsUseDrafts","versions","drafts","draft","localization","localeInputType","fallbackLocaleInputType","relatedCollectionSlug","Boolean","query","results","resultPromises","createPopulationPromise","relatedDoc","i","collectionSlug","isValidGraphQLCollection","includes","result","payloadDataLoader","load","currentDepth","docID","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":"AA6BA,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,cAAc,EAAEC,wBAAwB,EAAEC,iBAAiB,EAAEC,OAAO,QAAQ,UAAS;AAC9F,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;AAiBxD,OAAO,SAASC,gBAAgB,EAC9BC,IAAI,EACJC,aAAa,CAAC,CAAC,EAC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QgB,GAAG,CAACoD,iBAAiB,CAACC,IAAI,CAC9DtI,yBAAyB;4BACvBiI,gBAAgBR;4BAChBc,cAAc;4BACdjD,OAAO;4BACPkD,OAAOrE;4BACPkD;4BACA9B;4BACAC;4BACAC,gBAAgB;4BAChBgD,kBAAkB;4BAClBC,eAAezE,QAAQgB,GAAG,CAACyD,aAAa;wBAC1C;wBAGF,IAAII,iBAAiB;4BACnB,IAAI5C,4BAA4B;gCAC9B,OAAO;oCACLD,YAAYwB;oCACZX,OAAO;wCACL,GAAGgC,eAAe;wCAClBrE,YAAYgD;oCACd;gCACF;4BACF;4BAEA,OAAOqB;wBACT;wBAEA,OAAO;oBACT;oBAEA,OAAO;gBACT;YACF;YAEA,OAAO;gBACL,GAAGzH,gBAAgB;gBACnB,CAACC,MAAMX,IAAI,CAAC,EAAEqF;YAChB;QACF;IACF;IAEA,MAAMsE,eAAe;QACnB3J;QACAG,QAAQ,IACNA,OAAOuB,MAAM,CAAC,CAAChB,kBAAkBC;gBAC/B,MAAMiJ,cAAcpJ,gBAAgB,CAACG,MAAMW,IAAI,CAAC;gBAEhD,IAAI,OAAOsI,gBAAgB,YAAY;oBACrC,OAAOlJ;gBACT;gBAEA,OAAO;oBACL,GAAGA,gBAAgB;oBACnB,GAAGkJ,YAAYlJ,kBAAkBC,MAAM;gBACzC;YACF,GAAGV;IACP;IAEA,MAAMoG,wBAAwB,IAAItH,kBAAkB4K;IAEpD,OAAOtD;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initCollections.d.ts","sourceRoot":"","sources":["../../src/schema/initCollections.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,WAAW,EAEX,eAAe,EAChB,MAAM,SAAS,CAAA;AAyChB,KAAK,0BAA0B,GAAG;IAChC,MAAM,EAAE,eAAe,CAAA;IACvB,aAAa,EAAE,WAAW,CAAA;CAC3B,CAAA;AACD,wBAAgB,eAAe,CAAC,EAAE,MAAM,EAAE,aAAa,EAAE,EAAE,0BAA0B,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"initCollections.d.ts","sourceRoot":"","sources":["../../src/schema/initCollections.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,WAAW,EAEX,eAAe,EAChB,MAAM,SAAS,CAAA;AAyChB,KAAK,0BAA0B,GAAG;IAChC,MAAM,EAAE,eAAe,CAAA;IACvB,aAAa,EAAE,WAAW,CAAA;CAC3B,CAAA;AACD,wBAAgB,eAAe,CAAC,EAAE,MAAM,EAAE,aAAa,EAAE,EAAE,0BAA0B,GAAG,IAAI,CAwf3F"}
|
|
@@ -102,6 +102,7 @@ export function initCollections({ config, graphqlResult }) {
|
|
|
102
102
|
config,
|
|
103
103
|
fields: mutationInputFields,
|
|
104
104
|
graphqlResult,
|
|
105
|
+
parentIsLocalized: false,
|
|
105
106
|
parentName: singularName
|
|
106
107
|
});
|
|
107
108
|
if (createMutationInputType) {
|
|
@@ -113,6 +114,7 @@ export function initCollections({ config, graphqlResult }) {
|
|
|
113
114
|
fields: mutationInputFields.filter((field)=>!(fieldAffectsData(field) && field.name === 'id')),
|
|
114
115
|
forceNullable: true,
|
|
115
116
|
graphqlResult,
|
|
117
|
+
parentIsLocalized: false,
|
|
116
118
|
parentName: `${singularName}Update`
|
|
117
119
|
});
|
|
118
120
|
if (updateMutationInputType) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/schema/initCollections.ts"],"sourcesContent":["import type {\n Collection,\n Field,\n GraphQLInfo,\n SanitizedCollectionConfig,\n SanitizedConfig,\n} from 'payload'\n\nimport {\n GraphQLBoolean,\n GraphQLInt,\n GraphQLNonNull,\n GraphQLObjectType,\n GraphQLString,\n} from 'graphql'\nimport { buildVersionCollectionFields, flattenTopLevelFields, formatNames, toWords } from 'payload'\nimport { fieldAffectsData, getLoginOptions } from 'payload/shared'\n\nimport type { ObjectTypeConfig } from './buildObjectType.js'\n\nimport { forgotPassword } from '../resolvers/auth/forgotPassword.js'\nimport { init } from '../resolvers/auth/init.js'\nimport { login } from '../resolvers/auth/login.js'\nimport { logout } from '../resolvers/auth/logout.js'\nimport { me } from '../resolvers/auth/me.js'\nimport { refresh } from '../resolvers/auth/refresh.js'\nimport { resetPassword } from '../resolvers/auth/resetPassword.js'\nimport { unlock } from '../resolvers/auth/unlock.js'\nimport { verifyEmail } from '../resolvers/auth/verifyEmail.js'\nimport { countResolver } from '../resolvers/collections/count.js'\nimport { createResolver } from '../resolvers/collections/create.js'\nimport { getDeleteResolver } from '../resolvers/collections/delete.js'\nimport { docAccessResolver } from '../resolvers/collections/docAccess.js'\nimport { duplicateResolver } from '../resolvers/collections/duplicate.js'\nimport { findResolver } from '../resolvers/collections/find.js'\nimport { findByIDResolver } from '../resolvers/collections/findByID.js'\nimport { findVersionByIDResolver } from '../resolvers/collections/findVersionByID.js'\nimport { findVersionsResolver } from '../resolvers/collections/findVersions.js'\nimport { 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\n const fromSlug = formatNames(collection.config.slug)\n\n if (graphQL.singularName) {\n singularName = toWords(graphQL.singularName, true)\n } else {\n singularName = fromSlug.singular\n }\n if (graphQL.pluralName) {\n pluralName = toWords(graphQL.pluralName, true)\n } else {\n pluralName = fromSlug.plural\n }\n\n // For collections named 'Media' or similar,\n // there is a possibility that the singular name\n // will equal the plural name. Append `all` to the beginning\n // of potential conflicts\n if (singularName === pluralName) {\n pluralName = `all${singularName}`\n }\n\n collection.graphQL = {} as Collection['graphQL']\n\n const hasIDField =\n flattenTopLevelFields(fields).findIndex(\n (field) => fieldAffectsData(field) && field.name === 'id',\n ) > -1\n\n const idType = getCollectionIDType(config.db.defaultIDType, collectionConfig)\n\n const baseFields: ObjectTypeConfig = {}\n\n const whereInputFields = [...fields]\n\n if (!hasIDField) {\n baseFields.id = { type: new GraphQLNonNull(idType) }\n whereInputFields.push({\n name: 'id',\n type: config.db.defaultIDType as 'text',\n })\n }\n\n 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 const mutationInputFields = [...fields]\n\n if (\n collectionConfig.auth &&\n (!collectionConfig.auth.disableLocalStrategy ||\n (typeof collectionConfig.auth.disableLocalStrategy === 'object' &&\n collectionConfig.auth.disableLocalStrategy.optionalPassword))\n ) {\n mutationInputFields.push({\n name: 'password',\n type: 'text',\n label: 'Password',\n required: !(\n typeof collectionConfig.auth.disableLocalStrategy === 'object' &&\n collectionConfig.auth.disableLocalStrategy.optionalPassword\n ),\n })\n }\n\n const createMutationInputType = buildMutationInputType({\n name: singularName,\n config,\n fields: mutationInputFields,\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: mutationInputFields.filter(\n (field) => !(fieldAffectsData(field) && field.name === 'id'),\n ),\n forceNullable: true,\n graphqlResult,\n parentName: `${singularName}Update`,\n })\n if (updateMutationInputType) {\n collection.graphQL.updateMutationInputType = new GraphQLNonNull(updateMutationInputType)\n }\n\n const queriesEnabled =\n typeof collectionConfig.graphQL !== 'object' || !collectionConfig.graphQL.disableQueries\n const mutationsEnabled =\n typeof collectionConfig.graphQL !== 'object' || !collectionConfig.graphQL.disableMutations\n\n if (queriesEnabled) {\n graphqlResult.Query.fields[singularName] = {\n type: collection.graphQL.type,\n args: {\n id: { type: new GraphQLNonNull(idType) },\n draft: { type: GraphQLBoolean },\n ...(config.localization\n ? {\n fallbackLocale: { type: graphqlResult.types.fallbackLocaleInputType },\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n },\n resolve: findByIDResolver(collection),\n }\n\n graphqlResult.Query.fields[pluralName] = {\n type: buildPaginatedListType(pluralName, collection.graphQL.type),\n args: {\n draft: { type: GraphQLBoolean },\n where: { type: collection.graphQL.whereInputType },\n ...(config.localization\n ? {\n fallbackLocale: { type: graphqlResult.types.fallbackLocaleInputType },\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n limit: { type: GraphQLInt },\n page: { type: GraphQLInt },\n pagination: { type: GraphQLBoolean },\n 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\n if (mutationsEnabled) {\n graphqlResult.Mutation.fields[`create${singularName}`] = {\n type: collection.graphQL.type,\n args: {\n ...(createMutationInputType\n ? { data: { type: collection.graphQL.mutationInputType } }\n : {}),\n draft: { type: GraphQLBoolean },\n ...(config.localization\n ? {\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n },\n resolve: createResolver(collection),\n }\n\n graphqlResult.Mutation.fields[`update${singularName}`] = {\n type: collection.graphQL.type,\n args: {\n id: { type: new GraphQLNonNull(idType) },\n autosave: { type: GraphQLBoolean },\n ...(updateMutationInputType\n ? { data: { type: collection.graphQL.updateMutationInputType } }\n : {}),\n draft: { type: GraphQLBoolean },\n ...(config.localization\n ? {\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n },\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 ...(createMutationInputType\n ? { data: { type: collection.graphQL.mutationInputType } }\n : {}),\n },\n resolve: duplicateResolver(collection),\n }\n }\n }\n\n if (collectionConfig.versions) {\n const versionIDType = config.db.defaultIDType === 'text' ? GraphQLString : GraphQLInt\n const versionCollectionFields: Field[] = [\n ...buildVersionCollectionFields(config, collectionConfig),\n {\n name: 'id',\n type: config.db.defaultIDType as 'text',\n },\n {\n name: 'createdAt',\n type: 'date',\n label: '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 if (queriesEnabled) {\n graphqlResult.Query.fields[`version${formatName(singularName)}`] = {\n type: collection.graphQL.versionType,\n args: {\n id: { type: versionIDType },\n ...(config.localization\n ? {\n fallbackLocale: { type: graphqlResult.types.fallbackLocaleInputType },\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n },\n resolve: findVersionByIDResolver(collection),\n }\n graphqlResult.Query.fields[`versions${pluralName}`] = {\n type: buildPaginatedListType(\n `versions${formatName(pluralName)}`,\n collection.graphQL.versionType,\n ),\n args: {\n where: {\n type: buildWhereInputType({\n name: `versions${singularName}`,\n fields: versionCollectionFields,\n parentName: `versions${singularName}`,\n }),\n },\n ...(config.localization\n ? {\n fallbackLocale: { type: graphqlResult.types.fallbackLocaleInputType },\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n limit: { type: GraphQLInt },\n page: { type: GraphQLInt },\n pagination: { type: GraphQLBoolean },\n sort: { type: GraphQLString },\n },\n resolve: findVersionsResolver(collection),\n }\n }\n\n if (mutationsEnabled) {\n graphqlResult.Mutation.fields[`restoreVersion${formatName(singularName)}`] = {\n type: collection.graphQL.type,\n args: {\n id: { type: versionIDType },\n draft: { type: GraphQLBoolean },\n },\n resolve: restoreVersionResolver(collection),\n }\n }\n }\n\n if (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 if (queriesEnabled) {\n graphqlResult.Query.fields[`me${singularName}`] = {\n type: new GraphQLObjectType({\n name: formatName(`${slug}Me`),\n fields: {\n collection: {\n type: GraphQLString,\n },\n exp: {\n type: GraphQLInt,\n },\n 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\n if (mutationsEnabled) {\n graphqlResult.Mutation.fields[`refreshToken${singularName}`] = {\n type: new GraphQLObjectType({\n name: formatName(`${slug}Refreshed${singularName}`),\n fields: {\n exp: {\n type: GraphQLInt,\n },\n refreshedToken: {\n type: GraphQLString,\n },\n 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, canLoginWithUsername } = getLoginOptions(\n collectionConfig.auth.loginWithUsername,\n )\n\n if (canLoginWithEmail) {\n authArgs['email'] = { type: new GraphQLNonNull(GraphQLString) }\n }\n if (canLoginWithUsername) {\n authArgs['username'] = { type: new GraphQLNonNull(GraphQLString) }\n }\n\n if (collectionConfig.auth.maxLoginAttempts > 0) {\n graphqlResult.Mutation.fields[`unlock${singularName}`] = {\n type: new GraphQLNonNull(GraphQLBoolean),\n args: authArgs,\n resolve: unlock(collection),\n }\n }\n\n graphqlResult.Mutation.fields[`login${singularName}`] = {\n type: new GraphQLObjectType({\n name: formatName(`${slug}LoginResult`),\n fields: {\n exp: {\n type: GraphQLInt,\n },\n token: {\n type: GraphQLString,\n },\n user: {\n type: collection.graphQL.type,\n },\n },\n }),\n args: {\n ...authArgs,\n password: { type: GraphQLString },\n },\n resolve: login(collection),\n }\n\n graphqlResult.Mutation.fields[`forgotPassword${singularName}`] = {\n type: new GraphQLNonNull(GraphQLBoolean),\n args: {\n 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}\n"],"names":["GraphQLBoolean","GraphQLInt","GraphQLNonNull","GraphQLObjectType","GraphQLString","buildVersionCollectionFields","flattenTopLevelFields","formatNames","toWords","fieldAffectsData","getLoginOptions","forgotPassword","init","login","logout","me","refresh","resetPassword","unlock","verifyEmail","countResolver","createResolver","getDeleteResolver","docAccessResolver","duplicateResolver","findResolver","findByIDResolver","findVersionByIDResolver","findVersionsResolver","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","mutationInputFields","auth","disableLocalStrategy","optionalPassword","label","required","createMutationInputType","mutationInputType","updateMutationInputType","filter","queriesEnabled","disableQueries","mutationsEnabled","disableMutations","Query","args","draft","localization","fallbackLocale","types","fallbackLocaleInputType","locale","localeInputType","resolve","where","limit","page","pagination","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,EAAEC,eAAe,QAAQ,iBAAgB;AAIlE,SAASC,cAAc,QAAQ,sCAAqC;AACpE,SAASC,IAAI,QAAQ,4BAA2B;AAChD,SAASC,KAAK,QAAQ,6BAA4B;AAClD,SAASC,MAAM,QAAQ,8BAA6B;AACpD,SAASC,EAAE,QAAQ,0BAAyB;AAC5C,SAASC,OAAO,QAAQ,+BAA8B;AACtD,SAASC,aAAa,QAAQ,qCAAoC;AAClE,SAASC,MAAM,QAAQ,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,2BAA0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0H,OAAO;oCACLzD,MAAM9D;gCACR;gCACAwH,MAAM;oCACJ1D,MAAMpB,WAAWG,OAAO,CAACiB,IAAI;gCAC/B;4BACF;wBACF;wBACAwB,MAAM;4BACJ,GAAGoC,QAAQ;4BACXI,UAAU;gCAAEhE,MAAM9D;4BAAc;wBAClC;wBACA8F,SAASrF,MAAMiC;oBACjB;oBAEAN,cAAcoE,QAAQ,CAAC5D,MAAM,CAAC,CAAC,cAAc,EAAEG,cAAc,CAAC,GAAG;wBAC/De,MAAM,IAAIhE,eAAeF;wBACzB0F,MAAM;4BACJyC,cAAc;gCAAEjE,MAAMlE;4BAAe;4BACrCoI,YAAY;gCAAElE,MAAMjE;4BAAW;4BAC/B,GAAG6H,QAAQ;wBACb;wBACA5B,SAASvF,eAAemC;oBAC1B;oBAEAN,cAAcoE,QAAQ,CAAC5D,MAAM,CAAC,CAAC,aAAa,EAAEG,cAAc,CAAC,GAAG;wBAC9De,MAAM,IAAI/D,kBAAkB;4BAC1BwD,MAAM5B,WAAW,GAAGc,KAAK,aAAa,CAAC;4BACvCG,QAAQ;gCACN2E,OAAO;oCAAEzD,MAAM9D;gCAAc;gCAC7BwH,MAAM;oCAAE1D,MAAMpB,WAAWG,OAAO,CAACiB,IAAI;gCAAC;4BACxC;wBACF;wBACAwB,MAAM;4BACJwC,UAAU;gCAAEhE,MAAM9D;4BAAc;4BAChCuH,OAAO;gCAAEzD,MAAM9D;4BAAc;wBAC/B;wBACA8F,SAASjF,cAAc6B;oBACzB;oBAEAN,cAAcoE,QAAQ,CAAC5D,MAAM,CAAC,CAAC,WAAW,EAAEG,cAAc,CAAC,GAAG;wBAC5De,MAAMlE;wBACN0F,MAAM;4BACJiC,OAAO;gCAAEzD,MAAM9D;4BAAc;wBAC/B;wBACA8F,SAAS/E,YAAY2B;oBACvB;gBACF;YACF;QACF;IACF;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../src/schema/initCollections.ts"],"sourcesContent":["import type {\n Collection,\n Field,\n GraphQLInfo,\n SanitizedCollectionConfig,\n SanitizedConfig,\n} from 'payload'\n\nimport {\n GraphQLBoolean,\n GraphQLInt,\n GraphQLNonNull,\n GraphQLObjectType,\n GraphQLString,\n} from 'graphql'\nimport { buildVersionCollectionFields, flattenTopLevelFields, formatNames, toWords } from 'payload'\nimport { fieldAffectsData, getLoginOptions } from 'payload/shared'\n\nimport type { ObjectTypeConfig } from './buildObjectType.js'\n\nimport { forgotPassword } from '../resolvers/auth/forgotPassword.js'\nimport { init } from '../resolvers/auth/init.js'\nimport { login } from '../resolvers/auth/login.js'\nimport { logout } from '../resolvers/auth/logout.js'\nimport { me } from '../resolvers/auth/me.js'\nimport { refresh } from '../resolvers/auth/refresh.js'\nimport { resetPassword } from '../resolvers/auth/resetPassword.js'\nimport { unlock } from '../resolvers/auth/unlock.js'\nimport { verifyEmail } from '../resolvers/auth/verifyEmail.js'\nimport { countResolver } from '../resolvers/collections/count.js'\nimport { createResolver } from '../resolvers/collections/create.js'\nimport { getDeleteResolver } from '../resolvers/collections/delete.js'\nimport { docAccessResolver } from '../resolvers/collections/docAccess.js'\nimport { duplicateResolver } from '../resolvers/collections/duplicate.js'\nimport { findResolver } from '../resolvers/collections/find.js'\nimport { findByIDResolver } from '../resolvers/collections/findByID.js'\nimport { findVersionByIDResolver } from '../resolvers/collections/findVersionByID.js'\nimport { findVersionsResolver } from '../resolvers/collections/findVersions.js'\nimport { 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\n const fromSlug = formatNames(collection.config.slug)\n\n if (graphQL.singularName) {\n singularName = toWords(graphQL.singularName, true)\n } else {\n singularName = fromSlug.singular\n }\n if (graphQL.pluralName) {\n pluralName = toWords(graphQL.pluralName, true)\n } else {\n pluralName = fromSlug.plural\n }\n\n // For collections named 'Media' or similar,\n // there is a possibility that the singular name\n // will equal the plural name. Append `all` to the beginning\n // of potential conflicts\n if (singularName === pluralName) {\n pluralName = `all${singularName}`\n }\n\n collection.graphQL = {} as Collection['graphQL']\n\n const hasIDField =\n flattenTopLevelFields(fields).findIndex(\n (field) => fieldAffectsData(field) && field.name === 'id',\n ) > -1\n\n const idType = getCollectionIDType(config.db.defaultIDType, collectionConfig)\n\n const baseFields: ObjectTypeConfig = {}\n\n const whereInputFields = [...fields]\n\n if (!hasIDField) {\n baseFields.id = { type: new GraphQLNonNull(idType) }\n whereInputFields.push({\n name: 'id',\n type: config.db.defaultIDType as 'text',\n })\n }\n\n 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 const mutationInputFields = [...fields]\n\n if (\n collectionConfig.auth &&\n (!collectionConfig.auth.disableLocalStrategy ||\n (typeof collectionConfig.auth.disableLocalStrategy === 'object' &&\n collectionConfig.auth.disableLocalStrategy.optionalPassword))\n ) {\n mutationInputFields.push({\n name: 'password',\n type: 'text',\n label: 'Password',\n required: !(\n typeof collectionConfig.auth.disableLocalStrategy === 'object' &&\n collectionConfig.auth.disableLocalStrategy.optionalPassword\n ),\n })\n }\n\n const createMutationInputType = buildMutationInputType({\n name: singularName,\n config,\n fields: mutationInputFields,\n graphqlResult,\n parentIsLocalized: false,\n parentName: singularName,\n })\n if (createMutationInputType) {\n collection.graphQL.mutationInputType = new GraphQLNonNull(createMutationInputType)\n }\n\n const updateMutationInputType = buildMutationInputType({\n name: `${singularName}Update`,\n config,\n fields: mutationInputFields.filter(\n (field) => !(fieldAffectsData(field) && field.name === 'id'),\n ),\n forceNullable: true,\n graphqlResult,\n parentIsLocalized: false,\n parentName: `${singularName}Update`,\n })\n if (updateMutationInputType) {\n collection.graphQL.updateMutationInputType = new GraphQLNonNull(updateMutationInputType)\n }\n\n const queriesEnabled =\n typeof collectionConfig.graphQL !== 'object' || !collectionConfig.graphQL.disableQueries\n const mutationsEnabled =\n typeof collectionConfig.graphQL !== 'object' || !collectionConfig.graphQL.disableMutations\n\n if (queriesEnabled) {\n graphqlResult.Query.fields[singularName] = {\n type: collection.graphQL.type,\n args: {\n id: { type: new GraphQLNonNull(idType) },\n draft: { type: GraphQLBoolean },\n ...(config.localization\n ? {\n fallbackLocale: { type: graphqlResult.types.fallbackLocaleInputType },\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n },\n resolve: findByIDResolver(collection),\n }\n\n graphqlResult.Query.fields[pluralName] = {\n type: buildPaginatedListType(pluralName, collection.graphQL.type),\n args: {\n draft: { type: GraphQLBoolean },\n where: { type: collection.graphQL.whereInputType },\n ...(config.localization\n ? {\n fallbackLocale: { type: graphqlResult.types.fallbackLocaleInputType },\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n limit: { type: GraphQLInt },\n page: { type: GraphQLInt },\n pagination: { type: GraphQLBoolean },\n 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\n if (mutationsEnabled) {\n graphqlResult.Mutation.fields[`create${singularName}`] = {\n type: collection.graphQL.type,\n args: {\n ...(createMutationInputType\n ? { data: { type: collection.graphQL.mutationInputType } }\n : {}),\n draft: { type: GraphQLBoolean },\n ...(config.localization\n ? {\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n },\n resolve: createResolver(collection),\n }\n\n graphqlResult.Mutation.fields[`update${singularName}`] = {\n type: collection.graphQL.type,\n args: {\n id: { type: new GraphQLNonNull(idType) },\n autosave: { type: GraphQLBoolean },\n ...(updateMutationInputType\n ? { data: { type: collection.graphQL.updateMutationInputType } }\n : {}),\n draft: { type: GraphQLBoolean },\n ...(config.localization\n ? {\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n },\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 ...(createMutationInputType\n ? { data: { type: collection.graphQL.mutationInputType } }\n : {}),\n },\n resolve: duplicateResolver(collection),\n }\n }\n }\n\n if (collectionConfig.versions) {\n const versionIDType = config.db.defaultIDType === 'text' ? GraphQLString : GraphQLInt\n const versionCollectionFields: Field[] = [\n ...buildVersionCollectionFields(config, collectionConfig),\n {\n name: 'id',\n type: config.db.defaultIDType as 'text',\n },\n {\n name: 'createdAt',\n type: 'date',\n label: '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 if (queriesEnabled) {\n graphqlResult.Query.fields[`version${formatName(singularName)}`] = {\n type: collection.graphQL.versionType,\n args: {\n id: { type: versionIDType },\n ...(config.localization\n ? {\n fallbackLocale: { type: graphqlResult.types.fallbackLocaleInputType },\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n },\n resolve: findVersionByIDResolver(collection),\n }\n graphqlResult.Query.fields[`versions${pluralName}`] = {\n type: buildPaginatedListType(\n `versions${formatName(pluralName)}`,\n collection.graphQL.versionType,\n ),\n args: {\n where: {\n type: buildWhereInputType({\n name: `versions${singularName}`,\n fields: versionCollectionFields,\n parentName: `versions${singularName}`,\n }),\n },\n ...(config.localization\n ? {\n fallbackLocale: { type: graphqlResult.types.fallbackLocaleInputType },\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n limit: { type: GraphQLInt },\n page: { type: GraphQLInt },\n pagination: { type: GraphQLBoolean },\n sort: { type: GraphQLString },\n },\n resolve: findVersionsResolver(collection),\n }\n }\n\n if (mutationsEnabled) {\n graphqlResult.Mutation.fields[`restoreVersion${formatName(singularName)}`] = {\n type: collection.graphQL.type,\n args: {\n id: { type: versionIDType },\n draft: { type: GraphQLBoolean },\n },\n resolve: restoreVersionResolver(collection),\n }\n }\n }\n\n if (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 if (queriesEnabled) {\n graphqlResult.Query.fields[`me${singularName}`] = {\n type: new GraphQLObjectType({\n name: formatName(`${slug}Me`),\n fields: {\n collection: {\n type: GraphQLString,\n },\n exp: {\n type: GraphQLInt,\n },\n 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\n if (mutationsEnabled) {\n graphqlResult.Mutation.fields[`refreshToken${singularName}`] = {\n type: new GraphQLObjectType({\n name: formatName(`${slug}Refreshed${singularName}`),\n fields: {\n exp: {\n type: GraphQLInt,\n },\n refreshedToken: {\n type: GraphQLString,\n },\n 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, canLoginWithUsername } = getLoginOptions(\n collectionConfig.auth.loginWithUsername,\n )\n\n if (canLoginWithEmail) {\n authArgs['email'] = { type: new GraphQLNonNull(GraphQLString) }\n }\n if (canLoginWithUsername) {\n authArgs['username'] = { type: new GraphQLNonNull(GraphQLString) }\n }\n\n if (collectionConfig.auth.maxLoginAttempts > 0) {\n graphqlResult.Mutation.fields[`unlock${singularName}`] = {\n type: new GraphQLNonNull(GraphQLBoolean),\n args: authArgs,\n resolve: unlock(collection),\n }\n }\n\n graphqlResult.Mutation.fields[`login${singularName}`] = {\n type: new GraphQLObjectType({\n name: formatName(`${slug}LoginResult`),\n fields: {\n exp: {\n type: GraphQLInt,\n },\n token: {\n type: GraphQLString,\n },\n user: {\n type: collection.graphQL.type,\n },\n },\n }),\n args: {\n ...authArgs,\n password: { type: GraphQLString },\n },\n resolve: login(collection),\n }\n\n graphqlResult.Mutation.fields[`forgotPassword${singularName}`] = {\n type: new GraphQLNonNull(GraphQLBoolean),\n args: {\n 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}\n"],"names":["GraphQLBoolean","GraphQLInt","GraphQLNonNull","GraphQLObjectType","GraphQLString","buildVersionCollectionFields","flattenTopLevelFields","formatNames","toWords","fieldAffectsData","getLoginOptions","forgotPassword","init","login","logout","me","refresh","resetPassword","unlock","verifyEmail","countResolver","createResolver","getDeleteResolver","docAccessResolver","duplicateResolver","findResolver","findByIDResolver","findVersionByIDResolver","findVersionsResolver","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","mutationInputFields","auth","disableLocalStrategy","optionalPassword","label","required","createMutationInputType","parentIsLocalized","mutationInputType","updateMutationInputType","filter","queriesEnabled","disableQueries","mutationsEnabled","disableMutations","Query","args","draft","localization","fallbackLocale","types","fallbackLocaleInputType","locale","localeInputType","resolve","where","limit","page","pagination","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,EAAEC,eAAe,QAAQ,iBAAgB;AAIlE,SAASC,cAAc,QAAQ,sCAAqC;AACpE,SAASC,IAAI,QAAQ,4BAA2B;AAChD,SAASC,KAAK,QAAQ,6BAA4B;AAClD,SAASC,MAAM,QAAQ,8BAA6B;AACpD,SAASC,EAAE,QAAQ,0BAAyB;AAC5C,SAASC,OAAO,QAAQ,+BAA8B;AACtD,SAASC,aAAa,QAAQ,qCAAoC;AAClE,SAASC,MAAM,QAAQ,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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D;4BAAc;4BAChCwH,OAAO;gCAAE1D,MAAM9D;4BAAc;wBAC/B;wBACA+F,SAASlF,cAAc6B;oBACzB;oBAEAN,cAAcqE,QAAQ,CAAC7D,MAAM,CAAC,CAAC,WAAW,EAAEG,cAAc,CAAC,GAAG;wBAC5De,MAAMlE;wBACN2F,MAAM;4BACJiC,OAAO;gCAAE1D,MAAM9D;4BAAc;wBAC/B;wBACA+F,SAAShF,YAAY2B;oBACvB;gBACF;YACF;QACF;IACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initGlobals.d.ts","sourceRoot":"","sources":["../../src/schema/initGlobals.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAS,WAAW,EAAE,eAAe,EAAyB,MAAM,SAAS,CAAA;AAiBzF,KAAK,sBAAsB,GAAG;IAC5B,MAAM,EAAE,eAAe,CAAA;IACvB,aAAa,EAAE,WAAW,CAAA;CAC3B,CAAA;AACD,wBAAgB,WAAW,CAAC,EAAE,MAAM,EAAE,aAAa,EAAE,EAAE,sBAAsB,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"initGlobals.d.ts","sourceRoot":"","sources":["../../src/schema/initGlobals.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAS,WAAW,EAAE,eAAe,EAAyB,MAAM,SAAS,CAAA;AAiBzF,KAAK,sBAAsB,GAAG;IAC5B,MAAM,EAAE,eAAe,CAAA;IACvB,aAAa,EAAE,WAAW,CAAA;CAC3B,CAAA;AACD,wBAAgB,WAAW,CAAC,EAAE,MAAM,EAAE,aAAa,EAAE,EAAE,sBAAsB,GAAG,IAAI,CA2KnF"}
|
|
@@ -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 const queriesEnabled = typeof global.graphQL !== 'object' || !global.graphQL.disableQueries\n const mutationsEnabled = typeof global.graphQL !== 'object' || !global.graphQL.disableMutations\n\n if (queriesEnabled) {\n graphqlResult.Query.fields[formattedName] = {\n type: graphqlResult.globals.graphQL[slug].type,\n args: {\n draft: { type: GraphQLBoolean },\n ...(config.localization\n ? {\n fallbackLocale: { type: graphqlResult.types.fallbackLocaleInputType },\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n },\n resolve: findOne(global),\n }\n\n graphqlResult.Query.fields[`docAccess${formattedName}`] = {\n type: buildPolicyType({\n type: 'global',\n entity: global,\n scope: 'docAccess',\n typeSuffix: 'DocAccess',\n }),\n resolve: docAccessResolver(global),\n }\n }\n\n if (mutationsEnabled) {\n graphqlResult.Mutation.fields[`update${formattedName}`] = {\n type: graphqlResult.globals.graphQL[slug].type,\n args: {\n ...(updateMutationInputType\n ? { data: { type: graphqlResult.globals.graphQL[slug].mutationInputType } }\n : {}),\n draft: { type: GraphQLBoolean },\n ...(config.localization\n ? {\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n },\n resolve: update(global),\n }\n }\n\n if (global.versions) {\n const idType = config.db.defaultIDType === 'number' ? GraphQLInt : GraphQLString\n\n const versionGlobalFields: Field[] = [\n ...buildVersionGlobalFields(config, global),\n {\n name: 'id',\n type: config.db.defaultIDType as 'text',\n },\n {\n name: 'createdAt',\n type: 'date',\n label: 'Created At',\n },\n {\n name: 'updatedAt',\n type: 'date',\n label: 'Updated At',\n },\n ]\n\n graphqlResult.globals.graphQL[slug].versionType = buildObjectType({\n name: `${formattedName}Version`,\n config,\n fields: versionGlobalFields,\n forceNullable: forceNullableObjectType,\n graphqlResult,\n parentName: `${formattedName}Version`,\n })\n\n if (queriesEnabled) {\n graphqlResult.Query.fields[`version${formatName(formattedName)}`] = {\n type: graphqlResult.globals.graphQL[slug].versionType,\n args: {\n id: { type: idType },\n draft: { type: GraphQLBoolean },\n ...(config.localization\n ? {\n fallbackLocale: { type: graphqlResult.types.fallbackLocaleInputType },\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n },\n resolve: findVersionByID(global),\n }\n graphqlResult.Query.fields[`versions${formattedName}`] = {\n type: buildPaginatedListType(\n `versions${formatName(formattedName)}`,\n graphqlResult.globals.graphQL[slug].versionType,\n ),\n args: {\n where: {\n type: buildWhereInputType({\n name: `versions${formattedName}`,\n fields: versionGlobalFields,\n parentName: `versions${formattedName}`,\n }),\n },\n ...(config.localization\n ? {\n fallbackLocale: { type: graphqlResult.types.fallbackLocaleInputType },\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n limit: { type: GraphQLInt },\n page: { type: GraphQLInt },\n pagination: { type: GraphQLBoolean },\n sort: { type: GraphQLString },\n },\n resolve: findVersions(global),\n }\n }\n\n if (mutationsEnabled) {\n graphqlResult.Mutation.fields[`restoreVersion${formatName(formattedName)}`] = {\n type: graphqlResult.globals.graphQL[slug].type,\n args: {\n id: { type: idType },\n draft: { type: GraphQLBoolean },\n },\n resolve: restoreVersion(global),\n }\n }\n }\n })\n}\n"],"names":["GraphQLBoolean","GraphQLInt","GraphQLNonNull","GraphQLString","pluralize","singular","buildVersionGlobalFields","toWords","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","queriesEnabled","disableQueries","mutationsEnabled","disableMutations","Query","args","draft","localization","fallbackLocale","types","fallbackLocaleInputType","locale","localeInputType","resolve","entity","scope","typeSuffix","Mutation","data","idType","db","defaultIDType","versionGlobalFields","label","versionType","id","where","limit","page","pagination","sort"],"mappings":"AAAA,SAASA,cAAc,EAAEC,UAAU,EAAEC,cAAc,EAAEC,aAAa,QAAQ,UAAS;AACnF,OAAOC,eAAe,YAAW;AACjC,MAAM,EAAEC,QAAQ,EAAE,GAAGD;AAIrB,SAASE,wBAAwB,EAAEC,OAAO,QAAQ,UAAS;AAE3D,SAASC,iBAAiB,QAAQ,oCAAmC;AACrE,SAASC,OAAO,QAAQ,kCAAiC;AACzD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B,EACtCV,cAAcG,OAAO,CAACK,OAAO,CAACH,KAAK,CAACuC,WAAW;oBAEjDnB,MAAM;wBACJqB,OAAO;4BACL7B,MAAMpB,oBAAoB;gCACxBc,MAAM,CAAC,QAAQ,EAAED,eAAe;gCAChCH,QAAQmC;gCACR1B,YAAY,CAAC,QAAQ,EAAEN,eAAe;4BACxC;wBACF;wBACA,GAAIX,OAAO4B,YAAY,GACnB;4BACEC,gBAAgB;gCAAEX,MAAMjB,cAAc6B,KAAK,CAACC,uBAAuB;4BAAC;4BACpEC,QAAQ;gCAAEd,MAAMjB,cAAc6B,KAAK,CAACG,eAAe;4BAAC;wBACtD,IACA,CAAC,CAAC;wBACNe,OAAO;4BAAE9B,MAAMtC;wBAAW;wBAC1BqE,MAAM;4BAAE/B,MAAMtC;wBAAW;wBACzBsE,YAAY;4BAAEhC,MAAMvC;wBAAe;wBACnCwE,MAAM;4BAAEjC,MAAMpC;wBAAc;oBAC9B;oBACAoD,SAAS5C,aAAaiB;gBACxB;YACF;YAEA,IAAIgB,kBAAkB;gBACpBtB,cAAcqC,QAAQ,CAAC9B,MAAM,CAAC,CAAC,cAAc,EAAEf,WAAWkB,gBAAgB,CAAC,GAAG;oBAC5EO,MAAMjB,cAAcG,OAAO,CAACK,OAAO,CAACH,KAAK,CAACY,IAAI;oBAC9CQ,MAAM;wBACJoB,IAAI;4BAAE5B,MAAMsB;wBAAO;wBACnBb,OAAO;4BAAET,MAAMvC;wBAAe;oBAChC;oBACAuD,SAAS3C,eAAegB;gBAC1B;YACF;QACF;IACF;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../src/schema/initGlobals.ts"],"sourcesContent":["import { GraphQLBoolean, GraphQLInt, GraphQLNonNull, GraphQLString } from 'graphql'\nimport pluralize from 'pluralize'\nconst { singular } = pluralize\n\nimport type { Field, GraphQLInfo, SanitizedConfig, SanitizedGlobalConfig } from 'payload'\n\nimport { buildVersionGlobalFields, toWords } from 'payload'\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 parentIsLocalized: false,\n parentName: formattedName,\n })\n graphqlResult.globals.graphQL[slug] = {\n type: buildObjectType({\n name: formattedName,\n config,\n fields,\n forceNullable: forceNullableObjectType,\n graphqlResult,\n parentName: formattedName,\n }),\n mutationInputType: updateMutationInputType\n ? new GraphQLNonNull(updateMutationInputType)\n : null,\n }\n\n const queriesEnabled = typeof global.graphQL !== 'object' || !global.graphQL.disableQueries\n const mutationsEnabled = typeof global.graphQL !== 'object' || !global.graphQL.disableMutations\n\n if (queriesEnabled) {\n graphqlResult.Query.fields[formattedName] = {\n type: graphqlResult.globals.graphQL[slug].type,\n args: {\n draft: { type: GraphQLBoolean },\n ...(config.localization\n ? {\n fallbackLocale: { type: graphqlResult.types.fallbackLocaleInputType },\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n },\n resolve: findOne(global),\n }\n\n graphqlResult.Query.fields[`docAccess${formattedName}`] = {\n type: buildPolicyType({\n type: 'global',\n entity: global,\n scope: 'docAccess',\n typeSuffix: 'DocAccess',\n }),\n resolve: docAccessResolver(global),\n }\n }\n\n if (mutationsEnabled) {\n graphqlResult.Mutation.fields[`update${formattedName}`] = {\n type: graphqlResult.globals.graphQL[slug].type,\n args: {\n ...(updateMutationInputType\n ? { data: { type: graphqlResult.globals.graphQL[slug].mutationInputType } }\n : {}),\n draft: { type: GraphQLBoolean },\n ...(config.localization\n ? {\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n },\n resolve: update(global),\n }\n }\n\n if (global.versions) {\n const idType = config.db.defaultIDType === 'number' ? GraphQLInt : GraphQLString\n\n const versionGlobalFields: Field[] = [\n ...buildVersionGlobalFields(config, global),\n {\n name: 'id',\n type: config.db.defaultIDType as 'text',\n },\n {\n name: 'createdAt',\n type: 'date',\n label: 'Created At',\n },\n {\n name: 'updatedAt',\n type: 'date',\n label: 'Updated At',\n },\n ]\n\n graphqlResult.globals.graphQL[slug].versionType = buildObjectType({\n name: `${formattedName}Version`,\n config,\n fields: versionGlobalFields,\n forceNullable: forceNullableObjectType,\n graphqlResult,\n parentName: `${formattedName}Version`,\n })\n\n if (queriesEnabled) {\n graphqlResult.Query.fields[`version${formatName(formattedName)}`] = {\n type: graphqlResult.globals.graphQL[slug].versionType,\n args: {\n id: { type: idType },\n draft: { type: GraphQLBoolean },\n ...(config.localization\n ? {\n fallbackLocale: { type: graphqlResult.types.fallbackLocaleInputType },\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n },\n resolve: findVersionByID(global),\n }\n graphqlResult.Query.fields[`versions${formattedName}`] = {\n type: buildPaginatedListType(\n `versions${formatName(formattedName)}`,\n graphqlResult.globals.graphQL[slug].versionType,\n ),\n args: {\n where: {\n type: buildWhereInputType({\n name: `versions${formattedName}`,\n fields: versionGlobalFields,\n parentName: `versions${formattedName}`,\n }),\n },\n ...(config.localization\n ? {\n fallbackLocale: { type: graphqlResult.types.fallbackLocaleInputType },\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n limit: { type: GraphQLInt },\n page: { type: GraphQLInt },\n pagination: { type: GraphQLBoolean },\n sort: { type: GraphQLString },\n },\n resolve: findVersions(global),\n }\n }\n\n if (mutationsEnabled) {\n graphqlResult.Mutation.fields[`restoreVersion${formatName(formattedName)}`] = {\n type: graphqlResult.globals.graphQL[slug].type,\n args: {\n id: { type: idType },\n draft: { type: GraphQLBoolean },\n },\n resolve: restoreVersion(global),\n }\n }\n }\n })\n}\n"],"names":["GraphQLBoolean","GraphQLInt","GraphQLNonNull","GraphQLString","pluralize","singular","buildVersionGlobalFields","toWords","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","parentIsLocalized","parentName","type","forceNullable","mutationInputType","queriesEnabled","disableQueries","mutationsEnabled","disableMutations","Query","args","draft","localization","fallbackLocale","types","fallbackLocaleInputType","locale","localeInputType","resolve","entity","scope","typeSuffix","Mutation","data","idType","db","defaultIDType","versionGlobalFields","label","versionType","id","where","limit","page","pagination","sort"],"mappings":"AAAA,SAASA,cAAc,EAAEC,UAAU,EAAEC,cAAc,EAAEC,aAAa,QAAQ,UAAS;AACnF,OAAOC,eAAe,YAAW;AACjC,MAAM,EAAEC,QAAQ,EAAE,GAAGD;AAIrB,SAASE,wBAAwB,EAAEC,OAAO,QAAQ,UAAS;AAE3D,SAASC,iBAAiB,QAAQ,oCAAmC;AACrE,SAASC,OAAO,QAAQ,kCAAiC;AACzD,SAASC,eAAe,QAAQ,0CAAyC;AACzE,SAASC,YAAY,QAA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AAO,CAACH,KAAK,CAACwC,WAAW;oBAEjDnB,MAAM;wBACJqB,OAAO;4BACL7B,MAAMrB,oBAAoB;gCACxBc,MAAM,CAAC,QAAQ,EAAED,eAAe;gCAChCH,QAAQoC;gCACR1B,YAAY,CAAC,QAAQ,EAAEP,eAAe;4BACxC;wBACF;wBACA,GAAIX,OAAO6B,YAAY,GACnB;4BACEC,gBAAgB;gCAAEX,MAAMlB,cAAc8B,KAAK,CAACC,uBAAuB;4BAAC;4BACpEC,QAAQ;gCAAEd,MAAMlB,cAAc8B,KAAK,CAACG,eAAe;4BAAC;wBACtD,IACA,CAAC,CAAC;wBACNe,OAAO;4BAAE9B,MAAMvC;wBAAW;wBAC1BsE,MAAM;4BAAE/B,MAAMvC;wBAAW;wBACzBuE,YAAY;4BAAEhC,MAAMxC;wBAAe;wBACnCyE,MAAM;4BAAEjC,MAAMrC;wBAAc;oBAC9B;oBACAqD,SAAS7C,aAAaiB;gBACxB;YACF;YAEA,IAAIiB,kBAAkB;gBACpBvB,cAAcsC,QAAQ,CAAC/B,MAAM,CAAC,CAAC,cAAc,EAAEf,WAAWkB,gBAAgB,CAAC,GAAG;oBAC5EQ,MAAMlB,cAAcG,OAAO,CAACK,OAAO,CAACH,KAAK,CAACa,IAAI;oBAC9CQ,MAAM;wBACJoB,IAAI;4BAAE5B,MAAMsB;wBAAO;wBACnBb,OAAO;4BAAET,MAAMxC;wBAAe;oBAChC;oBACAwD,SAAS5C,eAAegB;gBAC1B;YACF;QACF;IACF;AACF"}
|
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
import type { FieldAffectingData } from 'payload';
|
|
2
|
-
export declare const isFieldNullable: (field
|
|
2
|
+
export declare const isFieldNullable: ({ field, forceNullable, parentIsLocalized, }: {
|
|
3
|
+
field: FieldAffectingData;
|
|
4
|
+
forceNullable: boolean;
|
|
5
|
+
parentIsLocalized: boolean;
|
|
6
|
+
}) => boolean;
|
|
3
7
|
//# sourceMappingURL=isFieldNullable.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isFieldNullable.d.ts","sourceRoot":"","sources":["../../src/schema/isFieldNullable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AAIjD,eAAO,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"isFieldNullable.d.ts","sourceRoot":"","sources":["../../src/schema/isFieldNullable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AAIjD,eAAO,MAAM,eAAe,iDAIzB;IACD,KAAK,EAAE,kBAAkB,CAAA;IACzB,aAAa,EAAE,OAAO,CAAA;IACtB,iBAAiB,EAAE,OAAO,CAAA;CAC3B,KAAG,OAYH,CAAA"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { fieldAffectsData } from 'payload/shared';
|
|
2
|
-
export const isFieldNullable = (field,
|
|
2
|
+
export const isFieldNullable = ({ field, forceNullable, parentIsLocalized })=>{
|
|
3
3
|
const hasReadAccessControl = field.access && field.access.read;
|
|
4
4
|
const condition = field.admin && field.admin.condition;
|
|
5
|
-
return !(
|
|
5
|
+
return !(forceNullable && fieldAffectsData(field) && 'required' in field && field.required && (!field.localized || parentIsLocalized) && !condition && !hasReadAccessControl);
|
|
6
6
|
};
|
|
7
7
|
|
|
8
8
|
//# sourceMappingURL=isFieldNullable.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/schema/isFieldNullable.ts"],"sourcesContent":["import type { FieldAffectingData } from 'payload'\n\nimport { fieldAffectsData } from 'payload/shared'\n\nexport const isFieldNullable = (field: FieldAffectingData
|
|
1
|
+
{"version":3,"sources":["../../src/schema/isFieldNullable.ts"],"sourcesContent":["import type { FieldAffectingData } from 'payload'\n\nimport { fieldAffectsData } from 'payload/shared'\n\nexport const isFieldNullable = ({\n field,\n forceNullable,\n parentIsLocalized,\n}: {\n field: FieldAffectingData\n forceNullable: boolean\n parentIsLocalized: boolean\n}): boolean => {\n const hasReadAccessControl = field.access && field.access.read\n const condition = field.admin && field.admin.condition\n return !(\n forceNullable &&\n fieldAffectsData(field) &&\n 'required' in field &&\n field.required &&\n (!field.localized || parentIsLocalized) &&\n !condition &&\n !hasReadAccessControl\n )\n}\n"],"names":["fieldAffectsData","isFieldNullable","field","forceNullable","parentIsLocalized","hasReadAccessControl","access","read","condition","admin","required","localized"],"mappings":"AAEA,SAASA,gBAAgB,QAAQ,iBAAgB;AAEjD,OAAO,MAAMC,kBAAkB,CAAC,EAC9BC,KAAK,EACLC,aAAa,EACbC,iBAAiB,EAKlB;IACC,MAAMC,uBAAuBH,MAAMI,MAAM,IAAIJ,MAAMI,MAAM,CAACC,IAAI;IAC9D,MAAMC,YAAYN,MAAMO,KAAK,IAAIP,MAAMO,KAAK,CAACD,SAAS;IACtD,OAAO,CACLL,CAAAA,iBACAH,iBAAiBE,UACjB,cAAcA,SACdA,MAAMQ,QAAQ,IACb,CAAA,CAACR,MAAMS,SAAS,IAAIP,iBAAgB,KACrC,CAACI,aACD,CAACH,oBAAmB;AAExB,EAAC"}
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import type { GraphQLType } from 'graphql';
|
|
2
2
|
import type { FieldAffectingData } from 'payload';
|
|
3
|
-
export declare const withNullableType: (
|
|
3
|
+
export declare const withNullableType: ({ type, field, forceNullable, parentIsLocalized, }: {
|
|
4
|
+
field: FieldAffectingData;
|
|
5
|
+
forceNullable?: boolean;
|
|
6
|
+
parentIsLocalized: boolean;
|
|
7
|
+
type: GraphQLType;
|
|
8
|
+
}) => GraphQLType;
|
|
4
9
|
//# sourceMappingURL=withNullableType.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withNullableType.d.ts","sourceRoot":"","sources":["../../src/schema/withNullableType.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAC1C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AAIjD,eAAO,MAAM,gBAAgB,
|
|
1
|
+
{"version":3,"file":"withNullableType.d.ts","sourceRoot":"","sources":["../../src/schema/withNullableType.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAC1C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AAIjD,eAAO,MAAM,gBAAgB,uDAK1B;IACD,KAAK,EAAE,kBAAkB,CAAA;IACzB,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,iBAAiB,EAAE,OAAO,CAAA;IAC1B,IAAI,EAAE,WAAW,CAAA;CAClB,KAAG,WAkBH,CAAA"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { GraphQLNonNull } from 'graphql';
|
|
2
|
-
export const withNullableType = (
|
|
2
|
+
export const withNullableType = ({ type, field, forceNullable, parentIsLocalized })=>{
|
|
3
3
|
const hasReadAccessControl = field.access && field.access.read;
|
|
4
4
|
const condition = field.admin && field.admin.condition;
|
|
5
5
|
const isTimestamp = field.name === 'createdAt' || field.name === 'updatedAt';
|
|
6
|
-
if (!forceNullable && 'required' in field && field.required && !field.localized && !condition && !hasReadAccessControl && !isTimestamp) {
|
|
6
|
+
if (!forceNullable && 'required' in field && field.required && (!field.localized || parentIsLocalized) && !condition && !hasReadAccessControl && !isTimestamp) {
|
|
7
7
|
return new GraphQLNonNull(type);
|
|
8
8
|
}
|
|
9
9
|
return type;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/schema/withNullableType.ts"],"sourcesContent":["import type { GraphQLType } from 'graphql'\nimport type { FieldAffectingData } from 'payload'\n\nimport { GraphQLNonNull } from 'graphql'\n\nexport const withNullableType = (\n field:
|
|
1
|
+
{"version":3,"sources":["../../src/schema/withNullableType.ts"],"sourcesContent":["import type { GraphQLType } from 'graphql'\nimport type { FieldAffectingData } from 'payload'\n\nimport { GraphQLNonNull } from 'graphql'\n\nexport const withNullableType = ({\n type,\n field,\n forceNullable,\n parentIsLocalized,\n}: {\n field: FieldAffectingData\n forceNullable?: boolean\n parentIsLocalized: boolean\n type: GraphQLType\n}): GraphQLType => {\n const hasReadAccessControl = field.access && field.access.read\n const condition = field.admin && field.admin.condition\n const isTimestamp = field.name === 'createdAt' || field.name === 'updatedAt'\n\n if (\n !forceNullable &&\n 'required' in field &&\n field.required &&\n (!field.localized || parentIsLocalized) &&\n !condition &&\n !hasReadAccessControl &&\n !isTimestamp\n ) {\n return new GraphQLNonNull(type)\n }\n\n return type\n}\n"],"names":["GraphQLNonNull","withNullableType","type","field","forceNullable","parentIsLocalized","hasReadAccessControl","access","read","condition","admin","isTimestamp","name","required","localized"],"mappings":"AAGA,SAASA,cAAc,QAAQ,UAAS;AAExC,OAAO,MAAMC,mBAAmB,CAAC,EAC/BC,IAAI,EACJC,KAAK,EACLC,aAAa,EACbC,iBAAiB,EAMlB;IACC,MAAMC,uBAAuBH,MAAMI,MAAM,IAAIJ,MAAMI,MAAM,CAACC,IAAI;IAC9D,MAAMC,YAAYN,MAAMO,KAAK,IAAIP,MAAMO,KAAK,CAACD,SAAS;IACtD,MAAME,cAAcR,MAAMS,IAAI,KAAK,eAAeT,MAAMS,IAAI,KAAK;IAEjE,IACE,CAACR,iBACD,cAAcD,SACdA,MAAMU,QAAQ,IACb,CAAA,CAACV,MAAMW,SAAS,IAAIT,iBAAgB,KACrC,CAACI,aACD,CAACH,wBACD,CAACK,aACD;QACA,OAAO,IAAIX,eAAeE;IAC5B;IAEA,OAAOA;AACT,EAAC"}
|