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

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/bin/index.js CHANGED
File without changes
File without changes
@@ -11,7 +11,7 @@ export function createResolver(collection) {
11
11
  });
12
12
  const result = await createOperation({
13
13
  collection,
14
- data: args.data,
14
+ data: args.data ?? {},
15
15
  depth: 0,
16
16
  draft: args.draft,
17
17
  req
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/resolvers/collections/create.ts"],"sourcesContent":["import type { GraphQLResolveInfo } from 'graphql'\nimport type {\n Collection,\n CollectionSlug,\n DataFromCollectionSlug,\n PayloadRequest,\n RequiredDataFromCollectionSlug,\n} from 'payload'\n\nimport { createOperation } from 'payload'\n\nimport type { Context } from '../types.js'\n\nimport { getGraphQLRequest } from '../getGraphQLRequest.js'\n\nexport type Resolver<TSlug extends CollectionSlug> = (\n _: unknown,\n args: {\n branch?: string\n data: RequiredDataFromCollectionSlug<TSlug>\n draft: boolean\n locale?: string\n },\n context: {\n req: PayloadRequest\n },\n info: GraphQLResolveInfo,\n) => Promise<DataFromCollectionSlug<TSlug>>\n\nexport function createResolver<TSlug extends CollectionSlug>(\n collection: Collection,\n): Resolver<TSlug> {\n return async function resolver(_, args, context: Context, info) {\n const req = await getGraphQLRequest({\n branch: args.branch,\n collectionSlug: collection.config.slug,\n context,\n info,\n locale: args.locale,\n })\n\n const result = await createOperation({\n collection,\n data: args.data,\n depth: 0,\n draft: args.draft,\n req,\n })\n\n return result\n }\n}\n"],"names":["createOperation","getGraphQLRequest","createResolver","collection","resolver","_","args","context","info","req","branch","collectionSlug","config","slug","locale","result","data","depth","draft"],"mappings":"AASA,SAASA,eAAe,QAAQ,UAAS;AAIzC,SAASC,iBAAiB,QAAQ,0BAAyB;AAgB3D,OAAO,SAASC,eACdC,UAAsB;IAEtB,OAAO,eAAeC,SAASC,CAAC,EAAEC,IAAI,EAAEC,OAAgB,EAAEC,IAAI;QAC5D,MAAMC,MAAM,MAAMR,kBAAkB;YAClCS,QAAQJ,KAAKI,MAAM;YACnBC,gBAAgBR,WAAWS,MAAM,CAACC,IAAI;YACtCN;YACAC;YACAM,QAAQR,KAAKQ,MAAM;QACrB;QAEA,MAAMC,SAAS,MAAMf,gBAAgB;YACnCG;YACAa,MAAMV,KAAKU,IAAI;YACfC,OAAO;YACPC,OAAOZ,KAAKY,KAAK;YACjBT;QACF;QAEA,OAAOM;IACT;AACF"}
1
+ {"version":3,"sources":["../../../src/resolvers/collections/create.ts"],"sourcesContent":["import type { GraphQLResolveInfo } from 'graphql'\nimport type {\n Collection,\n CollectionSlug,\n DataFromCollectionSlug,\n PayloadRequest,\n RequiredDataFromCollectionSlug,\n} from 'payload'\n\nimport { createOperation } from 'payload'\n\nimport type { Context } from '../types.js'\n\nimport { getGraphQLRequest } from '../getGraphQLRequest.js'\n\nexport type Resolver<TSlug extends CollectionSlug> = (\n _: unknown,\n args: {\n branch?: string\n data: RequiredDataFromCollectionSlug<TSlug>\n draft: boolean\n locale?: string\n },\n context: {\n req: PayloadRequest\n },\n info: GraphQLResolveInfo,\n) => Promise<DataFromCollectionSlug<TSlug>>\n\nexport function createResolver<TSlug extends CollectionSlug>(\n collection: Collection,\n): Resolver<TSlug> {\n return async function resolver(_, args, context: Context, info) {\n const req = await getGraphQLRequest({\n branch: args.branch,\n collectionSlug: collection.config.slug,\n context,\n info,\n locale: args.locale,\n })\n\n const result = await createOperation({\n collection,\n data: args.data ?? {},\n depth: 0,\n draft: args.draft,\n req,\n })\n\n return result\n }\n}\n"],"names":["createOperation","getGraphQLRequest","createResolver","collection","resolver","_","args","context","info","req","branch","collectionSlug","config","slug","locale","result","data","depth","draft"],"mappings":"AASA,SAASA,eAAe,QAAQ,UAAS;AAIzC,SAASC,iBAAiB,QAAQ,0BAAyB;AAgB3D,OAAO,SAASC,eACdC,UAAsB;IAEtB,OAAO,eAAeC,SAASC,CAAC,EAAEC,IAAI,EAAEC,OAAgB,EAAEC,IAAI;QAC5D,MAAMC,MAAM,MAAMR,kBAAkB;YAClCS,QAAQJ,KAAKI,MAAM;YACnBC,gBAAgBR,WAAWS,MAAM,CAACC,IAAI;YACtCN;YACAC;YACAM,QAAQR,KAAKQ,MAAM;QACrB;QAEA,MAAMC,SAAS,MAAMf,gBAAgB;YACnCG;YACAa,MAAMV,KAAKU,IAAI,IAAI,CAAC;YACpBC,OAAO;YACPC,OAAOZ,KAAKY,KAAK;YACjBT;QACF;QAEA,OAAOM;IACT;AACF"}
@@ -18,7 +18,7 @@ export function updateResolver(collection) {
18
18
  id: args.id,
19
19
  autosave: args.autosave,
20
20
  collection,
21
- data: args.data,
21
+ data: args.data ?? {},
22
22
  depth: 0,
23
23
  draft: args.draft,
24
24
  req,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/resolvers/collections/update.ts"],"sourcesContent":["import type { GraphQLResolveInfo } from 'graphql'\nimport type { Collection, CollectionSlug, DataFromCollectionSlug, PayloadRequest } from 'payload'\n\nimport { updateByIDOperation } from 'payload'\n\nimport type { Context } from '../types.js'\n\nimport { getGraphQLRequest } from '../getGraphQLRequest.js'\n\nexport type Resolver<TSlug extends CollectionSlug> = (\n _: unknown,\n args: {\n autosave: boolean\n branch?: string\n data: DataFromCollectionSlug<TSlug>\n draft: boolean\n fallbackLocale?: string\n id: number | string\n locale?: string\n trash?: boolean\n },\n context: {\n req: PayloadRequest\n },\n info: GraphQLResolveInfo,\n) => Promise<DataFromCollectionSlug<TSlug>>\n\nexport function updateResolver<TSlug extends CollectionSlug>(\n collection: Collection,\n): Resolver<TSlug> {\n return async function resolver(_, args, context: Context, info) {\n const req = await getGraphQLRequest({\n branch: args.branch,\n collectionSlug: collection.config.slug,\n context,\n fallbackLocale: args.fallbackLocale,\n info,\n locale: args.locale,\n })\n\n const draft: boolean =\n (args.draft ?? req.query?.draft === 'false')\n ? false\n : req.query?.draft === 'true'\n ? true\n : undefined\n if (typeof draft === 'boolean') {\n req.query.draft = String(draft)\n }\n\n const options = {\n id: args.id,\n autosave: args.autosave,\n collection,\n data: args.data as any,\n depth: 0,\n draft: args.draft,\n req,\n trash: args.trash,\n }\n\n const result = await updateByIDOperation<TSlug>(options)\n\n return result\n }\n}\n"],"names":["updateByIDOperation","getGraphQLRequest","updateResolver","collection","resolver","_","args","context","info","req","branch","collectionSlug","config","slug","fallbackLocale","locale","draft","query","undefined","String","options","id","autosave","data","depth","trash","result"],"mappings":"AAGA,SAASA,mBAAmB,QAAQ,UAAS;AAI7C,SAASC,iBAAiB,QAAQ,0BAAyB;AAoB3D,OAAO,SAASC,eACdC,UAAsB;IAEtB,OAAO,eAAeC,SAASC,CAAC,EAAEC,IAAI,EAAEC,OAAgB,EAAEC,IAAI;QAC5D,MAAMC,MAAM,MAAMR,kBAAkB;YAClCS,QAAQJ,KAAKI,MAAM;YACnBC,gBAAgBR,WAAWS,MAAM,CAACC,IAAI;YACtCN;YACAO,gBAAgBR,KAAKQ,cAAc;YACnCN;YACAO,QAAQT,KAAKS,MAAM;QACrB;QAEA,MAAMC,QACJ,AAACV,KAAKU,KAAK,IAAIP,IAAIQ,KAAK,EAAED,UAAU,UAChC,QACAP,IAAIQ,KAAK,EAAED,UAAU,SACnB,OACAE;QACR,IAAI,OAAOF,UAAU,WAAW;YAC9BP,IAAIQ,KAAK,CAACD,KAAK,GAAGG,OAAOH;QAC3B;QAEA,MAAMI,UAAU;YACdC,IAAIf,KAAKe,EAAE;YACXC,UAAUhB,KAAKgB,QAAQ;YACvBnB;YACAoB,MAAMjB,KAAKiB,IAAI;YACfC,OAAO;YACPR,OAAOV,KAAKU,KAAK;YACjBP;YACAgB,OAAOnB,KAAKmB,KAAK;QACnB;QAEA,MAAMC,SAAS,MAAM1B,oBAA2BoB;QAEhD,OAAOM;IACT;AACF"}
1
+ {"version":3,"sources":["../../../src/resolvers/collections/update.ts"],"sourcesContent":["import type { GraphQLResolveInfo } from 'graphql'\nimport type { Collection, CollectionSlug, DataFromCollectionSlug, PayloadRequest } from 'payload'\n\nimport { updateByIDOperation } from 'payload'\n\nimport type { Context } from '../types.js'\n\nimport { getGraphQLRequest } from '../getGraphQLRequest.js'\n\nexport type Resolver<TSlug extends CollectionSlug> = (\n _: unknown,\n args: {\n autosave: boolean\n branch?: string\n data: DataFromCollectionSlug<TSlug>\n draft: boolean\n fallbackLocale?: string\n id: number | string\n locale?: string\n trash?: boolean\n },\n context: {\n req: PayloadRequest\n },\n info: GraphQLResolveInfo,\n) => Promise<DataFromCollectionSlug<TSlug>>\n\nexport function updateResolver<TSlug extends CollectionSlug>(\n collection: Collection,\n): Resolver<TSlug> {\n return async function resolver(_, args, context: Context, info) {\n const req = await getGraphQLRequest({\n branch: args.branch,\n collectionSlug: collection.config.slug,\n context,\n fallbackLocale: args.fallbackLocale,\n info,\n locale: args.locale,\n })\n\n const draft: boolean =\n (args.draft ?? req.query?.draft === 'false')\n ? false\n : req.query?.draft === 'true'\n ? true\n : undefined\n if (typeof draft === 'boolean') {\n req.query.draft = String(draft)\n }\n\n const options = {\n id: args.id,\n autosave: args.autosave,\n collection,\n data: (args.data ?? {}) as any,\n depth: 0,\n draft: args.draft,\n req,\n trash: args.trash,\n }\n\n const result = await updateByIDOperation<TSlug>(options)\n\n return result\n }\n}\n"],"names":["updateByIDOperation","getGraphQLRequest","updateResolver","collection","resolver","_","args","context","info","req","branch","collectionSlug","config","slug","fallbackLocale","locale","draft","query","undefined","String","options","id","autosave","data","depth","trash","result"],"mappings":"AAGA,SAASA,mBAAmB,QAAQ,UAAS;AAI7C,SAASC,iBAAiB,QAAQ,0BAAyB;AAoB3D,OAAO,SAASC,eACdC,UAAsB;IAEtB,OAAO,eAAeC,SAASC,CAAC,EAAEC,IAAI,EAAEC,OAAgB,EAAEC,IAAI;QAC5D,MAAMC,MAAM,MAAMR,kBAAkB;YAClCS,QAAQJ,KAAKI,MAAM;YACnBC,gBAAgBR,WAAWS,MAAM,CAACC,IAAI;YACtCN;YACAO,gBAAgBR,KAAKQ,cAAc;YACnCN;YACAO,QAAQT,KAAKS,MAAM;QACrB;QAEA,MAAMC,QACJ,AAACV,KAAKU,KAAK,IAAIP,IAAIQ,KAAK,EAAED,UAAU,UAChC,QACAP,IAAIQ,KAAK,EAAED,UAAU,SACnB,OACAE;QACR,IAAI,OAAOF,UAAU,WAAW;YAC9BP,IAAIQ,KAAK,CAACD,KAAK,GAAGG,OAAOH;QAC3B;QAEA,MAAMI,UAAU;YACdC,IAAIf,KAAKe,EAAE;YACXC,UAAUhB,KAAKgB,QAAQ;YACvBnB;YACAoB,MAAOjB,KAAKiB,IAAI,IAAI,CAAC;YACrBC,OAAO;YACPR,OAAOV,KAAKU,KAAK;YACjBP;YACAgB,OAAOnB,KAAKmB,KAAK;QACnB;QAEA,MAAMC,SAAS,MAAM1B,oBAA2BoB;QAEhD,OAAOM;IACT;AACF"}
@@ -16,7 +16,7 @@ export function restoreVersion(globalConfig) {
16
16
  req
17
17
  };
18
18
  const result = await restoreVersionOperationGlobal(options);
19
- return result.version;
19
+ return result;
20
20
  };
21
21
  }
22
22
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/resolvers/globals/restoreVersion.ts"],"sourcesContent":["import type { GraphQLResolveInfo } from 'graphql'\nimport type { Document, PayloadRequest, SanitizedGlobalConfig } from 'payload'\n\nimport { restoreVersionOperationGlobal } from 'payload'\n\nimport type { Context } from '../types.js'\n\nimport { getGraphQLRequest } from '../getGraphQLRequest.js'\n\ntype Resolver = (\n _: unknown,\n args: {\n branch?: string\n draft?: boolean\n id: number | string\n },\n context: {\n req: PayloadRequest\n },\n info: GraphQLResolveInfo,\n) => Promise<Document>\nexport function restoreVersion(globalConfig: SanitizedGlobalConfig): Resolver {\n return async function resolver(_, args, context: Context, info) {\n const req = await getGraphQLRequest({\n branch: args.branch,\n context,\n globalSlug: globalConfig.slug,\n info,\n })\n const options = {\n id: args.id,\n depth: 0,\n draft: args.draft,\n globalConfig,\n req,\n }\n\n const result = await restoreVersionOperationGlobal(options)\n return result.version\n }\n}\n"],"names":["restoreVersionOperationGlobal","getGraphQLRequest","restoreVersion","globalConfig","resolver","_","args","context","info","req","branch","globalSlug","slug","options","id","depth","draft","result","version"],"mappings":"AAGA,SAASA,6BAA6B,QAAQ,UAAS;AAIvD,SAASC,iBAAiB,QAAQ,0BAAyB;AAc3D,OAAO,SAASC,eAAeC,YAAmC;IAChE,OAAO,eAAeC,SAASC,CAAC,EAAEC,IAAI,EAAEC,OAAgB,EAAEC,IAAI;QAC5D,MAAMC,MAAM,MAAMR,kBAAkB;YAClCS,QAAQJ,KAAKI,MAAM;YACnBH;YACAI,YAAYR,aAAaS,IAAI;YAC7BJ;QACF;QACA,MAAMK,UAAU;YACdC,IAAIR,KAAKQ,EAAE;YACXC,OAAO;YACPC,OAAOV,KAAKU,KAAK;YACjBb;YACAM;QACF;QAEA,MAAMQ,SAAS,MAAMjB,8BAA8Ba;QACnD,OAAOI,OAAOC,OAAO;IACvB;AACF"}
1
+ {"version":3,"sources":["../../../src/resolvers/globals/restoreVersion.ts"],"sourcesContent":["import type { GraphQLResolveInfo } from 'graphql'\nimport type { Document, PayloadRequest, SanitizedGlobalConfig } from 'payload'\n\nimport { restoreVersionOperationGlobal } from 'payload'\n\nimport type { Context } from '../types.js'\n\nimport { getGraphQLRequest } from '../getGraphQLRequest.js'\n\ntype Resolver = (\n _: unknown,\n args: {\n branch?: string\n draft?: boolean\n id: number | string\n },\n context: {\n req: PayloadRequest\n },\n info: GraphQLResolveInfo,\n) => Promise<Document>\nexport function restoreVersion(globalConfig: SanitizedGlobalConfig): Resolver {\n return async function resolver(_, args, context: Context, info) {\n const req = await getGraphQLRequest({\n branch: args.branch,\n context,\n globalSlug: globalConfig.slug,\n info,\n })\n const options = {\n id: args.id,\n depth: 0,\n draft: args.draft,\n globalConfig,\n req,\n }\n\n const result = await restoreVersionOperationGlobal(options)\n return result\n }\n}\n"],"names":["restoreVersionOperationGlobal","getGraphQLRequest","restoreVersion","globalConfig","resolver","_","args","context","info","req","branch","globalSlug","slug","options","id","depth","draft","result"],"mappings":"AAGA,SAASA,6BAA6B,QAAQ,UAAS;AAIvD,SAASC,iBAAiB,QAAQ,0BAAyB;AAc3D,OAAO,SAASC,eAAeC,YAAmC;IAChE,OAAO,eAAeC,SAASC,CAAC,EAAEC,IAAI,EAAEC,OAAgB,EAAEC,IAAI;QAC5D,MAAMC,MAAM,MAAMR,kBAAkB;YAClCS,QAAQJ,KAAKI,MAAM;YACnBH;YACAI,YAAYR,aAAaS,IAAI;YAC7BJ;QACF;QACA,MAAMK,UAAU;YACdC,IAAIR,KAAKQ,EAAE;YACXC,OAAO;YACPC,OAAOV,KAAKU,KAAK;YACjBb;YACAM;QACF;QAEA,MAAMQ,SAAS,MAAMjB,8BAA8Ba;QACnD,OAAOI;IACT;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"buildMutationInputType.d.ts","sourceRoot":"","sources":["../../src/schema/buildMutationInputType.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,iBAAiB,EAAe,MAAM,SAAS,CAAA;AACtF,OAAO,KAAK,EAQV,KAAK,EACL,WAAW,EASX,yBAAyB,EACzB,eAAe,EAOhB,MAAM,SAAS,CAAA;AAEhB,OAAO,EAIL,sBAAsB,EAKvB,MAAM,SAAS,CAAA;AAUhB,QAAA,MAAM,YAAY;IAChB,MAAM;IACN,IAAI;CACL,CAAA;AAED,eAAO,MAAM,mBAAmB,SACxB,MAAM,OAAO,YAAY,cACnB,yBAAyB,KACpC,iBAUF,CAAA;AAED,MAAM,MAAM,qBAAqB,GAAG;IAClC,CAAC,IAAI,EAAE,MAAM,GAAG,uBAAuB,CAAA;CACxC,CAAA;AAED,KAAK,0BAA0B,GAAG;IAChC,MAAM,EAAE,eAAe,CAAA;IACvB,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,aAAa,EAAE,WAAW,CAAA;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,iBAAiB,EAAE,OAAO,CAAA;IAC1B,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,wBAAgB,sBAAsB,CAAC,EACrC,IAAI,EACJ,MAAM,EACN,MAAM,EACN,aAAqB,EACrB,aAAa,EACb,iBAAiB,EACjB,UAAU,GACX,EAAE,0BAA0B,GAAG,sBAAsB,GAAG,IAAI,CA0W5D"}
1
+ {"version":3,"file":"buildMutationInputType.d.ts","sourceRoot":"","sources":["../../src/schema/buildMutationInputType.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,iBAAiB,EAAe,MAAM,SAAS,CAAA;AACtF,OAAO,KAAK,EAQV,KAAK,EACL,WAAW,EASX,yBAAyB,EACzB,eAAe,EAOhB,MAAM,SAAS,CAAA;AAEhB,OAAO,EAIL,sBAAsB,EAKvB,MAAM,SAAS,CAAA;AAkChB,QAAA,MAAM,YAAY;IAChB,MAAM;IACN,IAAI;CACL,CAAA;AAED,eAAO,MAAM,mBAAmB,SACxB,MAAM,OAAO,YAAY,cACnB,yBAAyB,KACpC,iBAUF,CAAA;AAED,MAAM,MAAM,qBAAqB,GAAG;IAClC,CAAC,IAAI,EAAE,MAAM,GAAG,uBAAuB,CAAA;CACxC,CAAA;AAED,KAAK,0BAA0B,GAAG;IAChC,MAAM,EAAE,eAAe,CAAA;IACvB,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,aAAa,EAAE,WAAW,CAAA;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,iBAAiB,EAAE,OAAO,CAAA;IAC1B,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,wBAAgB,sBAAsB,CAAC,EACrC,IAAI,EACJ,MAAM,EACN,MAAM,EACN,aAAqB,EACrB,aAAa,EACb,iBAAiB,EACjB,UAAU,GACX,EAAE,0BAA0B,GAAG,sBAAsB,GAAG,IAAI,CA0U5D"}
@@ -6,6 +6,18 @@ import { combineParentName } from '../utilities/combineParentName.js';
6
6
  import { formatName } from '../utilities/formatName.js';
7
7
  import { groupOrTabHasRequiredSubfield } from '../utilities/groupOrTabHasRequiredSubfield.js';
8
8
  import { withNullableType } from './withNullableType.js';
9
+ function buildMutationInputFields({ fields, fieldToSchemaMap, initialInputFields = {} }) {
10
+ return fields.reduce((inputFields, field)=>{
11
+ if ('hidden' in field && field.hidden) {
12
+ return inputFields;
13
+ }
14
+ const buildFieldSchema = fieldToSchemaMap[field.type];
15
+ return typeof buildFieldSchema === 'function' ? {
16
+ ...inputFields,
17
+ ...buildFieldSchema(inputFields, field)
18
+ } : inputFields;
19
+ }, initialInputFields);
20
+ }
9
21
  const idFieldTypes = {
10
22
  number: GraphQLInt,
11
23
  text: GraphQLString
@@ -80,13 +92,11 @@ export function buildMutationInputType({ name, config, fields, forceNullable = f
80
92
  })
81
93
  }
82
94
  }),
83
- collapsible: (inputObjectTypeConfig, field)=>field.fields.reduce((acc, subField)=>{
84
- const addSubField = fieldToSchemaMap[subField.type];
85
- if (addSubField) {
86
- return addSubField(acc, subField);
87
- }
88
- return acc;
89
- }, inputObjectTypeConfig),
95
+ collapsible: (inputObjectTypeConfig, field)=>buildMutationInputFields({
96
+ fields: field.fields,
97
+ fieldToSchemaMap,
98
+ initialInputFields: inputObjectTypeConfig
99
+ }),
90
100
  date: (inputObjectTypeConfig, field)=>({
91
101
  ...inputObjectTypeConfig,
92
102
  [formatName(field.name)]: {
@@ -135,13 +145,11 @@ export function buildMutationInputType({ name, config, fields, forceNullable = f
135
145
  }
136
146
  };
137
147
  } else {
138
- return field.fields.reduce((acc, subField)=>{
139
- const addSubField = fieldToSchemaMap[subField.type];
140
- if (addSubField) {
141
- return addSubField(acc, subField);
142
- }
143
- return acc;
144
- }, inputObjectTypeConfig);
148
+ return buildMutationInputFields({
149
+ fields: field.fields,
150
+ fieldToSchemaMap,
151
+ initialInputFields: inputObjectTypeConfig
152
+ });
145
153
  }
146
154
  },
147
155
  json: (inputObjectTypeConfig, field)=>({
@@ -236,13 +244,11 @@ export function buildMutationInputType({ name, config, fields, forceNullable = f
236
244
  })
237
245
  }
238
246
  }),
239
- row: (inputObjectTypeConfig, field)=>field.fields.reduce((acc, subField)=>{
240
- const addSubField = fieldToSchemaMap[subField.type];
241
- if (addSubField) {
242
- return addSubField(acc, subField);
243
- }
244
- return acc;
245
- }, inputObjectTypeConfig),
247
+ row: (inputObjectTypeConfig, field)=>buildMutationInputFields({
248
+ fields: field.fields,
249
+ fieldToSchemaMap,
250
+ initialInputFields: inputObjectTypeConfig
251
+ }),
246
252
  select: (inputObjectTypeConfig, field)=>{
247
253
  const formattedName = `${combineParentName(parentName, field.name)}_MutationInput`;
248
254
  let type = new GraphQLEnumType({
@@ -305,16 +311,11 @@ export function buildMutationInputType({ name, config, fields, forceNullable = f
305
311
  }
306
312
  };
307
313
  }
308
- return {
309
- ...acc,
310
- ...tab.fields.reduce((subFieldSchema, subField)=>{
311
- const addSubField = fieldToSchemaMap[subField.type];
312
- if (addSubField) {
313
- return addSubField(subFieldSchema, subField);
314
- }
315
- return subFieldSchema;
316
- }, acc)
317
- };
314
+ return buildMutationInputFields({
315
+ fields: tab.fields,
316
+ fieldToSchemaMap,
317
+ initialInputFields: acc
318
+ });
318
319
  }, inputObjectTypeConfig);
319
320
  },
320
321
  text: (inputObjectTypeConfig, field)=>({
@@ -375,23 +376,10 @@ export function buildMutationInputType({ name, config, fields, forceNullable = f
375
376
  }
376
377
  };
377
378
  const fieldName = formatName(name);
378
- const fieldSchemas = fields.reduce((inputObjectTypeConfig, field)=>{
379
- if ('hidden' in field && field.hidden) {
380
- return inputObjectTypeConfig;
381
- }
382
- const fieldSchema = fieldToSchemaMap[field.type];
383
- if (typeof fieldSchema !== 'function') {
384
- return inputObjectTypeConfig;
385
- }
386
- const schema = fieldSchema(inputObjectTypeConfig, field);
387
- if (Object.keys(schema).length === 0) {
388
- return inputObjectTypeConfig;
389
- }
390
- return {
391
- ...inputObjectTypeConfig,
392
- ...fieldSchema(inputObjectTypeConfig, field)
393
- };
394
- }, {});
379
+ const fieldSchemas = buildMutationInputFields({
380
+ fields,
381
+ fieldToSchemaMap
382
+ });
395
383
  if (Object.keys(fieldSchemas).length === 0) {
396
384
  return null;
397
385
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/schema/buildMutationInputType.ts"],"sourcesContent":["import type { GraphQLInputFieldConfig, GraphQLScalarType, GraphQLType } from 'graphql'\nimport type {\n ArrayField,\n BlocksField,\n CheckboxField,\n CodeField,\n CollapsibleField,\n DateField,\n EmailField,\n Field,\n GraphQLInfo,\n GroupField,\n JSONField,\n NumberField,\n PointField,\n RadioField,\n RelationshipField,\n RichTextField,\n RowField,\n SanitizedCollectionConfig,\n SanitizedConfig,\n SelectField,\n SlugField,\n TabsField,\n TextareaField,\n TextField,\n UploadField,\n} from 'payload'\n\nimport {\n GraphQLBoolean,\n GraphQLEnumType,\n GraphQLFloat,\n GraphQLInputObjectType,\n GraphQLInt,\n GraphQLList,\n GraphQLNonNull,\n GraphQLString,\n} from 'graphql'\nimport { flattenTopLevelFields, toWords } from 'payload'\nimport { fieldAffectsData, optionIsObject, tabHasName } from 'payload/shared'\n\nimport { GraphQLJSON } from '../packages/graphql-type-json/index.js'\nimport { combineParentName } from '../utilities/combineParentName.js'\nimport { formatName } from '../utilities/formatName.js'\nimport { groupOrTabHasRequiredSubfield } from '../utilities/groupOrTabHasRequiredSubfield.js'\nimport { withNullableType } from './withNullableType.js'\n\nconst idFieldTypes = {\n number: GraphQLInt,\n text: GraphQLString,\n}\n\nexport const getCollectionIDType = (\n type: keyof typeof idFieldTypes,\n collection: SanitizedCollectionConfig,\n): GraphQLScalarType => {\n const idField = flattenTopLevelFields(collection.fields).find(\n (field) => fieldAffectsData(field) && field.name === 'id',\n )\n\n if (!idField) {\n return idFieldTypes[type]\n }\n\n return idFieldTypes[idField.type]\n}\n\nexport type InputObjectTypeConfig = {\n [path: string]: GraphQLInputFieldConfig\n}\n\ntype BuildMutationInputTypeArgs = {\n config: SanitizedConfig\n fields: Field[]\n forceNullable?: boolean\n graphqlResult: GraphQLInfo\n name: string\n parentIsLocalized: boolean\n parentName: string\n}\n\nexport function buildMutationInputType({\n name,\n config,\n fields,\n forceNullable = false,\n graphqlResult,\n parentIsLocalized,\n parentName,\n}: BuildMutationInputTypeArgs): GraphQLInputObjectType | null {\n const fieldToSchemaMap = {\n slug: (inputObjectTypeConfig: InputObjectTypeConfig, field: SlugField) => ({\n ...inputObjectTypeConfig,\n [formatName(field.name)]: {\n type: withNullableType({ type: GraphQLString, field, forceNullable, parentIsLocalized }),\n },\n }),\n array: (inputObjectTypeConfig: InputObjectTypeConfig, field: ArrayField) => {\n const fullName = combineParentName(parentName, toWords(field.name, true))\n let type: GraphQLList<GraphQLType> | GraphQLType = buildMutationInputType({\n name: fullName,\n config,\n fields: field.fields,\n forceNullable,\n graphqlResult,\n parentIsLocalized: parentIsLocalized || field.localized,\n parentName: fullName,\n })\n\n if (!type) {\n return inputObjectTypeConfig\n }\n\n type = new GraphQLList(withNullableType({ type, field, forceNullable, parentIsLocalized }))\n return {\n ...inputObjectTypeConfig,\n [formatName(field.name)]: { type },\n }\n },\n blocks: (inputObjectTypeConfig: InputObjectTypeConfig, field: BlocksField) => ({\n ...inputObjectTypeConfig,\n [formatName(field.name)]: { type: GraphQLJSON },\n }),\n checkbox: (inputObjectTypeConfig: InputObjectTypeConfig, field: CheckboxField) => ({\n ...inputObjectTypeConfig,\n [formatName(field.name)]: { type: GraphQLBoolean },\n }),\n code: (inputObjectTypeConfig: InputObjectTypeConfig, field: CodeField) => ({\n ...inputObjectTypeConfig,\n [formatName(field.name)]: {\n type: withNullableType({ type: GraphQLString, field, forceNullable, parentIsLocalized }),\n },\n }),\n collapsible: (inputObjectTypeConfig: InputObjectTypeConfig, field: CollapsibleField) =>\n field.fields.reduce((acc, subField: CollapsibleField) => {\n const addSubField = fieldToSchemaMap[subField.type]\n if (addSubField) {\n return addSubField(acc, subField)\n }\n return acc\n }, inputObjectTypeConfig),\n date: (inputObjectTypeConfig: InputObjectTypeConfig, field: DateField) => ({\n ...inputObjectTypeConfig,\n [formatName(field.name)]: {\n type: withNullableType({ type: GraphQLString, field, forceNullable, parentIsLocalized }),\n },\n }),\n email: (inputObjectTypeConfig: InputObjectTypeConfig, field: EmailField) => ({\n ...inputObjectTypeConfig,\n [formatName(field.name)]: {\n type: withNullableType({ type: GraphQLString, field, forceNullable, parentIsLocalized }),\n },\n }),\n group: (inputObjectTypeConfig: InputObjectTypeConfig, field: GroupField) => {\n if (fieldAffectsData(field)) {\n const requiresAtLeastOneField = groupOrTabHasRequiredSubfield(field)\n const fullName = combineParentName(parentName, toWords(field.name, true))\n let type: GraphQLType = buildMutationInputType({\n name: fullName,\n config,\n fields: field.fields,\n forceNullable,\n graphqlResult,\n parentIsLocalized: parentIsLocalized || field.localized,\n parentName: fullName,\n })\n\n if (!type) {\n return inputObjectTypeConfig\n }\n\n if (requiresAtLeastOneField && !forceNullable) {\n type = new GraphQLNonNull(type)\n }\n return {\n ...inputObjectTypeConfig,\n [formatName(field.name)]: { type },\n }\n } else {\n return field.fields.reduce((acc, subField: CollapsibleField) => {\n const addSubField = fieldToSchemaMap[subField.type]\n if (addSubField) {\n return addSubField(acc, subField)\n }\n return acc\n }, inputObjectTypeConfig)\n }\n },\n json: (inputObjectTypeConfig: InputObjectTypeConfig, field: JSONField) => ({\n ...inputObjectTypeConfig,\n [formatName(field.name)]: {\n type: withNullableType({ type: GraphQLJSON, field, forceNullable, parentIsLocalized }),\n },\n }),\n number: (inputObjectTypeConfig: InputObjectTypeConfig, field: NumberField) => {\n const type = field.name === 'id' ? GraphQLInt : GraphQLFloat\n return {\n ...inputObjectTypeConfig,\n [formatName(field.name)]: {\n type: withNullableType({\n type: field.hasMany === true ? new GraphQLList(type) : type,\n field,\n forceNullable,\n parentIsLocalized,\n }),\n },\n }\n },\n point: (inputObjectTypeConfig: InputObjectTypeConfig, field: PointField) => ({\n ...inputObjectTypeConfig,\n [formatName(field.name)]: {\n type: withNullableType({\n type: new GraphQLList(GraphQLFloat),\n field,\n forceNullable,\n parentIsLocalized,\n }),\n },\n }),\n radio: (inputObjectTypeConfig: InputObjectTypeConfig, field: RadioField) => ({\n ...inputObjectTypeConfig,\n [formatName(field.name)]: {\n type: withNullableType({ type: GraphQLString, field, forceNullable, parentIsLocalized }),\n },\n }),\n relationship: (inputObjectTypeConfig: InputObjectTypeConfig, field: RelationshipField) => {\n const { relationTo } = field\n type PayloadGraphQLRelationshipType =\n | GraphQLInputObjectType\n | GraphQLList<GraphQLScalarType>\n | GraphQLScalarType\n let type: PayloadGraphQLRelationshipType\n\n if (Array.isArray(relationTo)) {\n const fullName = `${combineParentName(\n parentName,\n toWords(field.name, true),\n )}RelationshipInput`\n type = new GraphQLInputObjectType({\n name: fullName,\n fields: {\n relationTo: {\n type: new GraphQLEnumType({\n name: `${fullName}RelationTo`,\n values: relationTo.reduce(\n (values, option) => ({\n ...values,\n [formatName(option)]: {\n value: option,\n },\n }),\n {},\n ),\n }),\n },\n value: { type: GraphQLJSON },\n },\n })\n } else {\n type = getCollectionIDType(\n config.db.defaultIDType,\n graphqlResult.collections[relationTo].config,\n )\n }\n\n return {\n ...inputObjectTypeConfig,\n [formatName(field.name)]: { type: field.hasMany ? new GraphQLList(type) : type },\n }\n },\n richText: (inputObjectTypeConfig: InputObjectTypeConfig, field: RichTextField) => ({\n ...inputObjectTypeConfig,\n [formatName(field.name)]: {\n type: withNullableType({ type: GraphQLJSON, field, forceNullable, parentIsLocalized }),\n },\n }),\n row: (inputObjectTypeConfig: InputObjectTypeConfig, field: RowField) =>\n field.fields.reduce((acc, subField: Field) => {\n const addSubField = fieldToSchemaMap[subField.type]\n if (addSubField) {\n return addSubField(acc, subField)\n }\n return acc\n }, inputObjectTypeConfig),\n select: (inputObjectTypeConfig: InputObjectTypeConfig, field: SelectField) => {\n const formattedName = `${combineParentName(parentName, field.name)}_MutationInput`\n let type: GraphQLType = new GraphQLEnumType({\n name: formattedName,\n values: field.options.reduce((values, option) => {\n if (optionIsObject(option)) {\n return {\n ...values,\n [formatName(option.value)]: {\n value: option.value,\n },\n }\n }\n\n return {\n ...values,\n [formatName(option)]: {\n value: option,\n },\n }\n }, {}),\n })\n\n type = field.hasMany ? new GraphQLList(type) : type\n type = withNullableType({ type, field, forceNullable, parentIsLocalized })\n\n return {\n ...inputObjectTypeConfig,\n [formatName(field.name)]: { type },\n }\n },\n tabs: (inputObjectTypeConfig: InputObjectTypeConfig, field: TabsField) => {\n return field.tabs.reduce((acc, tab) => {\n if (tabHasName(tab)) {\n const fullName = combineParentName(parentName, toWords(tab.name, true))\n const requiresAtLeastOneField = groupOrTabHasRequiredSubfield(field)\n let type: GraphQLType = buildMutationInputType({\n name: fullName,\n config,\n fields: tab.fields,\n forceNullable,\n graphqlResult,\n parentIsLocalized: parentIsLocalized || tab.localized,\n parentName: fullName,\n })\n\n if (!type) {\n return acc\n }\n\n if (requiresAtLeastOneField && !forceNullable) {\n type = new GraphQLNonNull(type)\n }\n return {\n ...acc,\n [tab.name]: { type },\n }\n }\n\n return {\n ...acc,\n ...tab.fields.reduce((subFieldSchema, subField) => {\n const addSubField = fieldToSchemaMap[subField.type]\n if (addSubField) {\n return addSubField(subFieldSchema, subField)\n }\n return subFieldSchema\n }, acc),\n }\n }, inputObjectTypeConfig)\n },\n text: (inputObjectTypeConfig: InputObjectTypeConfig, field: TextField) => ({\n ...inputObjectTypeConfig,\n [formatName(field.name)]: {\n type: withNullableType({\n type: field.hasMany === true ? new GraphQLList(GraphQLString) : GraphQLString,\n field,\n forceNullable,\n parentIsLocalized,\n }),\n },\n }),\n textarea: (inputObjectTypeConfig: InputObjectTypeConfig, field: TextareaField) => ({\n ...inputObjectTypeConfig,\n [formatName(field.name)]: {\n type: withNullableType({ type: GraphQLString, field, forceNullable, parentIsLocalized }),\n },\n }),\n upload: (inputObjectTypeConfig: InputObjectTypeConfig, field: UploadField) => {\n const { relationTo } = field\n type PayloadGraphQLRelationshipType =\n | GraphQLInputObjectType\n | GraphQLList<GraphQLScalarType>\n | GraphQLScalarType\n let type: PayloadGraphQLRelationshipType\n\n if (Array.isArray(relationTo)) {\n const fullName = `${combineParentName(\n parentName,\n toWords(field.name, true),\n )}RelationshipInput`\n type = new GraphQLInputObjectType({\n name: fullName,\n fields: {\n relationTo: {\n type: new GraphQLEnumType({\n name: `${fullName}RelationTo`,\n values: relationTo.reduce(\n (values, option) => ({\n ...values,\n [formatName(option)]: {\n value: option,\n },\n }),\n {},\n ),\n }),\n },\n value: { type: GraphQLJSON },\n },\n })\n } else {\n type = getCollectionIDType(\n config.db.defaultIDType,\n graphqlResult.collections[relationTo].config,\n )\n }\n\n return {\n ...inputObjectTypeConfig,\n [formatName(field.name)]: { type: field.hasMany ? new GraphQLList(type) : type },\n }\n },\n }\n\n const fieldName = formatName(name)\n\n const fieldSchemas = fields.reduce((inputObjectTypeConfig, field) => {\n if ('hidden' in field && field.hidden) {\n return inputObjectTypeConfig\n }\n\n const fieldSchema = fieldToSchemaMap[field.type]\n\n if (typeof fieldSchema !== 'function') {\n return inputObjectTypeConfig\n }\n\n const schema = fieldSchema(inputObjectTypeConfig, field)\n if (Object.keys(schema).length === 0) {\n return inputObjectTypeConfig\n }\n\n return {\n ...inputObjectTypeConfig,\n ...fieldSchema(inputObjectTypeConfig, field),\n }\n }, {})\n\n if (Object.keys(fieldSchemas).length === 0) {\n return null\n }\n\n return new GraphQLInputObjectType({\n name: `mutation${fieldName}Input`,\n fields: fieldSchemas,\n })\n}\n"],"names":["GraphQLBoolean","GraphQLEnumType","GraphQLFloat","GraphQLInputObjectType","GraphQLInt","GraphQLList","GraphQLNonNull","GraphQLString","flattenTopLevelFields","toWords","fieldAffectsData","optionIsObject","tabHasName","GraphQLJSON","combineParentName","formatName","groupOrTabHasRequiredSubfield","withNullableType","idFieldTypes","number","text","getCollectionIDType","type","collection","idField","fields","find","field","name","buildMutationInputType","config","forceNullable","graphqlResult","parentIsLocalized","parentName","fieldToSchemaMap","slug","inputObjectTypeConfig","array","fullName","localized","blocks","checkbox","code","collapsible","reduce","acc","subField","addSubField","date","email","group","requiresAtLeastOneField","json","hasMany","point","radio","relationship","relationTo","Array","isArray","values","option","value","db","defaultIDType","collections","richText","row","select","formattedName","options","tabs","tab","subFieldSchema","textarea","upload","fieldName","fieldSchemas","hidden","fieldSchema","schema","Object","keys","length"],"mappings":"AA6BA,SACEA,cAAc,EACdC,eAAe,EACfC,YAAY,EACZC,sBAAsB,EACtBC,UAAU,EACVC,WAAW,EACXC,cAAc,EACdC,aAAa,QACR,UAAS;AAChB,SAASC,qBAAqB,EAAEC,OAAO,QAAQ,UAAS;AACxD,SAASC,gBAAgB,EAAEC,cAAc,EAAEC,UAAU,QAAQ,iBAAgB;AAE7E,SAASC,WAAW,QAAQ,yCAAwC;AACpE,SAASC,iBAAiB,QAAQ,oCAAmC;AACrE,SAASC,UAAU,QAAQ,6BAA4B;AACvD,SAASC,6BAA6B,QAAQ,gDAA+C;AAC7F,SAASC,gBAAgB,QAAQ,wBAAuB;AAExD,MAAMC,eAAe;IACnBC,QAAQf;IACRgB,MAAMb;AACR;AAEA,OAAO,MAAMc,sBAAsB,CACjCC,MACAC;IAEA,MAAMC,UAAUhB,sBAAsBe,WAAWE,MAAM,EAAEC,IAAI,CAC3D,CAACC,QAAUjB,iBAAiBiB,UAAUA,MAAMC,IAAI,KAAK;IAGvD,IAAI,CAACJ,SAAS;QACZ,OAAON,YAAY,CAACI,KAAK;IAC3B;IAEA,OAAOJ,YAAY,CAACM,QAAQF,IAAI,CAAC;AACnC,EAAC;AAgBD,OAAO,SAASO,uBAAuB,EACrCD,IAAI,EACJE,MAAM,EACNL,MAAM,EACNM,gBAAgB,KAAK,EACrBC,aAAa,EACbC,iBAAiB,EACjBC,UAAU,EACiB;IAC3B,MAAMC,mBAAmB;QACvBC,MAAM,CAACC,uBAA8CV,QAAsB,CAAA;gBACzE,GAAGU,qBAA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F;wBACAC,OAAO;4BAAEzC,MAAMT;wBAAY;oBAC7B;gBACF;YACF,OAAO;gBACLS,OAAOD,oBACLS,OAAOkC,EAAE,CAACC,aAAa,EACvBjC,cAAckC,WAAW,CAACR,WAAW,CAAC5B,MAAM;YAEhD;YAEA,OAAO;gBACL,GAAGO,qBAAqB;gBACxB,CAACtB,WAAWY,MAAMC,IAAI,EAAE,EAAE;oBAAEN,MAAMK,MAAM2B,OAAO,GAAG,IAAIjD,YAAYiB,QAAQA;gBAAK;YACjF;QACF;IACF;IAEA,MAAMuD,YAAY9D,WAAWa;IAE7B,MAAMkD,eAAerD,OAAOoB,MAAM,CAAC,CAACR,uBAAuBV;QACzD,IAAI,YAAYA,SAASA,MAAMoD,MAAM,EAAE;YACrC,OAAO1C;QACT;QAEA,MAAM2C,cAAc7C,gBAAgB,CAACR,MAAML,IAAI,CAAC;QAEhD,IAAI,OAAO0D,gBAAgB,YAAY;YACrC,OAAO3C;QACT;QAEA,MAAM4C,SAASD,YAAY3C,uBAAuBV;QAClD,IAAIuD,OAAOC,IAAI,CAACF,QAAQG,MAAM,KAAK,GAAG;YACpC,OAAO/C;QACT;QAEA,OAAO;YACL,GAAGA,qBAAqB;YACxB,GAAG2C,YAAY3C,uBAAuBV,MAAM;QAC9C;IACF,GAAG,CAAC;IAEJ,IAAIuD,OAAOC,IAAI,CAACL,cAAcM,MAAM,KAAK,GAAG;QAC1C,OAAO;IACT;IAEA,OAAO,IAAIjF,uBAAuB;QAChCyB,MAAM,CAAC,QAAQ,EAAEiD,UAAU,KAAK,CAAC;QACjCpD,QAAQqD;IACV;AACF"}
1
+ {"version":3,"sources":["../../src/schema/buildMutationInputType.ts"],"sourcesContent":["import type { GraphQLInputFieldConfig, GraphQLScalarType, GraphQLType } from 'graphql'\nimport type {\n ArrayField,\n BlocksField,\n CheckboxField,\n CodeField,\n CollapsibleField,\n DateField,\n EmailField,\n Field,\n GraphQLInfo,\n GroupField,\n JSONField,\n NumberField,\n PointField,\n RadioField,\n RelationshipField,\n RichTextField,\n RowField,\n SanitizedCollectionConfig,\n SanitizedConfig,\n SelectField,\n SlugField,\n TabsField,\n TextareaField,\n TextField,\n UploadField,\n} from 'payload'\n\nimport {\n GraphQLBoolean,\n GraphQLEnumType,\n GraphQLFloat,\n GraphQLInputObjectType,\n GraphQLInt,\n GraphQLList,\n GraphQLNonNull,\n GraphQLString,\n} from 'graphql'\nimport { flattenTopLevelFields, toWords } from 'payload'\nimport { fieldAffectsData, optionIsObject, tabHasName } from 'payload/shared'\n\nimport { GraphQLJSON } from '../packages/graphql-type-json/index.js'\nimport { combineParentName } from '../utilities/combineParentName.js'\nimport { formatName } from '../utilities/formatName.js'\nimport { groupOrTabHasRequiredSubfield } from '../utilities/groupOrTabHasRequiredSubfield.js'\nimport { withNullableType } from './withNullableType.js'\n\nfunction buildMutationInputFields({\n fields,\n fieldToSchemaMap,\n initialInputFields = {},\n}: {\n fields: Field[]\n fieldToSchemaMap: Partial<\n Record<Field['type'], (inputFields: InputObjectTypeConfig, field: Field) => object>\n >\n initialInputFields?: InputObjectTypeConfig\n}): InputObjectTypeConfig {\n return fields.reduce((inputFields, field) => {\n if ('hidden' in field && field.hidden) {\n return inputFields\n }\n\n const buildFieldSchema = fieldToSchemaMap[field.type]\n\n return typeof buildFieldSchema === 'function'\n ? { ...inputFields, ...buildFieldSchema(inputFields, field) }\n : inputFields\n }, initialInputFields)\n}\n\nconst idFieldTypes = {\n number: GraphQLInt,\n text: GraphQLString,\n}\n\nexport const getCollectionIDType = (\n type: keyof typeof idFieldTypes,\n collection: SanitizedCollectionConfig,\n): GraphQLScalarType => {\n const idField = flattenTopLevelFields(collection.fields).find(\n (field) => fieldAffectsData(field) && field.name === 'id',\n )\n\n if (!idField) {\n return idFieldTypes[type]\n }\n\n return idFieldTypes[idField.type]\n}\n\nexport type InputObjectTypeConfig = {\n [path: string]: GraphQLInputFieldConfig\n}\n\ntype BuildMutationInputTypeArgs = {\n config: SanitizedConfig\n fields: Field[]\n forceNullable?: boolean\n graphqlResult: GraphQLInfo\n name: string\n parentIsLocalized: boolean\n parentName: string\n}\n\nexport function buildMutationInputType({\n name,\n config,\n fields,\n forceNullable = false,\n graphqlResult,\n parentIsLocalized,\n parentName,\n}: BuildMutationInputTypeArgs): GraphQLInputObjectType | null {\n const fieldToSchemaMap = {\n slug: (inputObjectTypeConfig: InputObjectTypeConfig, field: SlugField) => ({\n ...inputObjectTypeConfig,\n [formatName(field.name)]: {\n type: withNullableType({ type: GraphQLString, field, forceNullable, parentIsLocalized }),\n },\n }),\n array: (inputObjectTypeConfig: InputObjectTypeConfig, field: ArrayField) => {\n const fullName = combineParentName(parentName, toWords(field.name, true))\n let type: GraphQLList<GraphQLType> | GraphQLType = buildMutationInputType({\n name: fullName,\n config,\n fields: field.fields,\n forceNullable,\n graphqlResult,\n parentIsLocalized: parentIsLocalized || field.localized,\n parentName: fullName,\n })\n\n if (!type) {\n return inputObjectTypeConfig\n }\n\n type = new GraphQLList(withNullableType({ type, field, forceNullable, parentIsLocalized }))\n return {\n ...inputObjectTypeConfig,\n [formatName(field.name)]: { type },\n }\n },\n blocks: (inputObjectTypeConfig: InputObjectTypeConfig, field: BlocksField) => ({\n ...inputObjectTypeConfig,\n [formatName(field.name)]: { type: GraphQLJSON },\n }),\n checkbox: (inputObjectTypeConfig: InputObjectTypeConfig, field: CheckboxField) => ({\n ...inputObjectTypeConfig,\n [formatName(field.name)]: { type: GraphQLBoolean },\n }),\n code: (inputObjectTypeConfig: InputObjectTypeConfig, field: CodeField) => ({\n ...inputObjectTypeConfig,\n [formatName(field.name)]: {\n type: withNullableType({ type: GraphQLString, field, forceNullable, parentIsLocalized }),\n },\n }),\n collapsible: (inputObjectTypeConfig: InputObjectTypeConfig, field: CollapsibleField) =>\n buildMutationInputFields({\n fields: field.fields,\n fieldToSchemaMap,\n initialInputFields: inputObjectTypeConfig,\n }),\n date: (inputObjectTypeConfig: InputObjectTypeConfig, field: DateField) => ({\n ...inputObjectTypeConfig,\n [formatName(field.name)]: {\n type: withNullableType({ type: GraphQLString, field, forceNullable, parentIsLocalized }),\n },\n }),\n email: (inputObjectTypeConfig: InputObjectTypeConfig, field: EmailField) => ({\n ...inputObjectTypeConfig,\n [formatName(field.name)]: {\n type: withNullableType({ type: GraphQLString, field, forceNullable, parentIsLocalized }),\n },\n }),\n group: (inputObjectTypeConfig: InputObjectTypeConfig, field: GroupField) => {\n if (fieldAffectsData(field)) {\n const requiresAtLeastOneField = groupOrTabHasRequiredSubfield(field)\n const fullName = combineParentName(parentName, toWords(field.name, true))\n let type: GraphQLType = buildMutationInputType({\n name: fullName,\n config,\n fields: field.fields,\n forceNullable,\n graphqlResult,\n parentIsLocalized: parentIsLocalized || field.localized,\n parentName: fullName,\n })\n\n if (!type) {\n return inputObjectTypeConfig\n }\n\n if (requiresAtLeastOneField && !forceNullable) {\n type = new GraphQLNonNull(type)\n }\n return {\n ...inputObjectTypeConfig,\n [formatName(field.name)]: { type },\n }\n } else {\n return buildMutationInputFields({\n fields: field.fields,\n fieldToSchemaMap,\n initialInputFields: inputObjectTypeConfig,\n })\n }\n },\n json: (inputObjectTypeConfig: InputObjectTypeConfig, field: JSONField) => ({\n ...inputObjectTypeConfig,\n [formatName(field.name)]: {\n type: withNullableType({ type: GraphQLJSON, field, forceNullable, parentIsLocalized }),\n },\n }),\n number: (inputObjectTypeConfig: InputObjectTypeConfig, field: NumberField) => {\n const type = field.name === 'id' ? GraphQLInt : GraphQLFloat\n return {\n ...inputObjectTypeConfig,\n [formatName(field.name)]: {\n type: withNullableType({\n type: field.hasMany === true ? new GraphQLList(type) : type,\n field,\n forceNullable,\n parentIsLocalized,\n }),\n },\n }\n },\n point: (inputObjectTypeConfig: InputObjectTypeConfig, field: PointField) => ({\n ...inputObjectTypeConfig,\n [formatName(field.name)]: {\n type: withNullableType({\n type: new GraphQLList(GraphQLFloat),\n field,\n forceNullable,\n parentIsLocalized,\n }),\n },\n }),\n radio: (inputObjectTypeConfig: InputObjectTypeConfig, field: RadioField) => ({\n ...inputObjectTypeConfig,\n [formatName(field.name)]: {\n type: withNullableType({ type: GraphQLString, field, forceNullable, parentIsLocalized }),\n },\n }),\n relationship: (inputObjectTypeConfig: InputObjectTypeConfig, field: RelationshipField) => {\n const { relationTo } = field\n type PayloadGraphQLRelationshipType =\n | GraphQLInputObjectType\n | GraphQLList<GraphQLScalarType>\n | GraphQLScalarType\n let type: PayloadGraphQLRelationshipType\n\n if (Array.isArray(relationTo)) {\n const fullName = `${combineParentName(\n parentName,\n toWords(field.name, true),\n )}RelationshipInput`\n type = new GraphQLInputObjectType({\n name: fullName,\n fields: {\n relationTo: {\n type: new GraphQLEnumType({\n name: `${fullName}RelationTo`,\n values: relationTo.reduce(\n (values, option) => ({\n ...values,\n [formatName(option)]: {\n value: option,\n },\n }),\n {},\n ),\n }),\n },\n value: { type: GraphQLJSON },\n },\n })\n } else {\n type = getCollectionIDType(\n config.db.defaultIDType,\n graphqlResult.collections[relationTo].config,\n )\n }\n\n return {\n ...inputObjectTypeConfig,\n [formatName(field.name)]: { type: field.hasMany ? new GraphQLList(type) : type },\n }\n },\n richText: (inputObjectTypeConfig: InputObjectTypeConfig, field: RichTextField) => ({\n ...inputObjectTypeConfig,\n [formatName(field.name)]: {\n type: withNullableType({ type: GraphQLJSON, field, forceNullable, parentIsLocalized }),\n },\n }),\n row: (inputObjectTypeConfig: InputObjectTypeConfig, field: RowField) =>\n buildMutationInputFields({\n fields: field.fields,\n fieldToSchemaMap,\n initialInputFields: inputObjectTypeConfig,\n }),\n select: (inputObjectTypeConfig: InputObjectTypeConfig, field: SelectField) => {\n const formattedName = `${combineParentName(parentName, field.name)}_MutationInput`\n let type: GraphQLType = new GraphQLEnumType({\n name: formattedName,\n values: field.options.reduce((values, option) => {\n if (optionIsObject(option)) {\n return {\n ...values,\n [formatName(option.value)]: {\n value: option.value,\n },\n }\n }\n\n return {\n ...values,\n [formatName(option)]: {\n value: option,\n },\n }\n }, {}),\n })\n\n type = field.hasMany ? new GraphQLList(type) : type\n type = withNullableType({ type, field, forceNullable, parentIsLocalized })\n\n return {\n ...inputObjectTypeConfig,\n [formatName(field.name)]: { type },\n }\n },\n tabs: (inputObjectTypeConfig: InputObjectTypeConfig, field: TabsField) => {\n return field.tabs.reduce((acc, tab) => {\n if (tabHasName(tab)) {\n const fullName = combineParentName(parentName, toWords(tab.name, true))\n const requiresAtLeastOneField = groupOrTabHasRequiredSubfield(field)\n let type: GraphQLType = buildMutationInputType({\n name: fullName,\n config,\n fields: tab.fields,\n forceNullable,\n graphqlResult,\n parentIsLocalized: parentIsLocalized || tab.localized,\n parentName: fullName,\n })\n\n if (!type) {\n return acc\n }\n\n if (requiresAtLeastOneField && !forceNullable) {\n type = new GraphQLNonNull(type)\n }\n return {\n ...acc,\n [tab.name]: { type },\n }\n }\n\n return buildMutationInputFields({\n fields: tab.fields,\n fieldToSchemaMap,\n initialInputFields: acc,\n })\n }, inputObjectTypeConfig)\n },\n text: (inputObjectTypeConfig: InputObjectTypeConfig, field: TextField) => ({\n ...inputObjectTypeConfig,\n [formatName(field.name)]: {\n type: withNullableType({\n type: field.hasMany === true ? new GraphQLList(GraphQLString) : GraphQLString,\n field,\n forceNullable,\n parentIsLocalized,\n }),\n },\n }),\n textarea: (inputObjectTypeConfig: InputObjectTypeConfig, field: TextareaField) => ({\n ...inputObjectTypeConfig,\n [formatName(field.name)]: {\n type: withNullableType({ type: GraphQLString, field, forceNullable, parentIsLocalized }),\n },\n }),\n upload: (inputObjectTypeConfig: InputObjectTypeConfig, field: UploadField) => {\n const { relationTo } = field\n type PayloadGraphQLRelationshipType =\n | GraphQLInputObjectType\n | GraphQLList<GraphQLScalarType>\n | GraphQLScalarType\n let type: PayloadGraphQLRelationshipType\n\n if (Array.isArray(relationTo)) {\n const fullName = `${combineParentName(\n parentName,\n toWords(field.name, true),\n )}RelationshipInput`\n type = new GraphQLInputObjectType({\n name: fullName,\n fields: {\n relationTo: {\n type: new GraphQLEnumType({\n name: `${fullName}RelationTo`,\n values: relationTo.reduce(\n (values, option) => ({\n ...values,\n [formatName(option)]: {\n value: option,\n },\n }),\n {},\n ),\n }),\n },\n value: { type: GraphQLJSON },\n },\n })\n } else {\n type = getCollectionIDType(\n config.db.defaultIDType,\n graphqlResult.collections[relationTo].config,\n )\n }\n\n return {\n ...inputObjectTypeConfig,\n [formatName(field.name)]: { type: field.hasMany ? new GraphQLList(type) : type },\n }\n },\n }\n\n const fieldName = formatName(name)\n const fieldSchemas = buildMutationInputFields({ fields, fieldToSchemaMap })\n\n if (Object.keys(fieldSchemas).length === 0) {\n return null\n }\n\n return new GraphQLInputObjectType({\n name: `mutation${fieldName}Input`,\n fields: fieldSchemas,\n })\n}\n"],"names":["GraphQLBoolean","GraphQLEnumType","GraphQLFloat","GraphQLInputObjectType","GraphQLInt","GraphQLList","GraphQLNonNull","GraphQLString","flattenTopLevelFields","toWords","fieldAffectsData","optionIsObject","tabHasName","GraphQLJSON","combineParentName","formatName","groupOrTabHasRequiredSubfield","withNullableType","buildMutationInputFields","fields","fieldToSchemaMap","initialInputFields","reduce","inputFields","field","hidden","buildFieldSchema","type","idFieldTypes","number","text","getCollectionIDType","collection","idField","find","name","buildMutationInputType","config","forceNullable","graphqlResult","parentIsLocalized","parentName","slug","inputObjectTypeConfig","array","fullName","localized","blocks","checkbox","code","collapsible","date","email","group","requiresAtLeastOneField","json","hasMany","point","radio","relationship","relationTo","Array","isArray","values","option","value","db","defaultIDType","collections","richText","row","select","formattedName","options","tabs","acc","tab","textarea","upload","fieldName","fieldSchemas","Object","keys","length"],"mappings":"AA6BA,SACEA,cAAc,EACdC,eAAe,EACfC,YAAY,EACZC,sBAAsB,EACtBC,UAAU,EACVC,WAAW,EACXC,cAAc,EACdC,aAAa,QACR,UAAS;AAChB,SAASC,qBAAqB,EAAEC,OAAO,QAAQ,UAAS;AACxD,SAASC,gBAAgB,EAAEC,cAAc,EAAEC,UAAU,QAAQ,iBAAgB;AAE7E,SAASC,WAAW,QAAQ,yCAAwC;AACp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@ -2,17 +2,18 @@ import type { CollectionConfig, Field, GlobalConfig, SanitizedConfig } from 'pay
2
2
  import { GraphQLObjectType } from 'graphql';
3
3
  type OperationType = 'create' | 'delete' | 'read' | 'readVersions' | 'unlock' | 'update' | 'validate';
4
4
  type AccessScopes = 'docAccess' | undefined;
5
+ type ObjectTypeFields = {
6
+ [key in 'fields' | OperationType]?: {
7
+ type: GraphQLObjectType;
8
+ };
9
+ };
5
10
  type BuildEntityPolicy = {
6
11
  entityFields: Field[];
7
12
  name: string;
8
13
  operations: OperationType[];
9
14
  scope: AccessScopes;
10
15
  };
11
- export declare const buildEntityPolicy: (args: BuildEntityPolicy) => {
12
- fields: {
13
- type: GraphQLObjectType<any, any>;
14
- };
15
- };
16
+ export declare const buildEntityPolicy: (args: BuildEntityPolicy) => ObjectTypeFields;
16
17
  type BuildPolicyType = {
17
18
  scope?: AccessScopes;
18
19
  typeSuffix?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"buildPoliciesType.d.ts","sourceRoot":"","sources":["../../src/schema/buildPoliciesType.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,KAAK,EACL,YAAY,EAEZ,eAAe,EAEhB,MAAM,SAAS,CAAA;AAEhB,OAAO,EAAkC,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAM3E,KAAK,aAAa,GACd,QAAQ,GACR,QAAQ,GACR,MAAM,GACN,cAAc,GACd,QAAQ,GACR,QAAQ,GACR,UAAU,CAAA;AAEd,KAAK,YAAY,GAAG,WAAW,GAAG,SAAS,CAAA;AA6F3C,KAAK,iBAAiB,GAAG;IACvB,YAAY,EAAE,KAAK,EAAE,CAAA;IACrB,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,EAAE,aAAa,EAAE,CAAA;IAC3B,KAAK,EAAE,YAAY,CAAA;CACpB,CAAA;AACD,eAAO,MAAM,iBAAiB,SAAU,iBAAiB;;QAMnD,IAAI;;CAsBT,CAAA;AAED,KAAK,eAAe,GAA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,CACA;IACE,MAAM,EAAE,gBAAgB,CAAA;IACxB,IAAI,EAAE,YAAY,CAAA;CACnB,GACD;IACE,MAAM,EAAE,YAAY,CAAA;IACpB,IAAI,EAAE,QAAQ,CAAA;CACf,CACJ,CAAA;AACD,wBAAgB,eAAe,CAAC,IAAI,EAAE,eAAe,GAAG,iBAAiB,CAyDxE;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,eAAe,GAAG,iBAAiB,CAyC5E"}
@@ -29,11 +29,12 @@ const buildFields = (label, fieldsToBuild)=>fieldsToBuild.reduce((builtFields, f
29
29
  }
30
30
  };
31
31
  }, {});
32
- if (field.fields) {
32
+ const subFields = field.fields && buildFields(`${label}_${fieldName}`, field.fields);
33
+ if (subFields && Object.keys(subFields).length > 0) {
33
34
  objectTypeFields.fields = {
34
35
  type: new GraphQLObjectType({
35
36
  name: `${label}_${fieldName}_Fields`,
36
- fields: buildFields(`${label}_${fieldName}`, field.fields)
37
+ fields: subFields
37
38
  })
38
39
  };
39
40
  }
@@ -57,12 +58,13 @@ const buildFields = (label, fieldsToBuild)=>fieldsToBuild.reduce((builtFields, f
57
58
  if (field.type === 'tabs') {
58
59
  return field.tabs.reduce((fieldsWithTabFields, tab)=>{
59
60
  if ('name' in tab) {
60
- if (tab.fields.length) {
61
- const tabName = formatName(tab.name);
61
+ const tabName = formatName(tab.name);
62
+ const subFields = buildFields(`${label}_${tabName}`, tab.fields);
63
+ if (Object.keys(subFields).length > 0) {
62
64
  fieldsWithTabFields[tabName] = {
63
65
  type: new GraphQLObjectType({
64
66
  name: `${label}_${tabName}`,
65
- fields: buildFields(`${label}_${tabName}`, tab.fields)
67
+ fields: subFields
66
68
  })
67
69
  };
68
70
  }
@@ -82,14 +84,16 @@ const buildFields = (label, fieldsToBuild)=>fieldsToBuild.reduce((builtFields, f
82
84
  export const buildEntityPolicy = (args)=>{
83
85
  const { name, entityFields, operations, scope } = args;
84
86
  const fieldsTypeName = toWords(`${name}-${scope || ''}-Fields`, true);
85
- const fields = {
86
- fields: {
87
+ const policyFields = buildFields(fieldsTypeName, entityFields);
88
+ const fields = {};
89
+ if (Object.keys(policyFields).length > 0) {
90
+ fields.fields = {
87
91
  type: new GraphQLObjectType({
88
92
  name: fieldsTypeName,
89
- fields: buildFields(fieldsTypeName, entityFields)
93
+ fields: policyFields
90
94
  })
91
- }
92
- };
95
+ };
96
+ }
93
97
  operations.forEach((operation)=>{
94
98
  const operationTypeName = toWords(`${name}-${operation}-${scope || 'Access'}`, true);
95
99
  fields[operation] = {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/schema/buildPoliciesType.ts"],"sourcesContent":["import type {\n CollectionConfig,\n Field,\n GlobalConfig,\n SanitizedCollectionConfig,\n SanitizedConfig,\n SanitizedGlobalConfig,\n} from 'payload'\n\nimport { GraphQLBoolean, GraphQLNonNull, GraphQLObjectType } from 'graphql'\nimport { toWords } from 'payload'\n\nimport { GraphQLJSONObject } from '../packages/graphql-type-json/index.js'\nimport { formatName } from '../utilities/formatName.js'\n\ntype OperationType =\n | 'create'\n | 'delete'\n | 'read'\n | 'readVersions'\n | 'unlock'\n | 'update'\n | 'validate'\n\ntype AccessScopes = 'docAccess' | undefined\n\ntype ObjectTypeFields = {\n [key in 'fields' | OperationType]?: { type: GraphQLObjectType }\n}\n\nconst buildFields = (label, fieldsToBuild) =>\n fieldsToBuild.reduce((builtFields, field) => {\n const includeField = !field.hidden && field.type !== 'ui'\n if (includeField) {\n if (field.name) {\n const fieldName = formatName(field.name)\n\n const objectTypeFields: ObjectTypeFields = [\n 'create',\n 'read',\n 'update',\n 'delete',\n 'validate',\n ].reduce((operations, operation) => {\n const capitalizedOperation = operation.charAt(0).toUpperCase() + operation.slice(1)\n\n return {\n ...operations,\n [operation]: {\n type: new GraphQLObjectType({\n name: `${label}_${fieldName}_${capitalizedOperation}`,\n fields: {\n permission: {\n type: new GraphQLNonNull(GraphQLBoolean),\n },\n },\n }),\n },\n }\n }, {})\n\n if (field.fields) {\n objectTypeFields.fields = {\n type: new GraphQLObjectType({\n name: `${label}_${fieldName}_Fields`,\n fields: buildFields(`${label}_${fieldName}`, field.fields),\n }),\n }\n }\n\n return {\n ...builtFields,\n [formatName(field.name)]: {\n type: new GraphQLObjectType({\n name: `${label}_${fieldName}`,\n fields: objectTypeFields,\n }),\n },\n }\n }\n\n if (!field.name && field.fields && field.fields.length) {\n const subFields = buildFields(label, field.fields)\n\n return {\n ...builtFields,\n ...subFields,\n }\n }\n\n if (field.type === 'tabs') {\n return field.tabs.reduce(\n (fieldsWithTabFields, tab) => {\n if ('name' in tab) {\n if (tab.fields.length) {\n const tabName = formatName(tab.name)\n fieldsWithTabFields[tabName] = {\n type: new GraphQLObjectType({\n name: `${label}_${tabName}`,\n fields: buildFields(`${label}_${tabName}`, tab.fields),\n }),\n }\n }\n return fieldsWithTabFields\n }\n return {\n ...fieldsWithTabFields,\n ...buildFields(label, tab.fields),\n }\n },\n { ...builtFields },\n )\n }\n }\n return builtFields\n }, {})\n\ntype BuildEntityPolicy = {\n entityFields: Field[]\n name: string\n operations: OperationType[]\n scope: AccessScopes\n}\nexport const buildEntityPolicy = (args: BuildEntityPolicy) => {\n const { name, entityFields, operations, scope } = args\n\n const fieldsTypeName = toWords(`${name}-${scope || ''}-Fields`, true)\n const fields = {\n fields: {\n type: new GraphQLObjectType({\n name: fieldsTypeName,\n fields: buildFields(fieldsTypeName, entityFields),\n }),\n },\n }\n\n operations.forEach((operation) => {\n const operationTypeName = toWords(`${name}-${operation}-${scope || 'Access'}`, true)\n\n fields[operation] = {\n type: new GraphQLObjectType({\n name: operationTypeName,\n fields: {\n permission: { type: new GraphQLNonNull(GraphQLBoolean) },\n where: { type: GraphQLJSONObject },\n },\n }),\n }\n })\n\n return fields\n}\n\ntype BuildPolicyType = {\n scope?: AccessScopes\n typeSuffix?: string\n} & (\n | {\n entity: CollectionConfig\n type: 'collection'\n }\n | {\n entity: GlobalConfig\n type: 'global'\n }\n)\nexport function buildPolicyType(args: BuildPolicyType): GraphQLObjectType {\n const { type, entity, scope, typeSuffix } = args\n const { slug, fields, graphQL, versions } = entity\n\n let operations = []\n\n if (graphQL === false) {\n return null\n }\n\n if (type === 'collection') {\n operations = ['create', 'read', 'update', 'delete', 'validate']\n\n if (\n entity.auth &&\n typeof entity.auth === 'object' &&\n typeof entity.auth.maxLoginAttempts !== 'undefined' &&\n entity.auth.maxLoginAttempts !== 0\n ) {\n operations.push('unlock')\n }\n\n if (versions) {\n operations.push('readVersions')\n }\n\n const collectionTypeName = formatName(`${slug}${typeSuffix || ''}`)\n\n return new GraphQLObjectType({\n name: collectionTypeName,\n fields: buildEntityPolicy({\n name: slug,\n entityFields: fields,\n operations,\n scope,\n }),\n })\n }\n\n // else create global type\n operations = ['read', 'update', 'validate']\n\n if (entity.versions) {\n operations.push('readVersions')\n }\n\n const globalTypeName = formatName(`${global?.graphQL?.name || slug}${typeSuffix || ''}`)\n\n return new GraphQLObjectType({\n name: globalTypeName,\n fields: buildEntityPolicy({\n name: entity.graphQL ? entity?.graphQL?.name || slug : slug,\n entityFields: entity.fields,\n operations,\n scope,\n }),\n })\n}\n\nexport function buildPoliciesType(config: SanitizedConfig): GraphQLObjectType {\n const fields = {\n canAccessAdmin: {\n type: new GraphQLNonNull(GraphQLBoolean),\n },\n }\n\n Object.values(config.collections).forEach((collection: SanitizedCollectionConfig) => {\n if (collection.graphQL === false) {\n return\n }\n const collectionPolicyType = buildPolicyType({\n type: 'collection',\n entity: collection,\n typeSuffix: 'Access',\n })\n\n fields[formatName(collection.slug)] = {\n type: collectionPolicyType,\n }\n })\n\n Object.values(config.globals).forEach((global: SanitizedGlobalConfig) => {\n if (global.graphQL === false) {\n return\n }\n const globalPolicyType = buildPolicyType({\n type: 'global',\n entity: global,\n typeSuffix: 'Access',\n })\n\n fields[formatName(global.slug)] = {\n type: globalPolicyType,\n }\n })\n\n return new GraphQLObjectType({\n name: 'Access',\n fields,\n })\n}\n"],"names":["GraphQLBoolean","GraphQLNonNull","GraphQLObjectType","toWords","GraphQLJSONObject","formatName","buildFields","label","fieldsToBuild","reduce","builtFields","field","includeField","hidden","type","name","fieldName","objectTypeFields","operations","operation","capitalizedOperation","charAt","toUpperCase","slice","fields","permission","length","subFields","tabs","fieldsWithTabFields","tab","tabName","buildEntityPolicy","args","entityFields","scope","fieldsTypeName","forEach","operationTypeName","where","buildPolicyType","entity","typeSuffix","slug","graphQL","versions","auth","maxLoginAttempts","push","collectionTypeName","globalTypeName","global","buildPoliciesType","config","canAccessAdmin","Object","values","collections","collection","collectionPolicyType","globals","globalPolicyType"],"mappings":"AASA,SAASA,cAAc,EAAEC,cAAc,EAAEC,iBAAiB,QAAQ,UAAS;AAC3E,SAASC,OAAO,QAAQ,UAAS;AAEjC,SAASC,iBAAiB,QAAQ,yCAAwC;AAC1E,SAASC,UAAU,QAAQ,6BAA4B;AAiBvD,MAAMC,cAAc,CAACC,OAAOC,gBAC1BA,cAAcC,MAAM,CAAC,CAACC,aAAaC;QACjC,MAAMC,eAAe,CAACD,MAAME,MAAM,IAAIF,MAAMG,IAAI,KAAK;QACrD,IAAIF,cAAc;YAChB,IAAID,MAAMI,IAAI,EAAE;gBACd,MAAMC,YAAYX,WAAWM,MAAMI,IAAI;gBAEvC,MAAME,mBAAqC;oBACzC;oBACA;oBACA;oBACA;oBACA;iBACD,CAACR,MAAM,CAAC,CAACS,YAAYC;oBACpB,MAAMC,uBAAuBD,UAAUE,MAAM,CAAC,GAAGC,WAAW,KAAKH,UAAUI,KAAK,CAAC;oBAEjF,OAAO;wBACL,GAAGL,UAAU;wBACb,CAACC,UAAU,EAAE;4BACXL,MAAM,IAAIZ,kBAAkB;gCAC1Ba,MAAM,GAAGR,MAAM,CAAC,EAAES,UAAU,CAAC,EAAEI,sBAAsB;gCACrDI,QAAQ;oCACNC,YAAY;wCACVX,MAAM,IAAIb,eAAeD;oCAC3B;gCACF;4BACF;wBACF;oBACF;gBACF,GAAG,CAAC;gBAEJ,IAAIW,MAAMa,MAAM,EAAE;oBAChB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;YACN2B,QAAQU;YACRT,YAAY;QACd;QAEAlB,MAAM,CAACnB,WAAW8C,QAAOR,IAAI,EAAE,GAAG;YAChC7B,MAAM+C;QACR;IACF;IAEA,OAAO,IAAI3D,kBAAkB;QAC3Ba,MAAM;QACNS;IACF;AACF"}
1
+ {"version":3,"sources":["../../src/schema/buildPoliciesType.ts"],"sourcesContent":["import type {\n CollectionConfig,\n Field,\n GlobalConfig,\n SanitizedCollectionConfig,\n SanitizedConfig,\n SanitizedGlobalConfig,\n} from 'payload'\n\nimport { GraphQLBoolean, GraphQLNonNull, GraphQLObjectType } from 'graphql'\nimport { toWords } from 'payload'\n\nimport { GraphQLJSONObject } from '../packages/graphql-type-json/index.js'\nimport { formatName } from '../utilities/formatName.js'\n\ntype OperationType =\n | 'create'\n | 'delete'\n | 'read'\n | 'readVersions'\n | 'unlock'\n | 'update'\n | 'validate'\n\ntype AccessScopes = 'docAccess' | undefined\n\ntype ObjectTypeFields = {\n [key in 'fields' | OperationType]?: { type: GraphQLObjectType }\n}\n\nconst buildFields = (label, fieldsToBuild) =>\n fieldsToBuild.reduce((builtFields, field) => {\n const includeField = !field.hidden && field.type !== 'ui'\n if (includeField) {\n if (field.name) {\n const fieldName = formatName(field.name)\n\n const objectTypeFields: ObjectTypeFields = [\n 'create',\n 'read',\n 'update',\n 'delete',\n 'validate',\n ].reduce((operations, operation) => {\n const capitalizedOperation = operation.charAt(0).toUpperCase() + operation.slice(1)\n\n return {\n ...operations,\n [operation]: {\n type: new GraphQLObjectType({\n name: `${label}_${fieldName}_${capitalizedOperation}`,\n fields: {\n permission: {\n type: new GraphQLNonNull(GraphQLBoolean),\n },\n },\n }),\n },\n }\n }, {})\n\n const subFields = field.fields && buildFields(`${label}_${fieldName}`, field.fields)\n\n if (subFields && Object.keys(subFields).length > 0) {\n objectTypeFields.fields = {\n type: new GraphQLObjectType({\n name: `${label}_${fieldName}_Fields`,\n fields: subFields,\n }),\n }\n }\n\n return {\n ...builtFields,\n [formatName(field.name)]: {\n type: new GraphQLObjectType({\n name: `${label}_${fieldName}`,\n fields: objectTypeFields,\n }),\n },\n }\n }\n\n if (!field.name && field.fields && field.fields.length) {\n const subFields = buildFields(label, field.fields)\n\n return {\n ...builtFields,\n ...subFields,\n }\n }\n\n if (field.type === 'tabs') {\n return field.tabs.reduce(\n (fieldsWithTabFields, tab) => {\n if ('name' in tab) {\n const tabName = formatName(tab.name)\n const subFields = buildFields(`${label}_${tabName}`, tab.fields)\n\n if (Object.keys(subFields).length > 0) {\n fieldsWithTabFields[tabName] = {\n type: new GraphQLObjectType({\n name: `${label}_${tabName}`,\n fields: subFields,\n }),\n }\n }\n return fieldsWithTabFields\n }\n return {\n ...fieldsWithTabFields,\n ...buildFields(label, tab.fields),\n }\n },\n { ...builtFields },\n )\n }\n }\n return builtFields\n }, {})\n\ntype BuildEntityPolicy = {\n entityFields: Field[]\n name: string\n operations: OperationType[]\n scope: AccessScopes\n}\nexport const buildEntityPolicy = (args: BuildEntityPolicy) => {\n const { name, entityFields, operations, scope } = args\n\n const fieldsTypeName = toWords(`${name}-${scope || ''}-Fields`, true)\n const policyFields = buildFields(fieldsTypeName, entityFields)\n const fields: ObjectTypeFields = {}\n\n if (Object.keys(policyFields).length > 0) {\n fields.fields = {\n type: new GraphQLObjectType({\n name: fieldsTypeName,\n fields: policyFields,\n }),\n }\n }\n\n operations.forEach((operation) => {\n const operationTypeName = toWords(`${name}-${operation}-${scope || 'Access'}`, true)\n\n fields[operation] = {\n type: new GraphQLObjectType({\n name: operationTypeName,\n fields: {\n permission: { type: new GraphQLNonNull(GraphQLBoolean) },\n where: { type: GraphQLJSONObject },\n },\n }),\n }\n })\n\n return fields\n}\n\ntype BuildPolicyType = {\n scope?: AccessScopes\n typeSuffix?: string\n} & (\n | {\n entity: CollectionConfig\n type: 'collection'\n }\n | {\n entity: GlobalConfig\n type: 'global'\n }\n)\nexport function buildPolicyType(args: BuildPolicyType): GraphQLObjectType {\n const { type, entity, scope, typeSuffix } = args\n const { slug, fields, graphQL, versions } = entity\n\n let operations = []\n\n if (graphQL === false) {\n return null\n }\n\n if (type === 'collection') {\n operations = ['create', 'read', 'update', 'delete', 'validate']\n\n if (\n entity.auth &&\n typeof entity.auth === 'object' &&\n typeof entity.auth.maxLoginAttempts !== 'undefined' &&\n entity.auth.maxLoginAttempts !== 0\n ) {\n operations.push('unlock')\n }\n\n if (versions) {\n operations.push('readVersions')\n }\n\n const collectionTypeName = formatName(`${slug}${typeSuffix || ''}`)\n\n return new GraphQLObjectType({\n name: collectionTypeName,\n fields: buildEntityPolicy({\n name: slug,\n entityFields: fields,\n operations,\n scope,\n }),\n })\n }\n\n // else create global type\n operations = ['read', 'update', 'validate']\n\n if (entity.versions) {\n operations.push('readVersions')\n }\n\n const globalTypeName = formatName(`${global?.graphQL?.name || slug}${typeSuffix || ''}`)\n\n return new GraphQLObjectType({\n name: globalTypeName,\n fields: buildEntityPolicy({\n name: entity.graphQL ? entity?.graphQL?.name || slug : slug,\n entityFields: entity.fields,\n operations,\n scope,\n }),\n })\n}\n\nexport function buildPoliciesType(config: SanitizedConfig): GraphQLObjectType {\n const fields = {\n canAccessAdmin: {\n type: new GraphQLNonNull(GraphQLBoolean),\n },\n }\n\n Object.values(config.collections).forEach((collection: SanitizedCollectionConfig) => {\n if (collection.graphQL === false) {\n return\n }\n const collectionPolicyType = buildPolicyType({\n type: 'collection',\n entity: collection,\n typeSuffix: 'Access',\n })\n\n fields[formatName(collection.slug)] = {\n type: collectionPolicyType,\n }\n })\n\n Object.values(config.globals).forEach((global: SanitizedGlobalConfig) => {\n if (global.graphQL === false) {\n return\n }\n const globalPolicyType = buildPolicyType({\n type: 'global',\n entity: global,\n typeSuffix: 'Access',\n })\n\n fields[formatName(global.slug)] = {\n type: globalPolicyType,\n }\n })\n\n return new GraphQLObjectType({\n name: 'Access',\n fields,\n })\n}\n"],"names":["GraphQLBoolean","GraphQLNonNull","GraphQLObjectType","toWords","GraphQLJSONObject","formatName","buildFields","label","fieldsToBuild","reduce","builtFields","field","includeField","hidden","type","name","fieldName","objectTypeFields","operations","operation","capitalizedOperation","charAt","toUpperCase","slice","fields","permission","subFields","Object","keys","length","tabs","fieldsWithTabFields","tab","tabName","buildEntityPolicy","args","entityFields","scope","fieldsTypeName","policyFields","forEach","operationTypeName","where","buildPolicyType","entity","typeSuffix","slug","graphQL","versions","auth","maxLoginAttempts","push","collectionTypeName","globalTypeName","global","buildPoliciesType","config","canAccessAdmin","values","collections","collection","collectionPolicyType","globals","globalPolicyType"],"mappings":"AASA,SAASA,cAAc,EAAEC,cAAc,EAAEC,iBAAiB,QAAQ,UAAS;AAC3E,SAASC,OAAO,QAAQ,UAAS;AAEjC,SAASC,iBAAiB,QAAQ,yCAAwC;AAC1E,SAASC,UAAU,QAAQ,6BAA4B;AAiBvD,MAAMC,cAAc,CAACC,OAAOC,gBAC1BA,cAAcC,MAAM,CAAC,CAACC,aAAaC;QACjC,MAAMC,eAAe,CAACD,MAAME,MAAM,IAAIF,MAAMG,IAAI,KAAK;QACrD,IAAIF,cAAc;YAChB,IAAID,MAAMI,IAAI,EAAE;gBACd,MAAMC,YAAYX,WAAWM,MAAMI,IAAI;gBAEvC,MAAME,mBAAqC;oBACzC;oBACA;oBACA;oBACA;oBACA;iBACD,CAACR,MAAM,CAAC,CAACS,YAAYC;oBACpB,MAAMC,uBAAuBD,UAAUE,MAAM,CAAC,GAAGC,WAAW,KAAKH,UAAUI,KAAK,CAAC;oBAEjF,OAAO;wBACL,GAAGL,UAAU;wBACb,CAACC,UAAU,EAAE;4BACXL,MAAM,IAAIZ,kBAAkB;gCAC1Ba,MAAM,GAAGR,MAAM,CAAC,EAAES,UAAU,CAAC,EAAEI,sBAAsB;gCACrDI,QAAQ;oCACNC,YAAY;wCACVX,MAAM,IAAIb,eAAeD;oCAC3B;gCACF;4BACF;wBACF;oBACF;gBACF,GAAG,CAAC;gBAEJ,MAAM0B,YAAYf,MAAMa,MAAM,IAAIlB,YAAY,GAAGC,MAAM,CAAC,EA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R;IACF;IAEAlC,OAAO+B,MAAM,CAACF,OAAOM,OAAO,EAAEtB,OAAO,CAAC,CAACc;QACrC,IAAIA,QAAOP,OAAO,KAAK,OAAO;YAC5B;QACF;QACA,MAAMgB,mBAAmBpB,gBAAgB;YACvC7B,MAAM;YACN8B,QAAQU;YACRT,YAAY;QACd;QAEArB,MAAM,CAACnB,WAAWiD,QAAOR,IAAI,EAAE,GAAG;YAChChC,MAAMiD;QACR;IACF;IAEA,OAAO,IAAI7D,kBAAkB;QAC3Ba,MAAM;QACNS;IACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/schema/buildWhereInputType.ts"],"sourcesContent":["import type { Field, FieldAffectingData } from 'payload'\n\nimport { GraphQLInputObjectType, GraphQLList } from 'graphql'\nimport { flattenTopLevelFields } from 'payload'\nimport { fieldAffectsData, fieldHasSubFields, fieldIsPresentationalOnly } from 'payload/shared'\n\nimport { formatName } from '../utilities/formatName.js'\nimport { fieldToSchemaMap } from './fieldToWhereInputSchemaMap.js'\nimport { withOperators } from './withOperators.js'\n\ntype Args = {\n fields: Field[]\n name: string\n parentName: string\n}\n\n/** This does as the function name suggests. It builds a where GraphQL input type\n * for all the fields which are passed to the function.\n * Each field has different operators which may be valid for a where input type.\n * For example, a text field may have a \"contains\" operator, but a number field\n * may not.\n *\n * buildWhereInputType is similar to buildObjectType and operates\n * on a field basis with a few distinct differences.\n *\n * 1. Everything needs to be a GraphQLInputObjectType or scalar / enum\n * 2. Relationships, groups, repeaters and flex content are not\n * directly searchable. Instead, we need to build a chained pathname\n * using dot notation so MongoDB can properly search nested paths.\n */\nexport const buildWhereInputType = ({ name, fields, parentName }: Args): GraphQLInputObjectType => {\n // This is the function that builds nested paths for all\n // field types with nested paths.\n\n const idField = flattenTopLevelFields(fields).find(\n (field) => fieldAffectsData(field) && field.name === 'id',\n )\n\n const fieldTypes = fields.reduce((schema, field) => {\n if (!fieldIsPresentationalOnly(field) && !field.hidden) {\n const getFieldSchema = fieldToSchemaMap({\n parentName,\n })[field.type]\n\n if (getFieldSchema) {\n const fieldSchema = getFieldSchema(field)\n\n if (fieldHasSubFields(field) || field.type === 'tabs') {\n return {\n ...schema,\n ...fieldSchema.reduce(\n (subFields, subField) => ({\n ...subFields,\n [formatName(subField.key)]: subField.type,\n }),\n {},\n ),\n }\n }\n\n return {\n ...schema,\n [formatName(field.name)]: fieldSchema,\n }\n }\n }\n\n return schema\n }, {})\n\n if (!idField) {\n fieldTypes.id = {\n type: withOperators({ name: 'id', type: 'text' } as FieldAffectingData, parentName),\n }\n }\n\n const fieldName = formatName(name)\n\n const recursiveFields = {\n AND: {\n type: new GraphQLList(\n new GraphQLInputObjectType({\n name: `${fieldName}_where_and`,\n fields: () => ({\n ...fieldTypes,\n ...recursiveFields,\n }),\n }),\n ),\n },\n OR: {\n type: new GraphQLList(\n new GraphQLInputObjectType({\n name: `${fieldName}_where_or`,\n fields: () => ({\n ...fieldTypes,\n ...recursiveFields,\n }),\n }),\n ),\n },\n }\n\n return new GraphQLInputObjectType({\n name: `${fieldName}_where`,\n fields: {\n ...fieldTypes,\n ...recursiveFields,\n },\n })\n}\n"],"names":["GraphQLInputObjectType","GraphQLList","flattenTopLevelFields","fieldAffectsData","fieldHasSubFields","fieldIsPresentationalOnly","formatName","fieldToSchemaMap","withOperators","buildWhereInputType","name","fields","parentName","idField","find","field","fieldTypes","reduce","schema","hidden","getFieldSchema","type","fieldSchema","subFields","subField","key","id","fieldName","recursiveFields","AND","OR"],"mappings":"AAEA,SAASA,sBAAsB,EAAEC,WAAW,QAAQ,UAAS;AAC7D,SAASC,qBAAqB,QAAQ,UAAS;AAC/C,SAASC,gBAAgB,EAAEC,iBAAiB,EAAEC,yBAAyB,QAAQ,iBAAgB;AAE/F,SAASC,UAAU,QAAQ,6BAA4B;AACvD,SAASC,gBAAgB,QAAQ,kCAAiC;AAClE,SAASC,aAAa,QAAQ,qBAAoB;AAQlD;;;;;;;;;;;;;CAaC,GACD,OAAO,MAAMC,sBAAs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AuB;gBACzBU,MAAM,GAAGiB,UAAU,SAAS,CAAC;gBAC7BhB,QAAQ,IAAO,CAAA;wBACb,GAAGK,UAAU;wBACb,GAAGY,eAAe;oBACpB,CAAA;YACF;QAEJ;IACF;IAEA,OAAO,IAAI5B,uBAAuB;QAChCU,MAAM,GAAGiB,UAAU,MAAM,CAAC;QAC1BhB,QAAQ;YACN,GAAGK,UAAU;YACb,GAAGY,eAAe;QACpB;IACF;AACF,EAAC"}
1
+ {"version":3,"sources":["../../src/schema/buildWhereInputType.ts"],"sourcesContent":["import type { Field, FieldAffectingData } from 'payload'\n\nimport { GraphQLInputObjectType, GraphQLList } from 'graphql'\nimport { flattenTopLevelFields } from 'payload'\nimport { fieldAffectsData, fieldHasSubFields, fieldIsPresentationalOnly } from 'payload/shared'\n\nimport { formatName } from '../utilities/formatName.js'\nimport { fieldToSchemaMap } from './fieldToWhereInputSchemaMap.js'\nimport { withOperators } from './withOperators.js'\n\ntype Args = {\n fields: Field[]\n name: string\n parentName: string\n}\n\n/** This does as the function name suggests. It builds a where GraphQL input type\n * for all the fields which are passed to the function.\n * Each field has different operators which may be valid for a where input type.\n * For example, a text field may have a \"contains\" operator, but a number field\n * may not.\n *\n * buildWhereInputType is similar to buildObjectType and operates\n * on a field basis with a few distinct differences.\n *\n * 1. Everything needs to be a GraphQLInputObjectType or scalar / enum\n * 2. Relationships, groups, repeaters and flex content are not\n * directly searchable. Instead, we need to build a chained pathname\n * using dot notation so MongoDB can properly search nested paths.\n */\nexport const buildWhereInputType = ({ name, fields, parentName }: Args): GraphQLInputObjectType => {\n // This is the function that builds nested paths for all\n // field types with nested paths.\n\n const idField = flattenTopLevelFields(fields).find(\n (field) => fieldAffectsData(field) && field.name === 'id',\n )\n\n const fieldTypes = fields.reduce((schema, field) => {\n if (!fieldIsPresentationalOnly(field) && !field.hidden) {\n const getFieldSchema = fieldToSchemaMap({\n parentName,\n })[field.type]\n\n if (getFieldSchema) {\n const fieldSchema = getFieldSchema(field)\n\n if (fieldHasSubFields(field) || field.type === 'tabs') {\n return {\n ...schema,\n ...fieldSchema.reduce(\n (subFields, subField) => ({\n ...subFields,\n [formatName(subField.key)]: subField.type,\n }),\n {},\n ),\n }\n }\n\n return {\n ...schema,\n [formatName(field.name)]: fieldSchema,\n }\n }\n }\n\n return schema\n }, {})\n\n if (!idField) {\n fieldTypes.id = {\n type: withOperators({ name: 'id', type: 'text' }, parentName),\n }\n }\n\n const fieldName = formatName(name)\n\n const recursiveFields = {\n AND: {\n type: new GraphQLList(\n new GraphQLInputObjectType({\n name: `${fieldName}_where_and`,\n fields: () => ({\n ...fieldTypes,\n ...recursiveFields,\n }),\n }),\n ),\n },\n OR: {\n type: new GraphQLList(\n new GraphQLInputObjectType({\n name: `${fieldName}_where_or`,\n fields: () => ({\n ...fieldTypes,\n ...recursiveFields,\n }),\n }),\n ),\n },\n }\n\n return new GraphQLInputObjectType({\n name: `${fieldName}_where`,\n fields: {\n ...fieldTypes,\n ...recursiveFields,\n },\n })\n}\n"],"names":["GraphQLInputObjectType","GraphQLList","flattenTopLevelFields","fieldAffectsData","fieldHasSubFields","fieldIsPresentationalOnly","formatName","fieldToSchemaMap","withOperators","buildWhereInputType","name","fields","parentName","idField","find","field","fieldTypes","reduce","schema","hidden","getFieldSchema","type","fieldSchema","subFields","subField","key","id","fieldName","recursiveFields","AND","OR"],"mappings":"AAEA,SAASA,sBAAsB,EAAEC,WAAW,QAAQ,UAAS;AAC7D,SAASC,qBAAqB,QAAQ,UAAS;AAC/C,SAASC,gBAAgB,EAAEC,iBAAiB,EAAEC,yBAAyB,QAAQ,iBAAgB;AAE/F,SAASC,UAAU,QAAQ,6BAA4B;AACvD,SAASC,gBAAgB,QAAQ,kCAAiC;AAClE,SAASC,aAAa,QAAQ,qBAAoB;AAQlD;;;;;;;;;;;;;CAaC,GACD,OAAO,MAAMC,sBAAsB,CAAC,EAAEC,IAAI,EAAEC,MAAM,EAAEC,UAAU,EAAQ;IACpE,wDAAwD;IACxD,iCAA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AAGK,UAAU;wBACb,GAAGY,eAAe;oBACpB,CAAA;YACF;QAEJ;IACF;IAEA,OAAO,IAAI5B,uBAAuB;QAChCU,MAAM,GAAGiB,UAAU,MAAM,CAAC;QAC1BhB,QAAQ;YACN,GAAGK,UAAU;YACb,GAAGY,eAAe;QACpB;IACF;AACF,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/schema/fieldToSchemaMap.ts"],"sourcesContent":["import type { GraphQLArgumentConfig, GraphQLFieldConfig, GraphQLOutputType } from 'graphql'\nimport type {\n ArrayField,\n BlocksField,\n CheckboxField,\n CodeField,\n CollapsibleField,\n DateField,\n EmailField,\n Field,\n FlattenedJoinField,\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 SlugField,\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 {\n combineQueries,\n createDataloaderCacheKey,\n MissingEditorProp,\n resolveBranch,\n toWords,\n} from 'payload'\nimport { fieldAffectsData, tabHasName } from 'payload/shared'\n\nimport type { Context } from '../resolvers/types.js'\n\nimport { GraphQLJSON } from '../packages/graphql-type-json/index.js'\nimport { getGraphQLRequestForNestedField } from '../resolvers/getGraphQLRequest.js'\nimport { combineParentName } from '../utilities/combineParentName.js'\nimport { formatName } from '../utilities/formatName.js'\nimport { formatOptions } from '../utilities/formatOptions.js'\nimport { resolveSelect } from '../utilities/select.js'\nimport { buildObjectType, type ObjectTypeConfig } from './buildObjectType.js'\nimport { isFieldNullable } from './isFieldNullable.js'\nimport { withNullableType } from './withNullableType.js'\n\nfunction formattedNameResolver({\n field,\n ...rest\n}: { field: Field } & GraphQLFieldConfig<any, Context, any>): GraphQLFieldConfig<\n any,\n Context,\n any\n> {\n if ('name' in field) {\n if (formatName(field.name) !== field.name) {\n return {\n ...rest,\n extensions: { ...rest.extensions, field },\n resolve: (parent) => parent[field.name],\n }\n }\n }\n return rest\n}\n\ntype SharedArgs = {\n collectionSlug?: string\n config: SanitizedConfig\n forceNullable?: boolean\n graphqlResult: GraphQLInfo\n newlyCreatedBlockType: GraphQLObjectType\n objectTypeConfig: ObjectTypeConfig\n parentIsLocalized?: boolean\n parentName: string\n}\n\ntype GenericFieldToSchemaMap = (args: { field: Field } & SharedArgs) => ObjectTypeConfig\n\ntype FieldToSchemaMap = {\n array: (args: { field: ArrayField } & SharedArgs) => ObjectTypeConfig\n blocks: (args: { field: BlocksField } & SharedArgs) => ObjectTypeConfig\n checkbox: (args: { field: CheckboxField } & SharedArgs) => ObjectTypeConfig\n code: (args: { field: CodeField } & SharedArgs) => ObjectTypeConfig\n collapsible: (args: { field: CollapsibleField } & SharedArgs) => ObjectTypeConfig\n date: (args: { field: DateField } & SharedArgs) => ObjectTypeConfig\n email: (args: { field: EmailField } & SharedArgs) => ObjectTypeConfig\n group: (args: { field: GroupField } & SharedArgs) => ObjectTypeConfig\n join: (args: { field: JoinField } & SharedArgs) => ObjectTypeConfig\n json: (args: { field: JSONField } & SharedArgs) => ObjectTypeConfig\n number: (args: { field: NumberField } & SharedArgs) => ObjectTypeConfig\n point: (args: { field: PointField } & SharedArgs) => ObjectTypeConfig\n radio: (args: { field: RadioField } & SharedArgs) => ObjectTypeConfig\n relationship: (args: { field: RelationshipField } & SharedArgs) => ObjectTypeConfig\n richText: (args: { field: RichTextField } & SharedArgs) => ObjectTypeConfig\n row: (args: { field: RowField } & SharedArgs) => ObjectTypeConfig\n select: (args: { field: SelectField } & SharedArgs) => ObjectTypeConfig\n slug: (args: { field: SlugField } & SharedArgs) => ObjectTypeConfig\n tabs: (args: { field: TabsField } & SharedArgs) => ObjectTypeConfig\n text: (args: { field: TextField } & SharedArgs) => ObjectTypeConfig\n textarea: (args: { field: TextareaField } & SharedArgs) => ObjectTypeConfig\n upload: (args: { field: UploadField } & SharedArgs) => ObjectTypeConfig\n}\n\nexport const fieldToSchemaMap: FieldToSchemaMap = {\n slug: ({ field, forceNullable, objectTypeConfig, parentIsLocalized }) => ({\n ...objectTypeConfig,\n [formatName(field.name)]: formattedNameResolver({\n type: withNullableType({\n type: GraphQLString,\n field,\n forceNullable,\n parentIsLocalized,\n }) as GraphQLOutputType,\n field,\n }),\n }),\n array: ({\n config,\n field,\n forceNullable,\n graphqlResult,\n objectTypeConfig,\n parentIsLocalized,\n parentName,\n }) => {\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 [formatName(field.name)]: formattedNameResolver({\n type: withNullableType({ type: arrayType, field, parentIsLocalized }) as GraphQLOutputType,\n field,\n }),\n }\n },\n blocks: ({\n config,\n field,\n forceNullable,\n graphqlResult,\n objectTypeConfig,\n parentIsLocalized,\n parentName,\n }) => {\n const blockTypes: GraphQLObjectType<any, any>[] = field.blocks.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 // Store block slug in extensions for use in select building\n objectType.extensions = {\n ...objectType.extensions,\n blockSlug: block.slug,\n }\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 ) as GraphQLOutputType\n\n return {\n ...objectTypeConfig,\n [formatName(field.name)]: formattedNameResolver({\n type: withNullableType({ type, field, parentIsLocalized }) as GraphQLOutputType,\n field,\n }),\n }\n },\n checkbox: ({ field, forceNullable, objectTypeConfig, parentIsLocalized }) => ({\n ...objectTypeConfig,\n [formatName(field.name)]: formattedNameResolver({\n type: withNullableType({\n type: GraphQLBoolean,\n field,\n forceNullable,\n parentIsLocalized,\n }) as GraphQLOutputType,\n field,\n }),\n }),\n code: ({ field, forceNullable, objectTypeConfig, parentIsLocalized }) => ({\n ...objectTypeConfig,\n [formatName(field.name)]: formattedNameResolver({\n type: withNullableType({\n type: GraphQLString,\n field,\n forceNullable,\n parentIsLocalized,\n }) as GraphQLOutputType,\n field,\n }),\n }),\n collapsible: ({\n collectionSlug,\n config,\n field,\n forceNullable,\n graphqlResult,\n newlyCreatedBlockType,\n objectTypeConfig,\n parentIsLocalized,\n parentName,\n }) =>\n field.fields.reduce((objectTypeConfigWithCollapsibleFields, subField) => {\n const addSubField: GenericFieldToSchemaMap = fieldToSchemaMap[subField.type]\n if (addSubField) {\n return addSubField({\n collectionSlug,\n config,\n field: subField,\n forceNullable,\n graphqlResult,\n newlyCreatedBlockType,\n objectTypeConfig: objectTypeConfigWithCollapsibleFields,\n parentIsLocalized,\n parentName,\n })\n }\n return objectTypeConfigWithCollapsibleFields\n }, objectTypeConfig),\n date: ({ field, forceNullable, objectTypeConfig, parentIsLocalized }) => ({\n ...objectTypeConfig,\n [formatName(field.name)]: formattedNameResolver({\n type: withNullableType({\n type: DateTimeResolver,\n field,\n forceNullable,\n parentIsLocalized,\n }) as GraphQLOutputType,\n field,\n }),\n }),\n email: ({ field, forceNullable, objectTypeConfig, parentIsLocalized }) => ({\n ...objectTypeConfig,\n [formatName(field.name)]: formattedNameResolver({\n type: withNullableType({\n type: EmailAddressResolver,\n field,\n forceNullable,\n parentIsLocalized,\n }) as GraphQLOutputType,\n field,\n }),\n }),\n group: ({\n collectionSlug,\n config,\n field,\n forceNullable,\n graphqlResult,\n newlyCreatedBlockType,\n objectTypeConfig,\n parentIsLocalized,\n parentName,\n }) => {\n if (fieldAffectsData(field)) {\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 [formatName(field.name)]: {\n type: graphqlResult.types.groupTypes[interfaceName],\n extensions: { field },\n resolve: (parent, args, context) => {\n return {\n ...parent[field.name],\n _id: parent._id ?? parent.id,\n }\n },\n } satisfies GraphQLFieldConfig<any, Context, any>,\n }\n } else {\n return field.fields.reduce((objectTypeConfigWithCollapsibleFields, subField) => {\n const addSubField: GenericFieldToSchemaMap = fieldToSchemaMap[subField.type]\n if (addSubField) {\n return addSubField({\n collectionSlug,\n config,\n field: subField,\n forceNullable,\n graphqlResult,\n newlyCreatedBlockType,\n objectTypeConfig: objectTypeConfigWithCollapsibleFields,\n parentIsLocalized,\n parentName,\n })\n }\n return objectTypeConfigWithCollapsibleFields\n }, objectTypeConfig)\n }\n },\n join: ({ collectionSlug, field, graphqlResult, objectTypeConfig, parentName }) => {\n const joinName = combineParentName(parentName, toWords(field.name, true))\n\n const joinType: GraphQLFieldConfig<any, Context, any> = {\n type: new GraphQLObjectType({\n name: joinName,\n fields: {\n docs: {\n type: new GraphQLNonNull(\n Array.isArray(field.collection)\n ? GraphQLJSON\n : new GraphQLList(\n new GraphQLNonNull(graphqlResult.collections[field.collection].graphQL.type),\n ),\n ),\n },\n hasNextPage: { type: new GraphQLNonNull(GraphQLBoolean) },\n totalDocs: { type: GraphQLInt },\n },\n }),\n args: {\n count: { type: GraphQLBoolean },\n limit: {\n type: GraphQLInt,\n },\n page: {\n type: GraphQLInt,\n },\n sort: {\n type: GraphQLString,\n },\n where: {\n type: Array.isArray(field.collection)\n ? GraphQLJSON\n : graphqlResult.collections[field.collection].graphQL.whereInputType,\n },\n },\n extensions: {\n complexity: typeof field?.graphQL?.complexity === 'number' ? field.graphQL.complexity : 10,\n field,\n },\n async resolve(parent, args, context, info) {\n const { collection } = field\n const { count = false, limit, page, sort, where } = args\n const req = getGraphQLRequestForNestedField({ context, info })\n\n const draft = Boolean(args.draft ?? req.query?.draft)\n const select = resolveSelect(info, context.select, context)\n\n const targetField = (field as FlattenedJoinField).targetField\n\n const fullWhere = combineQueries(\n where,\n Array.isArray(targetField.relationTo)\n ? {\n [field.on]: {\n equals: {\n relationTo: collectionSlug,\n value: parent._id ?? parent.id,\n },\n },\n }\n : {\n [field.on]: { equals: parent._id ?? parent.id },\n },\n )\n\n if (Array.isArray(collection)) {\n throw new Error('GraphQL with array of join.field.collection is not implemented')\n }\n\n if (count && limit === 0) {\n return await req.payload.count({\n collection,\n overrideAccess: false,\n req,\n where: fullWhere,\n })\n }\n\n const { docs, totalDocs } = await req.payload.find({\n collection,\n depth: 0,\n draft,\n fallbackLocale: req.fallbackLocale,\n // Fetch one extra document to determine if there are more documents beyond the requested limit (used for hasNextPage calculation).\n limit: typeof limit === 'number' && limit > 0 ? limit + 1 : 0,\n locale: req.locale,\n overrideAccess: false,\n page,\n pagination: count ? true : false,\n req,\n select,\n sort,\n where: fullWhere,\n })\n\n let shouldSlice = false\n\n if (typeof limit === 'number' && limit !== 0 && limit < docs.length) {\n shouldSlice = true\n }\n\n return {\n docs: shouldSlice ? docs.slice(0, -1) : docs,\n hasNextPage: limit === 0 ? false : limit < docs.length,\n ...(count ? { totalDocs } : {}),\n }\n },\n }\n\n return {\n ...objectTypeConfig,\n [formatName(field.name)]: joinType,\n }\n },\n json: ({ field, forceNullable, objectTypeConfig, parentIsLocalized }) => ({\n ...objectTypeConfig,\n [formatName(field.name)]: formattedNameResolver({\n type: withNullableType({\n type: GraphQLJSON,\n field,\n forceNullable,\n parentIsLocalized,\n }) as GraphQLOutputType,\n field,\n }),\n }),\n number: ({ field, forceNullable, objectTypeConfig, parentIsLocalized }) => {\n const type = field?.name === 'id' ? GraphQLInt : GraphQLFloat\n return {\n ...objectTypeConfig,\n [formatName(field.name)]: formattedNameResolver({\n type: withNullableType({\n type: field?.hasMany === true ? new GraphQLList(new GraphQLNonNull(type)) : type,\n field,\n forceNullable,\n parentIsLocalized,\n }) as GraphQLOutputType,\n field,\n }),\n }\n },\n point: ({ field, forceNullable, objectTypeConfig, parentIsLocalized }) => ({\n ...objectTypeConfig,\n [formatName(field.name)]: formattedNameResolver({\n type: withNullableType({\n type: new GraphQLList(new GraphQLNonNull(GraphQLFloat)),\n field,\n forceNullable,\n parentIsLocalized,\n }) as GraphQLOutputType,\n field,\n }),\n }),\n radio: ({ field, forceNullable, objectTypeConfig, parentIsLocalized, parentName }) => ({\n ...objectTypeConfig,\n [formatName(field.name)]: formattedNameResolver({\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 }) as GraphQLOutputType,\n field,\n }),\n }),\n relationship: ({\n config,\n field,\n forceNullable,\n graphqlResult,\n newlyCreatedBlockType,\n objectTypeConfig,\n parentIsLocalized,\n parentName,\n }) => {\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: GraphQLOutputType\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) => graphQLCollections.some((collection) => collection.slug === relation))\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 }) as GraphQLOutputType,\n },\n },\n }) as GraphQLOutputType\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: GraphQLArgumentConfig\n fallbackLocale: GraphQLArgumentConfig\n limit: GraphQLArgumentConfig\n locale: GraphQLArgumentConfig\n page: GraphQLArgumentConfig\n where: GraphQLArgumentConfig\n } = {} as any\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: GraphQLFieldConfig<any, Context, any> = {\n type: withNullableType({\n type: hasManyValues ? new GraphQLList(new GraphQLNonNull(type)) : type,\n field,\n // can be null if the related doc is deleted even if the field is required, unless hasMany\n forceNullable: !field.hasMany,\n parentIsLocalized,\n }) as GraphQLOutputType,\n args: relationshipArgs,\n extensions: {\n complexity: typeof field?.graphQL?.complexity === 'number' ? field.graphQL.complexity : 10,\n field,\n },\n async resolve(parent, args, context, info) {\n const req = getGraphQLRequestForNestedField({ context, info })\n const value = parent[field.name]\n const locale = args.locale || req.locale\n const fallbackLocale = args.fallbackLocale || req.fallbackLocale\n let relatedCollectionSlug = field.relationTo\n const draft = Boolean(args.draft ?? req.query?.draft)\n const select = resolveSelect(info, context.select, context)\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 req.payloadDataLoader.load(\n createDataloaderCacheKey({\n branch: resolveBranch(req),\n collectionSlug: collectionSlug as string,\n currentDepth: 0,\n depth: 0,\n docID: id,\n draft,\n fallbackLocale,\n locale,\n overrideAccess: false,\n select,\n showHiddenFields: false,\n transactionID: req.transactionID,\n }),\n )\n\n if (result) {\n if (isRelatedToManyCollections) {\n results.push({\n relationTo: collectionSlug,\n value: {\n ...result,\n collection: collectionSlug,\n },\n })\n } else {\n results.push(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 (graphQLCollections.some((collection) => collection.slug === relatedCollectionSlug)) {\n const relatedDocument = await req.payloadDataLoader.load(\n createDataloaderCacheKey({\n branch: resolveBranch(req),\n collectionSlug: relatedCollectionSlug as string,\n currentDepth: 0,\n depth: 0,\n docID: id,\n draft,\n fallbackLocale,\n locale,\n overrideAccess: false,\n select,\n showHiddenFields: false,\n transactionID: 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 [formatName(field.name)]: relationship,\n }\n },\n richText: ({ config, field, forceNullable, objectTypeConfig, parentIsLocalized }) => ({\n ...objectTypeConfig,\n [formatName(field.name)]: {\n type: withNullableType({\n type: GraphQLJSON,\n field,\n forceNullable,\n parentIsLocalized,\n }) as GraphQLOutputType,\n args: {\n depth: {\n type: GraphQLInt,\n },\n },\n extensions: {\n field,\n },\n async resolve(parent, args, context: Context, info) {\n const req = getGraphQLRequestForNestedField({ context, info })\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: { ...context, req },\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,\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: ({ field, objectTypeConfig, ...rest }) =>\n field.fields.reduce((objectTypeConfigWithRowFields, subField) => {\n const addSubField: GenericFieldToSchemaMap = fieldToSchemaMap[subField.type]\n if (addSubField) {\n return addSubField({\n field: subField,\n objectTypeConfig: objectTypeConfigWithRowFields,\n ...rest,\n })\n }\n return objectTypeConfigWithRowFields\n }, objectTypeConfig),\n select: ({ field, forceNullable, objectTypeConfig, parentIsLocalized, parentName }) => {\n const fullName = combineParentName(parentName, field.name)\n\n let type: GraphQLOutputType = 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 }) as GraphQLOutputType\n\n return {\n ...objectTypeConfig,\n [formatName(field.name)]: formattedNameResolver({ type, field }),\n }\n },\n tabs: ({\n collectionSlug,\n config,\n field,\n forceNullable,\n graphqlResult,\n newlyCreatedBlockType,\n objectTypeConfig,\n parentIsLocalized,\n parentName,\n }) =>\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 collectionSlug,\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: GenericFieldToSchemaMap = fieldToSchemaMap[subField.type]\n if (addSubField) {\n return addSubField({\n collectionSlug,\n config,\n field: subField,\n forceNullable,\n graphqlResult,\n newlyCreatedBlockType,\n objectTypeConfig: subFieldSchema,\n parentIsLocalized,\n parentName,\n })\n }\n return subFieldSchema\n }, tabSchema),\n }\n }, objectTypeConfig),\n text: ({ field, forceNullable, objectTypeConfig, parentIsLocalized }) => ({\n ...objectTypeConfig,\n [formatName(field.name)]: formattedNameResolver({\n type: withNullableType({\n type:\n field.hasMany === true\n ? new GraphQLList(new GraphQLNonNull(GraphQLString))\n : GraphQLString,\n field,\n forceNullable,\n parentIsLocalized,\n }) as GraphQLOutputType,\n field,\n }),\n }),\n textarea: ({ field, forceNullable, objectTypeConfig, parentIsLocalized }) => ({\n ...objectTypeConfig,\n [formatName(field.name)]: formattedNameResolver({\n type: withNullableType({\n type: GraphQLString,\n field,\n forceNullable,\n parentIsLocalized,\n }) as GraphQLOutputType,\n field,\n }),\n }),\n upload: ({\n config,\n field,\n forceNullable,\n graphqlResult,\n newlyCreatedBlockType,\n objectTypeConfig,\n parentIsLocalized,\n parentName,\n }) => {\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.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?: GraphQLArgumentConfig\n fallbackLocale?: GraphQLArgumentConfig\n limit?: GraphQLArgumentConfig\n locale?: GraphQLArgumentConfig\n page?: GraphQLArgumentConfig\n where?: GraphQLArgumentConfig\n } = {} as any\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: GraphQLFieldConfig<any, Context, any> = {\n type: withNullableType({\n type: hasManyValues ? new GraphQLList(new GraphQLNonNull(type)) : type,\n field,\n // can be null if the related doc is deleted even if the field is required, unless hasMany\n forceNullable: !field.hasMany,\n parentIsLocalized,\n }) as GraphQLOutputType,\n args: relationshipArgs,\n extensions: {\n complexity: typeof field?.graphQL?.complexity === 'number' ? field.graphQL.complexity : 10,\n field,\n },\n async resolve(parent, args, context, info) {\n const req = getGraphQLRequestForNestedField({ context, info })\n const value = parent[field.name]\n const locale = args.locale || req.locale\n const fallbackLocale = args.fallbackLocale || req.fallbackLocale\n let relatedCollectionSlug = field.relationTo\n const draft = Boolean(args.draft ?? req.query?.draft)\n const select = resolveSelect(info, context.select, context)\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 req.payloadDataLoader.load(\n createDataloaderCacheKey({\n branch: resolveBranch(req),\n collectionSlug: collectionSlug as string,\n currentDepth: 0,\n depth: 0,\n docID: id,\n draft,\n fallbackLocale,\n locale,\n overrideAccess: false,\n select,\n showHiddenFields: false,\n transactionID: req.transactionID,\n }),\n )\n\n if (result) {\n if (isRelatedToManyCollections) {\n results.push({\n relationTo: collectionSlug,\n value: {\n ...result,\n collection: collectionSlug,\n },\n })\n } else {\n results.push(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 (graphQLCollections.some((collection) => collection.slug === relatedCollectionSlug)) {\n const relatedDocument = await req.payloadDataLoader.load(\n createDataloaderCacheKey({\n branch: resolveBranch(req),\n collectionSlug: relatedCollectionSlug as string,\n currentDepth: 0,\n depth: 0,\n docID: id,\n draft,\n fallbackLocale,\n locale,\n overrideAccess: false,\n select,\n showHiddenFields: false,\n transactionID: 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 [formatName(field.name)]: relationship,\n }\n },\n}\n"],"names":["GraphQLBoolean","GraphQLEnumType","GraphQLFloat","GraphQLInt","GraphQLList","GraphQLNonNull","GraphQLObjectType","GraphQLString","GraphQLUnionType","DateTimeResolver","EmailAddressResolver","combineQueries","createDataloaderCacheKey","MissingEditorProp","resolveBranch","toWords","fieldAffectsData","tabHasName","GraphQLJSON","getGraphQLRequestForNestedField","combineParentName","formatName","formatOptions","resolveSelect","buildObjectType","isFieldNullable","withNullableType","formattedNameResolver","field","rest","name","extensions","resolve","parent","fieldToSchemaMap","slug","forceNullable","objectTypeConfig","parentIsLocalized","type","array","config","graphqlResult","parentName","interfaceName","types","arrayTypes","objectType","fields","localized","Object","keys","getFields","length","arrayType","blocks","blockTypes","reduce","acc","_block","blockSlug","block","find","b","graphQL","singularName","push","fullName","resolveType","data","blockType","checkbox","code","collapsible","collectionSlug","newlyCreatedBlockType","objectTypeConfigWithCollapsibleFields","subField","addSubField","date","email","group","groupTypes","args","context","_id","id","join","joinName","joinType","docs","Array","isArray","collection","collections","hasNextPage","totalDocs","count","limit","page","sort","where","whereInputType","complexity","info","req","draft","Boolean","query","select","targetField","fullWhere","relationTo","on","equals","value","Error","payload","overrideAccess","depth","fallbackLocale","locale","pagination","shouldSlice","slice","json","number","hasMany","point","radio","values","relationship","isRelatedToManyCollections","hasManyValues","relationshipName","relationToType","graphQLCollections","filter","collectionConfig","relation","some","relations","map","relationshipArgs","relationsUseDrafts","versions","drafts","localization","localeInputType","fallbackLocaleInputType","relatedCollectionSlug","results","resultPromises","createPopulationPromise","relatedDoc","i","isValidGraphQLCollection","includes","result","payloadDataLoader","load","branch","currentDepth","docID","showHiddenFields","transactionID","forEach","Promise","all","relatedDocument","richText","defaultDepth","editor","graphQLPopulationPromises","fieldPromises","populationPromises","populateDepth","maxDepth","undefined","findMany","flattenLocales","siblingDoc","row","objectTypeConfigWithRowFields","tabs","tabSchema","tab","subFieldSchema","text","textarea","upload"],"mappings":"AA+BA,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,SACEC,cAAc,EACdC,wBAAwB,EACxBC,iBAAiB,EACjBC,aAAa,EACbC,OAAO,QACF,UAAS;AAChB,SAASC,gBAAgB,EAAEC,UAAU,QAAQ,iBAAgB;AAI7D,SAASC,WAAW,QAAQ,yCAAwC;AACpE,SAASC,+BAA+B,QAAQ,oCAAmC;AACnF,SAASC,iBAAiB,QAAQ,oCAAmC;AACrE,SAASC,UAAU,QAAQ,6BAA4B;AACvD,SAASC,aAAa,QAAQ,gCAA+B;AAC7D,SAASC,aAAa,QAAQ,yBAAwB;AACtD,SAASC,eAAe,QAA+B,uBAAsB;AAC7E,SAASC,eAAe,QAAQ,uBAAsB;AACtD,SAASC,gBAAgB,QAAQ,wBAAuB;AAExD,SAASC,sBAAsB,EAC7BC,KAAK,EACL,GAAGC,MACsD;IAKzD,IAAI,UAAUD,OAAO;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;oBAChBmC,wBAAwBnC,MAAMH,UAAU;gBAC1C;gBAEA,IAAI1B,IAAI;oBACN,IAAIkD,mBAAmBI,IAAI,CAAC,CAAC/C,aAAeA,WAAW1D,IAAI,KAAKmH,wBAAwB;wBACtF,MAAMmB,kBAAkB,MAAMhE,IAAIsD,iBAAiB,CAACC,IAAI,CACtDpJ,yBAAyB;4BACvBqJ,QAAQnJ,cAAc2F;4BACtB/B,gBAAgB4E;4BAChBY,cAAc;4BACd3C,OAAO;4BACP4C,OAAO7E;4BACPoB;4BACAc;4BACAC;4BACAH,gBAAgB;4BAChBT;4BACAuD,kBAAkB;4BAClBC,eAAe5D,IAAI4D,aAAa;wBAClC;wBAGF,IAAII,iBAAiB;4BACnB,IAAIrC,4BAA4B;gCAC9B,OAAO;oCACLpB,YAAYsC;oCACZnC,OAAO;wCACL,GAAGsD,eAAe;wCAClB5E,YAAYyD;oCACd;gCACF;4BACF;4BAEA,OAAOmB;wBACT;oBACF;oBAEA,OAAO;gBACT;gBAEA,OAAO;YACT;QACF;QAEA,OAAO;YACL,GAAGpI,gBAAgB;YACnB,CAAChB,WAAWO,MAAME,IAAI,EAAE,EAAEqG;QAC5B;IACF;AACF,EAAC"}
1
+ {"version":3,"sources":["../../src/schema/fieldToSchemaMap.ts"],"sourcesContent":["import type { GraphQLArgumentConfig, GraphQLFieldConfig, GraphQLOutputType } from 'graphql'\nimport type {\n ArrayField,\n BlocksField,\n CheckboxField,\n CodeField,\n CollapsibleField,\n DateField,\n EmailField,\n Field,\n FlattenedJoinField,\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 SlugField,\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 {\n combineQueries,\n createDataloaderCacheKey,\n MissingEditorProp,\n resolveBranch,\n toWords,\n} from 'payload'\nimport { fieldAffectsData, tabHasName } from 'payload/shared'\n\nimport type { Context } from '../resolvers/types.js'\n\nimport { GraphQLJSON } from '../packages/graphql-type-json/index.js'\nimport { getGraphQLRequestForNestedField } from '../resolvers/getGraphQLRequest.js'\nimport { combineParentName } from '../utilities/combineParentName.js'\nimport { formatName } from '../utilities/formatName.js'\nimport { formatOptions } from '../utilities/formatOptions.js'\nimport { resolveSelect } from '../utilities/select.js'\nimport { buildObjectType, type ObjectTypeConfig } from './buildObjectType.js'\nimport { isFieldNullable } from './isFieldNullable.js'\nimport { withNullableType } from './withNullableType.js'\n\nfunction formattedNameResolver({\n field,\n ...rest\n}: { field: Field } & GraphQLFieldConfig<any, Context, any>): GraphQLFieldConfig<\n any,\n Context,\n any\n> {\n if ('name' in field) {\n if (formatName(field.name) !== field.name) {\n return {\n ...rest,\n extensions: { ...rest.extensions, field },\n resolve: (parent) => parent[field.name],\n }\n }\n }\n return rest\n}\n\ntype SharedArgs = {\n collectionSlug?: string\n config: SanitizedConfig\n forceNullable?: boolean\n graphqlResult: GraphQLInfo\n newlyCreatedBlockType: GraphQLObjectType\n objectTypeConfig: ObjectTypeConfig\n parentIsLocalized?: boolean\n parentName: string\n}\n\ntype GenericFieldToSchemaMap = (args: { field: Field } & SharedArgs) => ObjectTypeConfig\n\ntype FieldToSchemaMap = {\n array: (args: { field: ArrayField } & SharedArgs) => ObjectTypeConfig\n blocks: (args: { field: BlocksField } & SharedArgs) => ObjectTypeConfig\n checkbox: (args: { field: CheckboxField } & SharedArgs) => ObjectTypeConfig\n code: (args: { field: CodeField } & SharedArgs) => ObjectTypeConfig\n collapsible: (args: { field: CollapsibleField } & SharedArgs) => ObjectTypeConfig\n date: (args: { field: DateField } & SharedArgs) => ObjectTypeConfig\n email: (args: { field: EmailField } & SharedArgs) => ObjectTypeConfig\n group: (args: { field: GroupField } & SharedArgs) => ObjectTypeConfig\n join: (args: { field: JoinField } & SharedArgs) => ObjectTypeConfig\n json: (args: { field: JSONField } & SharedArgs) => ObjectTypeConfig\n number: (args: { field: NumberField } & SharedArgs) => ObjectTypeConfig\n point: (args: { field: PointField } & SharedArgs) => ObjectTypeConfig\n radio: (args: { field: RadioField } & SharedArgs) => ObjectTypeConfig\n relationship: (args: { field: RelationshipField } & SharedArgs) => ObjectTypeConfig\n richText: (args: { field: RichTextField } & SharedArgs) => ObjectTypeConfig\n row: (args: { field: RowField } & SharedArgs) => ObjectTypeConfig\n select: (args: { field: SelectField } & SharedArgs) => ObjectTypeConfig\n slug: (args: { field: SlugField } & SharedArgs) => ObjectTypeConfig\n tabs: (args: { field: TabsField } & SharedArgs) => ObjectTypeConfig\n text: (args: { field: TextField } & SharedArgs) => ObjectTypeConfig\n textarea: (args: { field: TextareaField } & SharedArgs) => ObjectTypeConfig\n upload: (args: { field: UploadField } & SharedArgs) => ObjectTypeConfig\n}\n\nexport const fieldToSchemaMap: FieldToSchemaMap = {\n slug: ({ field, forceNullable, objectTypeConfig, parentIsLocalized }) => ({\n ...objectTypeConfig,\n [formatName(field.name)]: formattedNameResolver({\n type: withNullableType({\n type: GraphQLString,\n field,\n forceNullable,\n parentIsLocalized,\n }) as GraphQLOutputType,\n field,\n }),\n }),\n array: ({\n config,\n field,\n forceNullable,\n graphqlResult,\n objectTypeConfig,\n parentIsLocalized,\n parentName,\n }) => {\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 [formatName(field.name)]: formattedNameResolver({\n type: withNullableType({ type: arrayType, field, parentIsLocalized }) as GraphQLOutputType,\n field,\n }),\n }\n },\n blocks: ({\n config,\n field,\n forceNullable,\n graphqlResult,\n objectTypeConfig,\n parentIsLocalized,\n parentName,\n }) => {\n const blockTypes: GraphQLObjectType<any, any>[] = field.blocks.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 // Store block slug in extensions for use in select building\n objectType.extensions = {\n ...objectType.extensions,\n blockSlug: block.slug,\n }\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 ) as GraphQLOutputType\n\n return {\n ...objectTypeConfig,\n [formatName(field.name)]: formattedNameResolver({\n type: withNullableType({ type, field, parentIsLocalized }) as GraphQLOutputType,\n field,\n }),\n }\n },\n checkbox: ({ field, forceNullable, objectTypeConfig, parentIsLocalized }) => ({\n ...objectTypeConfig,\n [formatName(field.name)]: formattedNameResolver({\n type: withNullableType({\n type: GraphQLBoolean,\n field,\n forceNullable,\n parentIsLocalized,\n }) as GraphQLOutputType,\n field,\n }),\n }),\n code: ({ field, forceNullable, objectTypeConfig, parentIsLocalized }) => ({\n ...objectTypeConfig,\n [formatName(field.name)]: formattedNameResolver({\n type: withNullableType({\n type: GraphQLString,\n field,\n forceNullable,\n parentIsLocalized,\n }) as GraphQLOutputType,\n field,\n }),\n }),\n collapsible: ({\n collectionSlug,\n config,\n field,\n forceNullable,\n graphqlResult,\n newlyCreatedBlockType,\n objectTypeConfig,\n parentIsLocalized,\n parentName,\n }) =>\n field.fields.reduce((objectTypeConfigWithCollapsibleFields, subField) => {\n const addSubField: GenericFieldToSchemaMap = fieldToSchemaMap[subField.type]\n if (addSubField) {\n return addSubField({\n collectionSlug,\n config,\n field: subField,\n forceNullable,\n graphqlResult,\n newlyCreatedBlockType,\n objectTypeConfig: objectTypeConfigWithCollapsibleFields,\n parentIsLocalized,\n parentName,\n })\n }\n return objectTypeConfigWithCollapsibleFields\n }, objectTypeConfig),\n date: ({ field, forceNullable, objectTypeConfig, parentIsLocalized }) => ({\n ...objectTypeConfig,\n [formatName(field.name)]: formattedNameResolver({\n type: withNullableType({\n type: DateTimeResolver,\n field,\n forceNullable,\n parentIsLocalized,\n }) as GraphQLOutputType,\n field,\n }),\n }),\n email: ({ field, forceNullable, objectTypeConfig, parentIsLocalized }) => ({\n ...objectTypeConfig,\n [formatName(field.name)]: formattedNameResolver({\n type: withNullableType({\n type: EmailAddressResolver,\n field,\n forceNullable,\n parentIsLocalized,\n }) as GraphQLOutputType,\n field,\n }),\n }),\n group: ({\n collectionSlug,\n config,\n field,\n forceNullable,\n graphqlResult,\n newlyCreatedBlockType,\n objectTypeConfig,\n parentIsLocalized,\n parentName,\n }) => {\n if (fieldAffectsData(field)) {\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 [formatName(field.name)]: {\n type: graphqlResult.types.groupTypes[interfaceName],\n extensions: { field },\n resolve: (parent, args, context) => {\n return {\n ...parent[field.name],\n _id: parent._id ?? parent.id,\n }\n },\n } satisfies GraphQLFieldConfig<any, Context, any>,\n }\n } else {\n return field.fields.reduce((objectTypeConfigWithCollapsibleFields, subField) => {\n const addSubField: GenericFieldToSchemaMap = fieldToSchemaMap[subField.type]\n if (addSubField) {\n return addSubField({\n collectionSlug,\n config,\n field: subField,\n forceNullable,\n graphqlResult,\n newlyCreatedBlockType,\n objectTypeConfig: objectTypeConfigWithCollapsibleFields,\n parentIsLocalized,\n parentName,\n })\n }\n return objectTypeConfigWithCollapsibleFields\n }, objectTypeConfig)\n }\n },\n join: ({ collectionSlug, field, graphqlResult, objectTypeConfig, parentName }) => {\n const joinName = combineParentName(parentName, toWords(field.name, true))\n\n const joinType: GraphQLFieldConfig<any, Context, any> = {\n type: new GraphQLObjectType({\n name: joinName,\n fields: {\n docs: {\n type: new GraphQLNonNull(\n Array.isArray(field.collection)\n ? GraphQLJSON\n : new GraphQLList(\n new GraphQLNonNull(graphqlResult.collections[field.collection].graphQL.type),\n ),\n ),\n },\n hasNextPage: { type: new GraphQLNonNull(GraphQLBoolean) },\n totalDocs: { type: GraphQLInt },\n },\n }),\n args: {\n count: { type: GraphQLBoolean },\n limit: {\n type: GraphQLInt,\n },\n page: {\n type: GraphQLInt,\n },\n sort: {\n type: GraphQLString,\n },\n where: {\n type: Array.isArray(field.collection)\n ? GraphQLJSON\n : graphqlResult.collections[field.collection].graphQL.whereInputType,\n },\n },\n extensions: {\n complexity: typeof field?.graphQL?.complexity === 'number' ? field.graphQL.complexity : 10,\n field,\n },\n async resolve(parent, args, context, info) {\n const { collection } = field\n const { count = false, limit, page, sort, where } = args\n const req = getGraphQLRequestForNestedField({ context, info })\n\n const draft = Boolean(args.draft ?? req.query?.draft)\n const select = resolveSelect(info, context.select, context)\n\n const targetField = (field as FlattenedJoinField).targetField\n\n const fullWhere = combineQueries(\n where,\n Array.isArray(targetField.relationTo)\n ? {\n [field.on]: {\n equals: {\n relationTo: collectionSlug,\n value: parent._id ?? parent.id,\n },\n },\n }\n : {\n [field.on]: { equals: parent._id ?? parent.id },\n },\n )\n\n if (Array.isArray(collection)) {\n throw new Error('GraphQL with array of join.field.collection is not implemented')\n }\n\n if (count && limit === 0) {\n return await req.payload.count({\n collection,\n overrideAccess: false,\n req,\n where: fullWhere,\n })\n }\n\n const { docs, totalDocs } = await req.payload.find({\n collection,\n depth: 0,\n draft,\n fallbackLocale: req.fallbackLocale,\n // Fetch one extra document to determine if there are more documents beyond the requested limit (used for hasNextPage calculation).\n limit: typeof limit === 'number' && limit > 0 ? limit + 1 : 0,\n locale: req.locale,\n overrideAccess: false,\n page,\n pagination: count ? true : false,\n req,\n select,\n sort,\n where: fullWhere,\n })\n\n let shouldSlice = false\n\n if (typeof limit === 'number' && limit !== 0 && limit < docs.length) {\n shouldSlice = true\n }\n\n return {\n docs: shouldSlice ? docs.slice(0, -1) : docs,\n hasNextPage: limit === 0 ? false : limit < docs.length,\n ...(count ? { totalDocs } : {}),\n }\n },\n }\n\n return {\n ...objectTypeConfig,\n [formatName(field.name)]: joinType,\n }\n },\n json: ({ field, forceNullable, objectTypeConfig, parentIsLocalized }) => ({\n ...objectTypeConfig,\n [formatName(field.name)]: formattedNameResolver({\n type: withNullableType({\n type: GraphQLJSON,\n field,\n forceNullable,\n parentIsLocalized,\n }) as GraphQLOutputType,\n field,\n }),\n }),\n number: ({ field, forceNullable, objectTypeConfig, parentIsLocalized }) => {\n const type = field?.name === 'id' ? GraphQLInt : GraphQLFloat\n return {\n ...objectTypeConfig,\n [formatName(field.name)]: formattedNameResolver({\n type: withNullableType({\n type: field?.hasMany === true ? new GraphQLList(new GraphQLNonNull(type)) : type,\n field,\n forceNullable,\n parentIsLocalized,\n }) as GraphQLOutputType,\n field,\n }),\n }\n },\n point: ({ field, forceNullable, objectTypeConfig, parentIsLocalized }) => ({\n ...objectTypeConfig,\n [formatName(field.name)]: formattedNameResolver({\n type: withNullableType({\n type: new GraphQLList(new GraphQLNonNull(GraphQLFloat)),\n field,\n forceNullable,\n parentIsLocalized,\n }) as GraphQLOutputType,\n field,\n }),\n }),\n radio: ({ field, forceNullable, objectTypeConfig, parentIsLocalized, parentName }) => ({\n ...objectTypeConfig,\n [formatName(field.name)]: formattedNameResolver({\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 }) as GraphQLOutputType,\n field,\n }),\n }),\n relationship: ({\n config,\n field,\n forceNullable,\n graphqlResult,\n newlyCreatedBlockType,\n objectTypeConfig,\n parentIsLocalized,\n parentName,\n }) => {\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: GraphQLOutputType\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) => graphQLCollections.some((collection) => collection.slug === relation))\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 }) as GraphQLOutputType,\n },\n },\n }) as GraphQLOutputType\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: GraphQLArgumentConfig\n fallbackLocale: GraphQLArgumentConfig\n limit: GraphQLArgumentConfig\n locale: GraphQLArgumentConfig\n page: GraphQLArgumentConfig\n where: GraphQLArgumentConfig\n } = {} as any\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: GraphQLFieldConfig<any, Context, any> = {\n type: withNullableType({\n type: hasManyValues ? new GraphQLList(new GraphQLNonNull(type)) : type,\n field,\n // can be null if the related doc is deleted even if the field is required, unless hasMany\n forceNullable: !field.hasMany,\n parentIsLocalized,\n }) as GraphQLOutputType,\n args: relationshipArgs,\n extensions: {\n complexity: typeof field?.graphQL?.complexity === 'number' ? field.graphQL.complexity : 10,\n field,\n },\n async resolve(parent, args, context, info) {\n const req = getGraphQLRequestForNestedField({ context, info })\n const value = parent[field.name]\n const locale = args.locale || req.locale\n const fallbackLocale = args.fallbackLocale || req.fallbackLocale\n let relatedCollectionSlug = field.relationTo\n const draft = Boolean(args.draft ?? req.query?.draft)\n const select = resolveSelect(info, context.select, context)\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 req.payloadDataLoader.load(\n createDataloaderCacheKey({\n branch: resolveBranch(req),\n collectionSlug: collectionSlug as string,\n currentDepth: 0,\n depth: 0,\n docID: id,\n draft,\n fallbackLocale,\n locale,\n overrideAccess: false,\n select,\n showHiddenFields: false,\n transactionID: req.transactionID,\n }),\n )\n\n if (result) {\n if (isRelatedToManyCollections) {\n results.push({\n relationTo: collectionSlug,\n value: {\n ...result,\n collection: collectionSlug,\n },\n })\n } else {\n results.push(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 (graphQLCollections.some((collection) => collection.slug === relatedCollectionSlug)) {\n const relatedDocument = await req.payloadDataLoader.load(\n createDataloaderCacheKey({\n branch: resolveBranch(req),\n collectionSlug: relatedCollectionSlug as string,\n currentDepth: 0,\n depth: 0,\n docID: id,\n draft,\n fallbackLocale,\n locale,\n overrideAccess: false,\n select,\n showHiddenFields: false,\n transactionID: 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 [formatName(field.name)]: relationship,\n }\n },\n richText: ({ config, field, forceNullable, objectTypeConfig, parentIsLocalized }) => ({\n ...objectTypeConfig,\n [formatName(field.name)]: {\n type: withNullableType({\n type: GraphQLJSON,\n field,\n forceNullable,\n parentIsLocalized,\n }) as GraphQLOutputType,\n args: {\n depth: {\n type: GraphQLInt,\n },\n },\n extensions: {\n field,\n },\n async resolve(parent, args, context: Context, info) {\n const req = getGraphQLRequestForNestedField({ context, info })\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: { ...context, req },\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,\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: ({ field, objectTypeConfig, ...rest }) =>\n field.fields.reduce((objectTypeConfigWithRowFields, subField) => {\n const addSubField: GenericFieldToSchemaMap = fieldToSchemaMap[subField.type]\n if (addSubField) {\n return addSubField({\n field: subField,\n objectTypeConfig: objectTypeConfigWithRowFields,\n ...rest,\n })\n }\n return objectTypeConfigWithRowFields\n }, objectTypeConfig),\n select: ({ field, forceNullable, objectTypeConfig, parentIsLocalized, parentName }) => {\n const fullName = combineParentName(parentName, field.name)\n\n let type: GraphQLOutputType = 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 }) as GraphQLOutputType\n\n return {\n ...objectTypeConfig,\n [formatName(field.name)]: formattedNameResolver({ type, field }),\n }\n },\n tabs: ({\n collectionSlug,\n config,\n field,\n forceNullable,\n graphqlResult,\n newlyCreatedBlockType,\n objectTypeConfig,\n parentIsLocalized,\n parentName,\n }) =>\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 collectionSlug,\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: GenericFieldToSchemaMap = fieldToSchemaMap[subField.type]\n if (addSubField) {\n return addSubField({\n collectionSlug,\n config,\n field: subField,\n forceNullable,\n graphqlResult,\n newlyCreatedBlockType,\n objectTypeConfig: subFieldSchema,\n parentIsLocalized,\n parentName,\n })\n }\n return subFieldSchema\n }, tabSchema),\n }\n }, objectTypeConfig),\n text: ({ field, forceNullable, objectTypeConfig, parentIsLocalized }) => ({\n ...objectTypeConfig,\n [formatName(field.name)]: formattedNameResolver({\n type: withNullableType({\n type:\n field.hasMany === true\n ? new GraphQLList(new GraphQLNonNull(GraphQLString))\n : GraphQLString,\n field,\n forceNullable,\n parentIsLocalized,\n }) as GraphQLOutputType,\n field,\n }),\n }),\n textarea: ({ field, forceNullable, objectTypeConfig, parentIsLocalized }) => ({\n ...objectTypeConfig,\n [formatName(field.name)]: formattedNameResolver({\n type: withNullableType({\n type: GraphQLString,\n field,\n forceNullable,\n parentIsLocalized,\n }) as GraphQLOutputType,\n field,\n }),\n }),\n upload: ({\n config,\n field,\n forceNullable,\n graphqlResult,\n newlyCreatedBlockType,\n objectTypeConfig,\n parentIsLocalized,\n parentName,\n }) => {\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.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?: GraphQLArgumentConfig\n fallbackLocale?: GraphQLArgumentConfig\n limit?: GraphQLArgumentConfig\n locale?: GraphQLArgumentConfig\n page?: GraphQLArgumentConfig\n where?: GraphQLArgumentConfig\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: GraphQLFieldConfig<any, Context, any> = {\n type: withNullableType({\n type: hasManyValues ? new GraphQLList(new GraphQLNonNull(type)) : type,\n field,\n // can be null if the related doc is deleted even if the field is required, unless hasMany\n forceNullable: !field.hasMany,\n parentIsLocalized,\n }) as GraphQLOutputType,\n args: relationshipArgs,\n extensions: {\n complexity: typeof field?.graphQL?.complexity === 'number' ? field.graphQL.complexity : 10,\n field,\n },\n async resolve(parent, args, context, info) {\n const req = getGraphQLRequestForNestedField({ context, info })\n const value = parent[field.name]\n const locale = args.locale || req.locale\n const fallbackLocale = args.fallbackLocale || req.fallbackLocale\n let relatedCollectionSlug = field.relationTo\n const draft = Boolean(args.draft ?? req.query?.draft)\n const select = resolveSelect(info, context.select, context)\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 req.payloadDataLoader.load(\n createDataloaderCacheKey({\n branch: resolveBranch(req),\n collectionSlug: collectionSlug as string,\n currentDepth: 0,\n depth: 0,\n docID: id,\n draft,\n fallbackLocale,\n locale,\n overrideAccess: false,\n select,\n showHiddenFields: false,\n transactionID: req.transactionID,\n }),\n )\n\n if (result) {\n if (isRelatedToManyCollections) {\n results.push({\n relationTo: collectionSlug,\n value: {\n ...result,\n collection: collectionSlug,\n },\n })\n } else {\n results.push(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 (graphQLCollections.some((collection) => collection.slug === relatedCollectionSlug)) {\n const relatedDocument = await req.payloadDataLoader.load(\n createDataloaderCacheKey({\n branch: resolveBranch(req),\n collectionSlug: relatedCollectionSlug as string,\n currentDepth: 0,\n depth: 0,\n docID: id,\n draft,\n fallbackLocale,\n locale,\n overrideAccess: false,\n select,\n showHiddenFields: false,\n transactionID: 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 [formatName(field.name)]: relationship,\n }\n },\n}\n"],"names":["GraphQLBoolean","GraphQLEnumType","GraphQLFloat","GraphQLInt","GraphQLList","GraphQLNonNull","GraphQLObjectType","GraphQLString","GraphQLUnionType","DateTimeResolver","EmailAddressResolver","combineQueries","createDataloaderCacheKey","MissingEditorProp","resolveBranch","toWords","fieldAffectsData","tabHasName","GraphQLJSON","getGraphQLRequestForNestedField","combineParentName","formatName","formatOptions","resolveSelect","buildObjectType","isFieldNullable","withNullableType","formattedNameResolver","field","rest","name","extensions","resolve","parent","fieldToSchemaMap","slug","forceNullable","objectTypeConfig","parentIsLocalized","type","array","config","graphqlResult","parentName","interfaceName","types","arrayTypes","objectType","fields","localized","Object","keys","getFields","length","arrayType","blocks","blockTypes","reduce","acc","_block","blockSlug","block","find","b","graphQL","singularName","push","fullName","resolveType","data","blockType","checkbox","code","collapsible","collectionSlug","newlyCreatedBlockType","objectTypeConfigWithCollapsibleFields","subField","addSubField","date","email","group","groupTypes","args","context","_id","id","join","joinName","joinType","docs","Array","isArray","collection","collections","hasNextPage","totalDocs","count","limit","page","sort","where","whereInputType","complexity","info","req","draft","Boolean","query","select","targetField","fullWhere","relationTo","on","equals","value","Error","payload","overrideAccess","depth","fallbackLocale","locale","pagination","shouldSlice","slice","json","number","hasMany","point","radio","values","relationship","isRelatedToManyCollections","hasManyValues","relationshipName","relationToType","graphQLCollections","filter","collectionConfig","relation","some","relations","map","relationshipArgs","relationsUseDrafts","versions","drafts","localization","localeInputType","fallbackLocaleInputType","relatedCollectionSlug","results","resultPromises","createPopulationPromise","relatedDoc","i","isValidGraphQLCollection","includes","result","payloadDataLoader","load","branch","currentDepth","docID","showHiddenFields","transactionID","forEach","Promise","all","relatedDocument","richText","defaultDepth","editor","graphQLPopulationPromises","fieldPromises","populationPromises","populateDepth","maxDepth","undefined","findMany","flattenLocales","siblingDoc","row","objectTypeConfigWithRowFields","tabs","tabSchema","tab","subFieldSchema","text","textarea","upload"],"mappings":"AA+BA,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;A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I,EAAE,EAAEqG;QAC5B;IACF;AACF,EAAC"}
@@ -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;AA2ChB,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,CAskB3F"}
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;AA2ChB,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,CAwkB3F"}
@@ -402,7 +402,7 @@ export function initCollections({ config, graphqlResult }) {
402
402
  name: `${singularName}Version`,
403
403
  collectionSlug: collectionConfig.slug,
404
404
  config,
405
- fields: versionCollectionFields,
405
+ fields: versionCollectionFields.filter((field)=>!('name' in field) || field.name !== '_branchParent'),
406
406
  forceNullable: forceNullableObjectType,
407
407
  graphqlResult,
408
408
  parentName: `${singularName}Version`
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/schema/initCollections.ts"],"sourcesContent":["import type {\n Collection,\n Field,\n GraphQLInfo,\n SanitizedCollectionConfig,\n SanitizedConfig,\n} from 'payload'\n\nimport {\n GraphQLBoolean,\n GraphQLInt,\n GraphQLNonNull,\n GraphQLObjectType,\n GraphQLString,\n} from 'graphql'\nimport { buildVersionCollectionFields, flattenTopLevelFields, formatNames, toWords } from 'payload'\nimport { fieldAffectsData, getLoginOptions } from 'payload/shared'\n\nimport type { ObjectTypeConfig } from './buildObjectType.js'\n\nimport { forgotPassword } from '../resolvers/auth/forgotPassword.js'\nimport { init } from '../resolvers/auth/init.js'\nimport { login } from '../resolvers/auth/login.js'\nimport { logout } from '../resolvers/auth/logout.js'\nimport { me } from '../resolvers/auth/me.js'\nimport { refresh } from '../resolvers/auth/refresh.js'\nimport { resetPassword } from '../resolvers/auth/resetPassword.js'\nimport { unlock } from '../resolvers/auth/unlock.js'\nimport { verifyEmail } from '../resolvers/auth/verifyEmail.js'\nimport { countResolver } from '../resolvers/collections/count.js'\nimport { createResolver } from '../resolvers/collections/create.js'\nimport { getDeleteResolver } from '../resolvers/collections/delete.js'\nimport { docAccessResolver } from '../resolvers/collections/docAccess.js'\nimport { duplicateResolver } from '../resolvers/collections/duplicate.js'\nimport { findResolver } from '../resolvers/collections/find.js'\nimport { findByIDResolver } from '../resolvers/collections/findByID.js'\nimport { findVersionByIDResolver } from '../resolvers/collections/findVersionByID.js'\nimport { findVersionsResolver } from '../resolvers/collections/findVersions.js'\nimport { renameFileResolver } from '../resolvers/collections/renameFile.js'\nimport { restoreVersionResolver } from '../resolvers/collections/restoreVersion.js'\nimport { updateResolver } from '../resolvers/collections/update.js'\nimport { validateResolver } from '../resolvers/collections/validate.js'\nimport { formatName } from '../utilities/formatName.js'\nimport { buildMutationInputType, getCollectionIDType } from './buildMutationInputType.js'\nimport { buildObjectType } from './buildObjectType.js'\nimport { buildPaginatedListType } from './buildPaginatedListType.js'\nimport { buildPolicyType } from './buildPoliciesType.js'\nimport { buildWhereInputType } from './buildWhereInputType.js'\n\ntype InitCollectionsGraphQLArgs = {\n config: SanitizedConfig\n graphqlResult: GraphQLInfo\n}\nexport function initCollections({ config, graphqlResult }: InitCollectionsGraphQLArgs): void {\n Object.keys(graphqlResult.collections).forEach((slug) => {\n const collection: Collection = graphqlResult.collections[slug]\n const {\n config: collectionConfig,\n config: { fields, graphQL = {} as SanitizedCollectionConfig['graphQL'], versions },\n } = collection\n\n if (!graphQL) {\n return\n }\n\n let singularName\n let pluralName\n\n const fromSlug = formatNames(collection.config.slug)\n\n if (graphQL.singularName) {\n singularName = toWords(graphQL.singularName, true)\n } else {\n singularName = fromSlug.singular\n }\n if (graphQL.pluralName) {\n pluralName = toWords(graphQL.pluralName, true)\n } else {\n pluralName = fromSlug.plural\n }\n\n // For collections named 'Media' or similar,\n // there is a possibility that the singular name\n // will equal the plural name. Append `all` to the beginning\n // of potential conflicts\n if (singularName === pluralName) {\n pluralName = `all${singularName}`\n }\n\n collection.graphQL = {} as Collection['graphQL']\n\n const hasIDField =\n flattenTopLevelFields(fields).findIndex(\n (field) => fieldAffectsData(field) && field.name === 'id',\n ) > -1\n\n const idType = getCollectionIDType(config.db.defaultIDType, collectionConfig)\n\n const baseFields: ObjectTypeConfig = {}\n\n const whereInputFields = [...fields]\n\n if (!hasIDField) {\n baseFields.id = { type: new GraphQLNonNull(idType) }\n whereInputFields.push({\n name: 'id',\n type: config.db.defaultIDType as 'text',\n })\n }\n\n if (collectionConfig.auth) {\n baseFields._strategy = { type: GraphQLString }\n }\n\n const forceNullableObjectType = Boolean(versions?.drafts)\n\n collection.graphQL.type = buildObjectType({\n name: singularName,\n baseFields,\n collectionSlug: collectionConfig.slug,\n config,\n fields,\n forceNullable: forceNullableObjectType,\n graphqlResult,\n parentName: singularName,\n })\n\n collection.graphQL.paginatedType = buildPaginatedListType(pluralName, collection.graphQL.type)\n\n collection.graphQL.whereInputType = buildWhereInputType({\n name: singularName,\n fields: whereInputFields,\n parentName: singularName,\n })\n\n const mutationInputFields = [...fields]\n\n if (\n collectionConfig.auth &&\n (!collectionConfig.auth.disableLocalStrategy ||\n (typeof collectionConfig.auth.disableLocalStrategy === 'object' &&\n collectionConfig.auth.disableLocalStrategy.optionalPassword))\n ) {\n mutationInputFields.push({\n name: 'password',\n type: 'text',\n label: 'Password',\n required: !(\n typeof collectionConfig.auth.disableLocalStrategy === 'object' &&\n collectionConfig.auth.disableLocalStrategy.optionalPassword\n ),\n })\n }\n\n let mutationCreateInputFields = mutationInputFields\n\n if (\n config.db.allowIDOnCreate &&\n !collectionConfig.flattenedFields.some((field) => field.name === 'id')\n ) {\n mutationCreateInputFields = [\n ...mutationCreateInputFields,\n {\n name: 'id',\n type: config.db.defaultIDType,\n } as Field,\n ]\n }\n\n const createMutationInputType = buildMutationInputType({\n name: singularName,\n config,\n fields: mutationCreateInputFields,\n graphqlResult,\n parentIsLocalized: false,\n parentName: singularName,\n })\n if (createMutationInputType) {\n collection.graphQL.mutationInputType = new GraphQLNonNull(createMutationInputType)\n }\n\n const updateMutationInputType = buildMutationInputType({\n name: `${singularName}Update`,\n config,\n fields: mutationInputFields.filter(\n (field) => !(fieldAffectsData(field) && field.name === 'id'),\n ),\n forceNullable: true,\n graphqlResult,\n parentIsLocalized: false,\n parentName: `${singularName}Update`,\n })\n if (updateMutationInputType) {\n collection.graphQL.updateMutationInputType = new GraphQLNonNull(updateMutationInputType)\n }\n\n const validationMutationInputType = buildMutationInputType({\n name: `${singularName}Validation`,\n config,\n fields: mutationCreateInputFields,\n forceNullable: true,\n graphqlResult,\n parentIsLocalized: false,\n parentName: `${singularName}Validation`,\n })\n\n const queriesEnabled =\n typeof collectionConfig.graphQL !== 'object' || !collectionConfig.graphQL.disableQueries\n const mutationsEnabled =\n typeof collectionConfig.graphQL !== 'object' || !collectionConfig.graphQL.disableMutations\n\n if (queriesEnabled) {\n graphqlResult.Query.fields[singularName] = {\n type: collection.graphQL.type,\n args: {\n id: { type: new GraphQLNonNull(idType) },\n branch: { type: GraphQLString },\n draft: { type: GraphQLBoolean },\n ...(config.localization\n ? {\n fallbackLocale: { type: graphqlResult.types.fallbackLocaleInputType },\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n select: { type: GraphQLBoolean },\n trash: { type: GraphQLBoolean },\n },\n resolve: findByIDResolver(collection),\n }\n\n graphqlResult.Query.fields[pluralName] = {\n type: buildPaginatedListType(pluralName, collection.graphQL.type),\n args: {\n branch: { type: GraphQLString },\n draft: { type: GraphQLBoolean },\n where: { type: collection.graphQL.whereInputType },\n ...(config.localization\n ? {\n fallbackLocale: { type: graphqlResult.types.fallbackLocaleInputType },\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n limit: { type: GraphQLInt },\n page: { type: GraphQLInt },\n pagination: { type: GraphQLBoolean },\n select: { type: GraphQLBoolean },\n sort: { type: GraphQLString },\n trash: { type: GraphQLBoolean },\n },\n resolve: findResolver(collection),\n }\n\n graphqlResult.Query.fields[`count${pluralName}`] = {\n type: new GraphQLObjectType({\n name: `count${pluralName}`,\n fields: {\n totalDocs: { type: GraphQLInt },\n },\n }),\n args: {\n branch: { type: GraphQLString },\n draft: { type: GraphQLBoolean },\n trash: { type: GraphQLBoolean },\n where: { type: collection.graphQL.whereInputType },\n ...(config.localization\n ? {\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n },\n resolve: countResolver(collection),\n }\n\n graphqlResult.Query.fields[`docAccess${singularName}`] = {\n type: buildPolicyType({\n type: 'collection',\n entity: collectionConfig,\n scope: 'docAccess',\n typeSuffix: 'DocAccess',\n }),\n args: {\n id: { type: new GraphQLNonNull(idType) },\n branch: { type: GraphQLString },\n },\n resolve: docAccessResolver(collection),\n }\n }\n\n if (mutationsEnabled) {\n graphqlResult.Mutation.fields[`create${singularName}`] = {\n type: collection.graphQL.type,\n args: {\n ...(createMutationInputType\n ? { data: { type: collection.graphQL.mutationInputType } }\n : {}),\n branch: { type: GraphQLString },\n draft: { type: GraphQLBoolean },\n ...(config.localization\n ? {\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n },\n resolve: createResolver(collection),\n }\n\n graphqlResult.Mutation.fields[`update${singularName}`] = {\n type: collection.graphQL.type,\n args: {\n id: { type: new GraphQLNonNull(idType) },\n autosave: { type: GraphQLBoolean },\n ...(updateMutationInputType\n ? { data: { type: collection.graphQL.updateMutationInputType } }\n : {}),\n branch: { type: GraphQLString },\n draft: { type: GraphQLBoolean },\n ...(config.localization\n ? {\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n trash: { type: GraphQLBoolean },\n },\n resolve: updateResolver(collection),\n }\n\n graphqlResult.Mutation.fields[`validate${singularName}`] = {\n type: graphqlResult.types.validationResultType,\n args: {\n id: { type: idType },\n ...(validationMutationInputType ? { data: { type: validationMutationInputType } } : {}),\n draft: { type: GraphQLBoolean },\n ...(config.localization\n ? {\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n },\n resolve: validateResolver(collection),\n }\n\n graphqlResult.Mutation.fields[`delete${singularName}`] = {\n type: collection.graphQL.type,\n args: {\n id: { type: new GraphQLNonNull(idType) },\n branch: { type: GraphQLString },\n trash: { type: GraphQLBoolean },\n },\n resolve: getDeleteResolver(collection),\n }\n\n if (collectionConfig.disableDuplicate !== true) {\n graphqlResult.Mutation.fields[`duplicate${singularName}`] = {\n type: collection.graphQL.type,\n args: {\n id: { type: new GraphQLNonNull(idType) },\n branch: { type: GraphQLString },\n ...(createMutationInputType\n ? { data: { type: collection.graphQL.mutationInputType } }\n : {}),\n },\n resolve: duplicateResolver(collection),\n }\n }\n }\n\n if (collectionConfig.versions) {\n const versionIDType = config.db.defaultIDType === 'text' ? GraphQLString : GraphQLInt\n const versionCollectionFields: Field[] = [\n ...buildVersionCollectionFields(config, collectionConfig),\n {\n name: 'id',\n type: config.db.defaultIDType as 'text',\n },\n {\n name: 'createdAt',\n type: 'date',\n label: ({ t }) => t('general:createdAt'),\n },\n {\n name: 'updatedAt',\n type: 'date',\n label: ({ t }) => t('general:updatedAt'),\n },\n ]\n\n collection.graphQL.versionType = buildObjectType({\n name: `${singularName}Version`,\n collectionSlug: collectionConfig.slug,\n config,\n fields: versionCollectionFields,\n forceNullable: forceNullableObjectType,\n graphqlResult,\n parentName: `${singularName}Version`,\n })\n\n if (queriesEnabled) {\n graphqlResult.Query.fields[`version${formatName(singularName)}`] = {\n type: collection.graphQL.versionType,\n args: {\n id: { type: versionIDType },\n branch: { type: GraphQLString },\n ...(config.localization\n ? {\n fallbackLocale: { type: graphqlResult.types.fallbackLocaleInputType },\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n trash: { type: GraphQLBoolean },\n },\n resolve: findVersionByIDResolver(collection),\n }\n graphqlResult.Query.fields[`versions${pluralName}`] = {\n type: buildPaginatedListType(\n `versions${formatName(pluralName)}`,\n collection.graphQL.versionType,\n ),\n args: {\n branch: { type: GraphQLString },\n where: {\n type: buildWhereInputType({\n name: `versions${singularName}`,\n fields: versionCollectionFields,\n parentName: `versions${singularName}`,\n }),\n },\n ...(config.localization\n ? {\n fallbackLocale: { type: graphqlResult.types.fallbackLocaleInputType },\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n limit: { type: GraphQLInt },\n page: { type: GraphQLInt },\n pagination: { type: GraphQLBoolean },\n select: { type: GraphQLBoolean },\n sort: { type: GraphQLString },\n trash: { type: GraphQLBoolean },\n },\n resolve: findVersionsResolver(collection),\n }\n }\n\n if (mutationsEnabled) {\n graphqlResult.Mutation.fields[`restoreVersion${formatName(singularName)}`] = {\n type: collection.graphQL.type,\n args: {\n id: { type: versionIDType },\n branch: { type: GraphQLString },\n draft: { type: GraphQLBoolean },\n },\n resolve: restoreVersionResolver(collection),\n }\n }\n }\n\n if (mutationsEnabled && collectionConfig.upload) {\n graphqlResult.Mutation.fields[`renameFile${formatName(singularName)}`] = {\n type: collection.graphQL.type,\n args: {\n id: { type: new GraphQLNonNull(idType) },\n draft: { type: GraphQLBoolean },\n filename: { type: new GraphQLNonNull(GraphQLString) },\n },\n resolve: renameFileResolver(collection),\n }\n }\n\n if (collectionConfig.auth) {\n const authFields: Field[] =\n collectionConfig.auth.disableLocalStrategy ||\n (collectionConfig.auth.loginWithUsername &&\n !collectionConfig.auth.loginWithUsername.allowEmailLogin &&\n !collectionConfig.auth.loginWithUsername.requireEmail)\n ? []\n : [\n {\n name: 'email',\n type: 'email',\n required: true,\n },\n ]\n collection.graphQL.JWT = buildObjectType({\n name: formatName(`${slug}JWT`),\n config,\n fields: [\n ...collectionConfig.fields.filter((field) => fieldAffectsData(field) && field.saveToJWT),\n ...authFields,\n {\n name: 'collection',\n type: 'text',\n required: true,\n },\n {\n name: '_strategy',\n type: 'text',\n },\n ],\n graphqlResult,\n parentName: formatName(`${slug}JWT`),\n })\n\n if (queriesEnabled) {\n graphqlResult.Query.fields[`me${singularName}`] = {\n type: new GraphQLObjectType({\n name: formatName(`${slug}Me`),\n fields: {\n collection: {\n type: GraphQLString,\n },\n exp: {\n type: GraphQLInt,\n },\n token: {\n type: GraphQLString,\n },\n user: {\n type: collection.graphQL.type,\n },\n },\n }),\n resolve: me(collection),\n }\n\n graphqlResult.Query.fields[`initialized${singularName}`] = {\n type: GraphQLBoolean,\n resolve: init(collection.config.slug),\n }\n }\n\n if (mutationsEnabled) {\n graphqlResult.Mutation.fields[`refreshToken${singularName}`] = {\n type: new GraphQLObjectType({\n name: formatName(`${slug}Refreshed${singularName}`),\n fields: {\n exp: {\n type: GraphQLInt,\n },\n refreshedToken: {\n type: GraphQLString,\n },\n user: {\n type: collection.graphQL.JWT,\n },\n },\n }),\n resolve: refresh(collection),\n }\n\n graphqlResult.Mutation.fields[`logout${singularName}`] = {\n type: GraphQLString,\n args: {\n allSessions: { type: GraphQLBoolean },\n },\n resolve: logout(collection),\n }\n\n if (!collectionConfig.auth.disableLocalStrategy) {\n const authArgs = {}\n\n const { canLoginWithEmail, canLoginWithUsername } = getLoginOptions(\n collectionConfig.auth.loginWithUsername,\n )\n\n if (canLoginWithEmail) {\n authArgs['email'] = { type: new GraphQLNonNull(GraphQLString) }\n }\n if (canLoginWithUsername) {\n authArgs['username'] = { type: new GraphQLNonNull(GraphQLString) }\n }\n\n if (collectionConfig.auth.maxLoginAttempts > 0) {\n graphqlResult.Mutation.fields[`unlock${singularName}`] = {\n type: new GraphQLNonNull(GraphQLBoolean),\n args: authArgs,\n resolve: unlock(collection),\n }\n }\n\n graphqlResult.Mutation.fields[`login${singularName}`] = {\n type: new GraphQLObjectType({\n name: formatName(`${slug}LoginResult`),\n fields: {\n exp: {\n type: GraphQLInt,\n },\n token: {\n type: GraphQLString,\n },\n user: {\n type: collection.graphQL.type,\n },\n },\n }),\n args: {\n ...authArgs,\n password: { type: GraphQLString },\n },\n resolve: login(collection),\n }\n\n graphqlResult.Mutation.fields[`forgotPassword${singularName}`] = {\n type: new GraphQLNonNull(GraphQLBoolean),\n args: {\n ...authArgs,\n },\n resolve: forgotPassword(collection),\n }\n\n graphqlResult.Mutation.fields[`resetPassword${singularName}`] = {\n type: new GraphQLObjectType({\n name: formatName(`${slug}ResetPassword`),\n fields: {\n token: { type: GraphQLString },\n user: { type: collection.graphQL.type },\n },\n }),\n args: {\n password: { type: GraphQLString },\n token: { type: GraphQLString },\n },\n resolve: resetPassword(collection),\n }\n\n graphqlResult.Mutation.fields[`verifyEmail${singularName}`] = {\n type: GraphQLBoolean,\n args: {\n token: { type: GraphQLString },\n },\n resolve: verifyEmail(collection),\n }\n }\n }\n }\n })\n}\n"],"names":["GraphQLBoolean","GraphQLInt","GraphQLNonNull","GraphQLObjectType","GraphQLString","buildVersionCollectionFields","flattenTopLevelFields","formatNames","toWords","fieldAffectsData","getLoginOptions","forgotPassword","init","login","logout","me","refresh","resetPassword","unlock","verifyEmail","countResolver","createResolver","getDeleteResolver","docAccessResolver","duplicateResolver","findResolver","findByIDResolver","findVersionByIDResolver","findVersionsResolver","renameFileResolver","restoreVersionResolver","updateResolver","validateResolver","formatName","buildMutationInputType","getCollectionIDType","buildObjectType","buildPaginatedListType","buildPolicyType","buildWhereInputType","initCollections","config","graphqlResult","Object","keys","collections","forEach","slug","collection","collectionConfig","fields","graphQL","versions","singularName","pluralName","fromSlug","singular","plural","hasIDField","findIndex","field","name","idType","db","defaultIDType","baseFields","whereInputFields","id","type","push","auth","_strategy","forceNullableObjectType","Boolean","drafts","collectionSlug","forceNullable","parentName","paginatedType","whereInputType","mutationInputFields","disableLocalStrategy","optionalPassword","label","required","mutationCreateInputFields","allowIDOnCreate","flattenedFields","some","createMutationInputType","parentIsLocalized","mutationInputType","updateMutationInputType","filter","validationMutationInputType","queriesEnabled","disableQueries","mutationsEnabled","disableMutations","Query","args","branch","draft","localization","fallbackLocale","types","fallbackLocaleInputType","locale","localeInputType","select","trash","resolve","where","limit","page","pagination","sort","totalDocs","entity","scope","typeSuffix","Mutation","data","autosave","validationResultType","disableDuplicate","versionIDType","versionCollectionFields","t","versionType","upload","filename","authFields","loginWithUsername","allowEmailLogin","requireEmail","JWT","saveToJWT","exp","token","user","refreshedToken","allSessions","authArgs","canLoginWithEmail","canLoginWithUsername","maxLoginAttempts","password"],"mappings":"AAQA,SACEA,cAAc,EACdC,UAAU,EACVC,cAAc,EACdC,iBAAiB,EACjBC,aAAa,QACR,UAAS;AAChB,SAASC,4BAA4B,EAAEC,qBAAqB,EAAEC,WAAW,EAAEC,OAAO,QAAQ,UAAS;AACnG,SAASC,gBAAgB,EAAEC,eAAe,QAAQ,iBAAgB;AAIlE,SAASC,cAAc,QAAQ,sCAAqC;AACpE,SAASC,IAAI,QAAQ,4BAA2B;AAChD,SAASC,KAAK,QAAQ,6BAA4B;AAClD,SAASC,MAAM,QAAQ,8BAA6B;AACpD,SAASC,EAAE,QAAQ,0BAAyB;AAC5C,SAASC,OAAO,QAAQ,+BAA8B;AACtD,SAASC,aAAa,QAAQ,qCAAoC;AAClE,SAASC,MAAM,QAAQ,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,uBAAu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AAc;4BAChCuI,OAAO;gCAAEvE,MAAMhE;4BAAc;wBAC/B;wBACA2G,SAAS9F,cAAc+B;oBACzB;oBAEAN,cAAc+E,QAAQ,CAACvE,MAAM,CAAC,CAAC,WAAW,EAAEG,cAAc,CAAC,GAAG;wBAC5De,MAAMpE;wBACNoG,MAAM;4BACJuC,OAAO;gCAAEvE,MAAMhE;4BAAc;wBAC/B;wBACA2G,SAAS5F,YAAY6B;oBACvB;gBACF;YACF;QACF;IACF;AACF"}
1
+ {"version":3,"sources":["../../src/schema/initCollections.ts"],"sourcesContent":["import type {\n Collection,\n Field,\n GraphQLInfo,\n SanitizedCollectionConfig,\n SanitizedConfig,\n} from 'payload'\n\nimport {\n GraphQLBoolean,\n GraphQLInt,\n GraphQLNonNull,\n GraphQLObjectType,\n GraphQLString,\n} from 'graphql'\nimport { buildVersionCollectionFields, flattenTopLevelFields, formatNames, toWords } from 'payload'\nimport { fieldAffectsData, getLoginOptions } from 'payload/shared'\n\nimport type { ObjectTypeConfig } from './buildObjectType.js'\n\nimport { forgotPassword } from '../resolvers/auth/forgotPassword.js'\nimport { init } from '../resolvers/auth/init.js'\nimport { login } from '../resolvers/auth/login.js'\nimport { logout } from '../resolvers/auth/logout.js'\nimport { me } from '../resolvers/auth/me.js'\nimport { refresh } from '../resolvers/auth/refresh.js'\nimport { resetPassword } from '../resolvers/auth/resetPassword.js'\nimport { unlock } from '../resolvers/auth/unlock.js'\nimport { verifyEmail } from '../resolvers/auth/verifyEmail.js'\nimport { countResolver } from '../resolvers/collections/count.js'\nimport { createResolver } from '../resolvers/collections/create.js'\nimport { getDeleteResolver } from '../resolvers/collections/delete.js'\nimport { docAccessResolver } from '../resolvers/collections/docAccess.js'\nimport { duplicateResolver } from '../resolvers/collections/duplicate.js'\nimport { findResolver } from '../resolvers/collections/find.js'\nimport { findByIDResolver } from '../resolvers/collections/findByID.js'\nimport { findVersionByIDResolver } from '../resolvers/collections/findVersionByID.js'\nimport { findVersionsResolver } from '../resolvers/collections/findVersions.js'\nimport { renameFileResolver } from '../resolvers/collections/renameFile.js'\nimport { restoreVersionResolver } from '../resolvers/collections/restoreVersion.js'\nimport { updateResolver } from '../resolvers/collections/update.js'\nimport { validateResolver } from '../resolvers/collections/validate.js'\nimport { formatName } from '../utilities/formatName.js'\nimport { buildMutationInputType, getCollectionIDType } from './buildMutationInputType.js'\nimport { buildObjectType } from './buildObjectType.js'\nimport { buildPaginatedListType } from './buildPaginatedListType.js'\nimport { buildPolicyType } from './buildPoliciesType.js'\nimport { buildWhereInputType } from './buildWhereInputType.js'\n\ntype InitCollectionsGraphQLArgs = {\n config: SanitizedConfig\n graphqlResult: GraphQLInfo\n}\nexport function initCollections({ config, graphqlResult }: InitCollectionsGraphQLArgs): void {\n Object.keys(graphqlResult.collections).forEach((slug) => {\n const collection: Collection = graphqlResult.collections[slug]\n const {\n config: collectionConfig,\n config: { fields, graphQL = {}, versions },\n } = collection\n\n if (!graphQL) {\n return\n }\n\n let singularName\n let pluralName\n\n const fromSlug = formatNames(collection.config.slug)\n\n if (graphQL.singularName) {\n singularName = toWords(graphQL.singularName, true)\n } else {\n singularName = fromSlug.singular\n }\n if (graphQL.pluralName) {\n pluralName = toWords(graphQL.pluralName, true)\n } else {\n pluralName = fromSlug.plural\n }\n\n // For collections named 'Media' or similar,\n // there is a possibility that the singular name\n // will equal the plural name. Append `all` to the beginning\n // of potential conflicts\n if (singularName === pluralName) {\n pluralName = `all${singularName}`\n }\n\n collection.graphQL = {} as Collection['graphQL']\n\n const hasIDField =\n flattenTopLevelFields(fields).findIndex(\n (field) => fieldAffectsData(field) && field.name === 'id',\n ) > -1\n\n const idType = getCollectionIDType(config.db.defaultIDType, collectionConfig)\n\n const baseFields: ObjectTypeConfig = {}\n\n const whereInputFields = [...fields]\n\n if (!hasIDField) {\n baseFields.id = { type: new GraphQLNonNull(idType) }\n whereInputFields.push({\n name: 'id',\n type: config.db.defaultIDType as 'text',\n })\n }\n\n if (collectionConfig.auth) {\n baseFields._strategy = { type: GraphQLString }\n }\n\n const forceNullableObjectType = Boolean(versions?.drafts)\n\n collection.graphQL.type = buildObjectType({\n name: singularName,\n baseFields,\n collectionSlug: collectionConfig.slug,\n config,\n fields,\n forceNullable: forceNullableObjectType,\n graphqlResult,\n parentName: singularName,\n })\n\n collection.graphQL.paginatedType = buildPaginatedListType(pluralName, collection.graphQL.type)\n\n collection.graphQL.whereInputType = buildWhereInputType({\n name: singularName,\n fields: whereInputFields,\n parentName: singularName,\n })\n\n const mutationInputFields = [...fields]\n\n if (\n collectionConfig.auth &&\n (!collectionConfig.auth.disableLocalStrategy ||\n (typeof collectionConfig.auth.disableLocalStrategy === 'object' &&\n collectionConfig.auth.disableLocalStrategy.optionalPassword))\n ) {\n mutationInputFields.push({\n name: 'password',\n type: 'text',\n label: 'Password',\n required: !(\n typeof collectionConfig.auth.disableLocalStrategy === 'object' &&\n collectionConfig.auth.disableLocalStrategy.optionalPassword\n ),\n })\n }\n\n let mutationCreateInputFields = mutationInputFields\n\n if (\n config.db.allowIDOnCreate &&\n !collectionConfig.flattenedFields.some((field) => field.name === 'id')\n ) {\n mutationCreateInputFields = [\n ...mutationCreateInputFields,\n {\n name: 'id',\n type: config.db.defaultIDType,\n } as Field,\n ]\n }\n\n const createMutationInputType = buildMutationInputType({\n name: singularName,\n config,\n fields: mutationCreateInputFields,\n graphqlResult,\n parentIsLocalized: false,\n parentName: singularName,\n })\n if (createMutationInputType) {\n collection.graphQL.mutationInputType = new GraphQLNonNull(createMutationInputType)\n }\n\n const updateMutationInputType = buildMutationInputType({\n name: `${singularName}Update`,\n config,\n fields: mutationInputFields.filter(\n (field) => !(fieldAffectsData(field) && field.name === 'id'),\n ),\n forceNullable: true,\n graphqlResult,\n parentIsLocalized: false,\n parentName: `${singularName}Update`,\n })\n if (updateMutationInputType) {\n collection.graphQL.updateMutationInputType = new GraphQLNonNull(updateMutationInputType)\n }\n\n const validationMutationInputType = buildMutationInputType({\n name: `${singularName}Validation`,\n config,\n fields: mutationCreateInputFields,\n forceNullable: true,\n graphqlResult,\n parentIsLocalized: false,\n parentName: `${singularName}Validation`,\n })\n\n const queriesEnabled =\n typeof collectionConfig.graphQL !== 'object' || !collectionConfig.graphQL.disableQueries\n const mutationsEnabled =\n typeof collectionConfig.graphQL !== 'object' || !collectionConfig.graphQL.disableMutations\n\n if (queriesEnabled) {\n graphqlResult.Query.fields[singularName] = {\n type: collection.graphQL.type,\n args: {\n id: { type: new GraphQLNonNull(idType) },\n branch: { type: GraphQLString },\n draft: { type: GraphQLBoolean },\n ...(config.localization\n ? {\n fallbackLocale: { type: graphqlResult.types.fallbackLocaleInputType },\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n select: { type: GraphQLBoolean },\n trash: { type: GraphQLBoolean },\n },\n resolve: findByIDResolver(collection),\n }\n\n graphqlResult.Query.fields[pluralName] = {\n type: buildPaginatedListType(pluralName, collection.graphQL.type),\n args: {\n branch: { type: GraphQLString },\n draft: { type: GraphQLBoolean },\n where: { type: collection.graphQL.whereInputType },\n ...(config.localization\n ? {\n fallbackLocale: { type: graphqlResult.types.fallbackLocaleInputType },\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n limit: { type: GraphQLInt },\n page: { type: GraphQLInt },\n pagination: { type: GraphQLBoolean },\n select: { type: GraphQLBoolean },\n sort: { type: GraphQLString },\n trash: { type: GraphQLBoolean },\n },\n resolve: findResolver(collection),\n }\n\n graphqlResult.Query.fields[`count${pluralName}`] = {\n type: new GraphQLObjectType({\n name: `count${pluralName}`,\n fields: {\n totalDocs: { type: GraphQLInt },\n },\n }),\n args: {\n branch: { type: GraphQLString },\n draft: { type: GraphQLBoolean },\n trash: { type: GraphQLBoolean },\n where: { type: collection.graphQL.whereInputType },\n ...(config.localization\n ? {\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n },\n resolve: countResolver(collection),\n }\n\n graphqlResult.Query.fields[`docAccess${singularName}`] = {\n type: buildPolicyType({\n type: 'collection',\n entity: collectionConfig,\n scope: 'docAccess',\n typeSuffix: 'DocAccess',\n }),\n args: {\n id: { type: new GraphQLNonNull(idType) },\n branch: { type: GraphQLString },\n },\n resolve: docAccessResolver(collection),\n }\n }\n\n if (mutationsEnabled) {\n graphqlResult.Mutation.fields[`create${singularName}`] = {\n type: collection.graphQL.type,\n args: {\n ...(createMutationInputType\n ? { data: { type: collection.graphQL.mutationInputType } }\n : {}),\n branch: { type: GraphQLString },\n draft: { type: GraphQLBoolean },\n ...(config.localization\n ? {\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n },\n resolve: createResolver(collection),\n }\n\n graphqlResult.Mutation.fields[`update${singularName}`] = {\n type: collection.graphQL.type,\n args: {\n id: { type: new GraphQLNonNull(idType) },\n autosave: { type: GraphQLBoolean },\n ...(updateMutationInputType\n ? { data: { type: collection.graphQL.updateMutationInputType } }\n : {}),\n branch: { type: GraphQLString },\n draft: { type: GraphQLBoolean },\n ...(config.localization\n ? {\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n trash: { type: GraphQLBoolean },\n },\n resolve: updateResolver(collection),\n }\n\n graphqlResult.Mutation.fields[`validate${singularName}`] = {\n type: graphqlResult.types.validationResultType,\n args: {\n id: { type: idType },\n ...(validationMutationInputType ? { data: { type: validationMutationInputType } } : {}),\n draft: { type: GraphQLBoolean },\n ...(config.localization\n ? {\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n },\n resolve: validateResolver(collection),\n }\n\n graphqlResult.Mutation.fields[`delete${singularName}`] = {\n type: collection.graphQL.type,\n args: {\n id: { type: new GraphQLNonNull(idType) },\n branch: { type: GraphQLString },\n trash: { type: GraphQLBoolean },\n },\n resolve: getDeleteResolver(collection),\n }\n\n if (collectionConfig.disableDuplicate !== true) {\n graphqlResult.Mutation.fields[`duplicate${singularName}`] = {\n type: collection.graphQL.type,\n args: {\n id: { type: new GraphQLNonNull(idType) },\n branch: { type: GraphQLString },\n ...(createMutationInputType\n ? { data: { type: collection.graphQL.mutationInputType } }\n : {}),\n },\n resolve: duplicateResolver(collection),\n }\n }\n }\n\n if (collectionConfig.versions) {\n const versionIDType = config.db.defaultIDType === 'text' ? GraphQLString : GraphQLInt\n const versionCollectionFields: Field[] = [\n ...buildVersionCollectionFields(config, collectionConfig),\n {\n name: 'id',\n type: config.db.defaultIDType as 'text',\n },\n {\n name: 'createdAt',\n type: 'date',\n label: ({ t }) => t('general:createdAt'),\n },\n {\n name: 'updatedAt',\n type: 'date',\n label: ({ t }) => t('general:updatedAt'),\n },\n ]\n\n collection.graphQL.versionType = buildObjectType({\n name: `${singularName}Version`,\n collectionSlug: collectionConfig.slug,\n config,\n fields: versionCollectionFields.filter(\n (field) => !('name' in field) || field.name !== '_branchParent',\n ),\n forceNullable: forceNullableObjectType,\n graphqlResult,\n parentName: `${singularName}Version`,\n })\n\n if (queriesEnabled) {\n graphqlResult.Query.fields[`version${formatName(singularName)}`] = {\n type: collection.graphQL.versionType,\n args: {\n id: { type: versionIDType },\n branch: { type: GraphQLString },\n ...(config.localization\n ? {\n fallbackLocale: { type: graphqlResult.types.fallbackLocaleInputType },\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n trash: { type: GraphQLBoolean },\n },\n resolve: findVersionByIDResolver(collection),\n }\n graphqlResult.Query.fields[`versions${pluralName}`] = {\n type: buildPaginatedListType(\n `versions${formatName(pluralName)}`,\n collection.graphQL.versionType,\n ),\n args: {\n branch: { type: GraphQLString },\n where: {\n type: buildWhereInputType({\n name: `versions${singularName}`,\n fields: versionCollectionFields,\n parentName: `versions${singularName}`,\n }),\n },\n ...(config.localization\n ? {\n fallbackLocale: { type: graphqlResult.types.fallbackLocaleInputType },\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n limit: { type: GraphQLInt },\n page: { type: GraphQLInt },\n pagination: { type: GraphQLBoolean },\n select: { type: GraphQLBoolean },\n sort: { type: GraphQLString },\n trash: { type: GraphQLBoolean },\n },\n resolve: findVersionsResolver(collection),\n }\n }\n\n if (mutationsEnabled) {\n graphqlResult.Mutation.fields[`restoreVersion${formatName(singularName)}`] = {\n type: collection.graphQL.type,\n args: {\n id: { type: versionIDType },\n branch: { type: GraphQLString },\n draft: { type: GraphQLBoolean },\n },\n resolve: restoreVersionResolver(collection),\n }\n }\n }\n\n if (mutationsEnabled && collectionConfig.upload) {\n graphqlResult.Mutation.fields[`renameFile${formatName(singularName)}`] = {\n type: collection.graphQL.type,\n args: {\n id: { type: new GraphQLNonNull(idType) },\n draft: { type: GraphQLBoolean },\n filename: { type: new GraphQLNonNull(GraphQLString) },\n },\n resolve: renameFileResolver(collection),\n }\n }\n\n if (collectionConfig.auth) {\n const authFields: Field[] =\n collectionConfig.auth.disableLocalStrategy ||\n (collectionConfig.auth.loginWithUsername &&\n !collectionConfig.auth.loginWithUsername.allowEmailLogin &&\n !collectionConfig.auth.loginWithUsername.requireEmail)\n ? []\n : [\n {\n name: 'email',\n type: 'email',\n required: true,\n },\n ]\n collection.graphQL.JWT = buildObjectType({\n name: formatName(`${slug}JWT`),\n config,\n fields: [\n ...collectionConfig.fields.filter((field) => fieldAffectsData(field) && field.saveToJWT),\n ...authFields,\n {\n name: 'collection',\n type: 'text',\n required: true,\n },\n {\n name: '_strategy',\n type: 'text',\n },\n ],\n graphqlResult,\n parentName: formatName(`${slug}JWT`),\n })\n\n if (queriesEnabled) {\n graphqlResult.Query.fields[`me${singularName}`] = {\n type: new GraphQLObjectType({\n name: formatName(`${slug}Me`),\n fields: {\n collection: {\n type: GraphQLString,\n },\n exp: {\n type: GraphQLInt,\n },\n token: {\n type: GraphQLString,\n },\n user: {\n type: collection.graphQL.type,\n },\n },\n }),\n resolve: me(collection),\n }\n\n graphqlResult.Query.fields[`initialized${singularName}`] = {\n type: GraphQLBoolean,\n resolve: init(collection.config.slug),\n }\n }\n\n if (mutationsEnabled) {\n graphqlResult.Mutation.fields[`refreshToken${singularName}`] = {\n type: new GraphQLObjectType({\n name: formatName(`${slug}Refreshed${singularName}`),\n fields: {\n exp: {\n type: GraphQLInt,\n },\n refreshedToken: {\n type: GraphQLString,\n },\n user: {\n type: collection.graphQL.JWT,\n },\n },\n }),\n resolve: refresh(collection),\n }\n\n graphqlResult.Mutation.fields[`logout${singularName}`] = {\n type: GraphQLString,\n args: {\n allSessions: { type: GraphQLBoolean },\n },\n resolve: logout(collection),\n }\n\n if (!collectionConfig.auth.disableLocalStrategy) {\n const authArgs = {}\n\n const { canLoginWithEmail, canLoginWithUsername } = getLoginOptions(\n collectionConfig.auth.loginWithUsername,\n )\n\n if (canLoginWithEmail) {\n authArgs['email'] = { type: new GraphQLNonNull(GraphQLString) }\n }\n if (canLoginWithUsername) {\n authArgs['username'] = { type: new GraphQLNonNull(GraphQLString) }\n }\n\n if (collectionConfig.auth.maxLoginAttempts > 0) {\n graphqlResult.Mutation.fields[`unlock${singularName}`] = {\n type: new GraphQLNonNull(GraphQLBoolean),\n args: authArgs,\n resolve: unlock(collection),\n }\n }\n\n graphqlResult.Mutation.fields[`login${singularName}`] = {\n type: new GraphQLObjectType({\n name: formatName(`${slug}LoginResult`),\n fields: {\n exp: {\n type: GraphQLInt,\n },\n token: {\n type: GraphQLString,\n },\n user: {\n type: collection.graphQL.type,\n },\n },\n }),\n args: {\n ...authArgs,\n password: { type: GraphQLString },\n },\n resolve: login(collection),\n }\n\n graphqlResult.Mutation.fields[`forgotPassword${singularName}`] = {\n type: new GraphQLNonNull(GraphQLBoolean),\n args: {\n ...authArgs,\n },\n resolve: forgotPassword(collection),\n }\n\n graphqlResult.Mutation.fields[`resetPassword${singularName}`] = {\n type: new GraphQLObjectType({\n name: formatName(`${slug}ResetPassword`),\n fields: {\n token: { type: GraphQLString },\n user: { type: collection.graphQL.type },\n },\n }),\n args: {\n password: { type: GraphQLString },\n token: { type: GraphQLString },\n },\n resolve: resetPassword(collection),\n }\n\n graphqlResult.Mutation.fields[`verifyEmail${singularName}`] = {\n type: GraphQLBoolean,\n args: {\n token: { type: GraphQLString },\n },\n resolve: verifyEmail(collection),\n }\n }\n }\n }\n })\n}\n"],"names":["GraphQLBoolean","GraphQLInt","GraphQLNonNull","GraphQLObjectType","GraphQLString","buildVersionCollectionFields","flattenTopLevelFields","formatNames","toWords","fieldAffectsData","getLoginOptions","forgotPassword","init","login","logout","me","refresh","resetPassword","unlock","verifyEmail","countResolver","createResolver","getDeleteResolver","docAccessResolver","duplicateResolver","findResolver","findByIDResolver","findVersionByIDResolver","findVersionsResolver","renameFileResolver","restoreVersionResolver","updateResolver","validateResolver","formatName","buildMutationInputType","getCollectionIDType","buildObjectType","buildPaginatedListType","buildPolicyType","buildWhereInputType","initCollections","config","graphqlResult","Object","keys","collections","forEach","slug","collection","collectionConfig","fields","graphQL","versions","singularName","pluralName","fromSlug","singular","plural","hasIDField","findIndex","field","name","idType","db","defaultIDType","baseFields","whereInputFields","id","type","push","auth","_strategy","forceNullableObjectType","Boolean","drafts","collectionSlug","forceNullable","parentName","paginatedType","whereInputType","mutationInputFields","disableLocalStrategy","optionalPassword","label","required","mutationCreateInputFields","allowIDOnCreate","flattenedFields","some","createMutationInputType","parentIsLocalized","mutationInputType","updateMutationInputType","filter","validationMutationInputType","queriesEnabled","disableQueries","mutationsEnabled","disableMutations","Query","args","branch","draft","localization","fallbackLocale","types","fallbackLocaleInputType","locale","localeInputType","select","trash","resolve","where","limit","page","pagination","sort","totalDocs","entity","scope","typeSuffix","Mutation","data","autosave","validationResultType","disableDuplicate","versionIDType","versionCollectionFields","t","versionType","upload","filename","authFields","loginWithUsername","allowEmailLogin","requireEmail","JWT","saveToJWT","exp","token","user","refreshedToken","allSessions","authArgs","canLoginWithEmail","canLoginWithUsername","maxLoginAttempts","password"],"mappings":"AAQA,SACEA,cAAc,EACdC,UAAU,EACVC,cAAc,EACdC,iBAAiB,EACjBC,aAAa,QACR,UAAS;AAChB,SAASC,4BAA4B,EAAEC,qBAAqB,EAAEC,WAAW,EAAEC,OAAO,QAAQ,UAAS;AACnG,SAASC,gBAAgB,EAAEC,eAAe,QAAQ,iBAAgB;AA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wBACF;wBACAgC,MAAM;4BACJ,GAAG2C,QAAQ;4BACXI,UAAU;gCAAE/E,MAAMhE;4BAAc;wBAClC;wBACA2G,SAASlG,MAAMmC;oBACjB;oBAEAN,cAAc+E,QAAQ,CAACvE,MAAM,CAAC,CAAC,cAAc,EAAEG,cAAc,CAAC,GAAG;wBAC/De,MAAM,IAAIlE,eAAeF;wBACzBoG,MAAM;4BACJ,GAAG2C,QAAQ;wBACb;wBACAhC,SAASpG,eAAeqC;oBAC1B;oBAEAN,cAAc+E,QAAQ,CAACvE,MAAM,CAAC,CAAC,aAAa,EAAEG,cAAc,CAAC,GAAG;wBAC9De,MAAM,IAAIjE,kBAAkB;4BAC1B0D,MAAM5B,WAAW,GAAGc,KAAK,aAAa,CAAC;4BACvCG,QAAQ;gCACNyF,OAAO;oCAAEvE,MAAMhE;gCAAc;gCAC7BwI,MAAM;oCAAExE,MAAMpB,WAAWG,OAAO,CAACiB,IAAI;gCAAC;4BACxC;wBACF;wBACAgC,MAAM;4BACJ+C,UAAU;gCAAE/E,MAAMhE;4BAAc;4BAChCuI,OAAO;gCAAEvE,MAAMhE;4BAAc;wBAC/B;wBACA2G,SAAS9F,cAAc+B;oBACzB;oBAEAN,cAAc+E,QAAQ,CAACvE,MAAM,CAAC,CAAC,WAAW,EAAEG,cAAc,CAAC,GAAG;wBAC5De,MAAMpE;wBACNoG,MAAM;4BACJuC,OAAO;gCAAEvE,MAAMhE;4BAAc;wBAC/B;wBACA2G,SAAS5F,YAAY6B;oBACvB;gBACF;YACF;QACF;IACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"groupOrTabHasRequiredSubfield.d.ts","sourceRoot":"","sources":["../../src/utilities/groupOrTabHasRequiredSubfield.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,SAAS,CAAA;AAIzC,eAAO,MAAM,6BAA6B,WAAY,KAAK,GAAG,GAAG,KAAG,OAenE,CAAA"}
1
+ {"version":3,"file":"groupOrTabHasRequiredSubfield.d.ts","sourceRoot":"","sources":["../../src/utilities/groupOrTabHasRequiredSubfield.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,SAAS,CAAA;AAIzC,eAAO,MAAM,6BAA6B,WAAY,KAAK,GAAG,GAAG,KAAG,OAsBnE,CAAA"}
@@ -1,8 +1,11 @@
1
1
  import { fieldAffectsData } from 'payload/shared';
2
2
  export const groupOrTabHasRequiredSubfield = (entity)=>{
3
+ if ('hidden' in entity && entity.hidden) {
4
+ return false;
5
+ }
3
6
  if ('type' in entity && entity.type === 'group') {
4
7
  return entity.fields.some((subField)=>{
5
- return fieldAffectsData(subField) && 'required' in subField && subField.required || groupOrTabHasRequiredSubfield(subField);
8
+ return fieldAffectsData(subField) && !subField.hidden && 'required' in subField && subField.required || groupOrTabHasRequiredSubfield(subField);
6
9
  });
7
10
  }
8
11
  if ('fields' in entity && 'name' in entity) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utilities/groupOrTabHasRequiredSubfield.ts"],"sourcesContent":["import type { Field, Tab } from 'payload'\n\nimport { fieldAffectsData } from 'payload/shared'\n\nexport const groupOrTabHasRequiredSubfield = (entity: Field | Tab): boolean => {\n if ('type' in entity && entity.type === 'group') {\n return entity.fields.some((subField) => {\n return (\n (fieldAffectsData(subField) && 'required' in subField && subField.required) ||\n groupOrTabHasRequiredSubfield(subField)\n )\n })\n }\n\n if ('fields' in entity && 'name' in entity) {\n return (entity as Tab).fields.some((subField) => groupOrTabHasRequiredSubfield(subField))\n }\n\n return false\n}\n"],"names":["fieldAffectsData","groupOrTabHasRequiredSubfield","entity","type","fields","some","subField","required"],"mappings":"AAEA,SAASA,gBAAgB,QAAQ,iBAAgB;AAEjD,OAAO,MAAMC,gCAAgC,CAACC;IAC5C,IAAI,UAAUA,UAAUA,OAAOC,IAAI,KAAK,SAAS;QAC/C,OAAOD,OAAOE,MAAM,CAACC,IAAI,CAAC,CAACC;YACzB,OACE,AAACN,iBAAiBM,aAAa,cAAcA,YAAYA,SAASC,QAAQ,IAC1EN,8BAA8BK;QAElC;IACF;IAEA,IAAI,YAAYJ,UAAU,UAAUA,QAAQ;QAC1C,OAAO,AAACA,OAAeE,MAAM,CAACC,IAAI,CAAC,CAACC,WAAaL,8BAA8BK;IACjF;IAEA,OAAO;AACT,EAAC"}
1
+ {"version":3,"sources":["../../src/utilities/groupOrTabHasRequiredSubfield.ts"],"sourcesContent":["import type { Field, Tab } from 'payload'\n\nimport { fieldAffectsData } from 'payload/shared'\n\nexport const groupOrTabHasRequiredSubfield = (entity: Field | Tab): boolean => {\n if ('hidden' in entity && entity.hidden) {\n return false\n }\n\n if ('type' in entity && entity.type === 'group') {\n return entity.fields.some((subField) => {\n return (\n (fieldAffectsData(subField) &&\n !subField.hidden &&\n 'required' in subField &&\n subField.required) ||\n groupOrTabHasRequiredSubfield(subField)\n )\n })\n }\n\n if ('fields' in entity && 'name' in entity) {\n return (entity as Tab).fields.some((subField) => groupOrTabHasRequiredSubfield(subField))\n }\n\n return false\n}\n"],"names":["fieldAffectsData","groupOrTabHasRequiredSubfield","entity","hidden","type","fields","some","subField","required"],"mappings":"AAEA,SAASA,gBAAgB,QAAQ,iBAAgB;AAEjD,OAAO,MAAMC,gCAAgC,CAACC;IAC5C,IAAI,YAAYA,UAAUA,OAAOC,MAAM,EAAE;QACvC,OAAO;IACT;IAEA,IAAI,UAAUD,UAAUA,OAAOE,IAAI,KAAK,SAAS;QAC/C,OAAOF,OAAOG,MAAM,CAACC,IAAI,CAAC,CAACC;YACzB,OACE,AAACP,iBAAiBO,aAChB,CAACA,SAASJ,MAAM,IAChB,cAAcI,YACdA,SAASC,QAAQ,IACnBP,8BAA8BM;QAElC;IACF;IAEA,IAAI,YAAYL,UAAU,UAAUA,QAAQ;QAC1C,OAAO,AAACA,OAAeG,MAAM,CAACC,IAAI,CAAC,CAACC,WAAaN,8BAA8BM;IACjF;IAEA,OAAO;AACT,EAAC"}
package/package.json CHANGED
@@ -1,12 +1,7 @@
1
1
  {
2
2
  "name": "@payloadcms/graphql",
3
- "version": "4.0.0-internal.ea6e8f8",
3
+ "version": "4.0.0-internal.ec73d44",
4
4
  "homepage": "https://payloadcms.com",
5
- "repository": {
6
- "type": "git",
7
- "url": "https://github.com/payloadcms/payload.git",
8
- "directory": "packages/graphql"
9
- },
10
5
  "license": "MIT",
11
6
  "author": "Payload <dev@payloadcms.com> (https://payloadcms.com)",
12
7
  "maintainers": [
@@ -16,8 +11,21 @@
16
11
  "url": "https://payloadcms.com"
17
12
  }
18
13
  ],
19
- "sideEffects": false,
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "https://github.com/payloadcms/payload.git",
17
+ "directory": "packages/graphql"
18
+ },
19
+ "bin": {
20
+ "payload-graphql": "bin.js"
21
+ },
22
+ "files": [
23
+ "dist"
24
+ ],
20
25
  "type": "module",
26
+ "sideEffects": false,
27
+ "main": "./dist/index.js",
28
+ "types": "./dist/index.d.ts",
21
29
  "exports": {
22
30
  ".": {
23
31
  "import": "./dist/index.js",
@@ -35,14 +43,6 @@
35
43
  "default": "./dist/exports/utilities.js"
36
44
  }
37
45
  },
38
- "main": "./dist/index.js",
39
- "types": "./dist/index.d.ts",
40
- "bin": {
41
- "payload-graphql": "bin.js"
42
- },
43
- "files": [
44
- "dist"
45
- ],
46
46
  "dependencies": {
47
47
  "graphql-scalars": "1.22.2",
48
48
  "pluralize": "8.0.0",
@@ -52,20 +52,17 @@
52
52
  "devDependencies": {
53
53
  "@types/pluralize": "^0.0.33",
54
54
  "graphql-http": "1.22.4",
55
- "@payloadcms/eslint-config": "3.28.0",
56
- "payload": "4.0.0-internal.ea6e8f8"
55
+ "payload": "4.0.0-internal.ec73d44"
57
56
  },
58
57
  "peerDependencies": {
59
58
  "graphql": "^16.8.1",
60
- "payload": "4.0.0-internal.ea6e8f8"
59
+ "payload": "4.0.0-internal.ec73d44"
61
60
  },
62
61
  "scripts": {
63
62
  "build": "pnpm build:types && pnpm build:swc",
64
63
  "build:debug": "pnpm build",
65
64
  "build:swc": "swc ./src -d ./dist --config-file .swcrc --strip-leading-paths",
66
65
  "build:types": "tsc --emitDeclarationOnly --outDir dist",
67
- "clean": "rimraf -g {dist,*.tsbuildinfo}",
68
- "lint": "eslint .",
69
- "lint:fix": "eslint . --fix"
66
+ "clean": "rimraf -g {dist,*.tsbuildinfo}"
70
67
  }
71
68
  }