@payloadcms/graphql 4.0.0-internal.e55ccef → 4.0.0-internal.ea6e8f8
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/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/resolvers/collections/count.d.ts +3 -1
- package/dist/resolvers/collections/count.d.ts.map +1 -1
- package/dist/resolvers/collections/count.js +11 -11
- package/dist/resolvers/collections/count.js.map +1 -1
- package/dist/resolvers/collections/create.d.ts +3 -1
- package/dist/resolvers/collections/create.d.ts.map +1 -1
- package/dist/resolvers/collections/create.js +11 -6
- package/dist/resolvers/collections/create.js.map +1 -1
- package/dist/resolvers/collections/delete.d.ts +3 -1
- package/dist/resolvers/collections/delete.d.ts.map +1 -1
- package/dist/resolvers/collections/delete.js +12 -14
- package/dist/resolvers/collections/delete.js.map +1 -1
- package/dist/resolvers/collections/docAccess.d.ts +5 -4
- package/dist/resolvers/collections/docAccess.d.ts.map +1 -1
- package/dist/resolvers/collections/docAccess.js +10 -3
- package/dist/resolvers/collections/docAccess.js.map +1 -1
- package/dist/resolvers/collections/duplicate.d.ts +3 -1
- package/dist/resolvers/collections/duplicate.d.ts.map +1 -1
- package/dist/resolvers/collections/duplicate.js +12 -9
- package/dist/resolvers/collections/duplicate.js.map +1 -1
- package/dist/resolvers/collections/find.d.ts +1 -0
- package/dist/resolvers/collections/find.d.ts.map +1 -1
- package/dist/resolvers/collections/find.js +11 -10
- package/dist/resolvers/collections/find.js.map +1 -1
- package/dist/resolvers/collections/findByID.d.ts +1 -0
- package/dist/resolvers/collections/findByID.d.ts.map +1 -1
- package/dist/resolvers/collections/findByID.js +11 -10
- package/dist/resolvers/collections/findByID.js.map +1 -1
- package/dist/resolvers/collections/findVersionByID.d.ts +1 -0
- package/dist/resolvers/collections/findVersionByID.d.ts.map +1 -1
- package/dist/resolvers/collections/findVersionByID.js +11 -10
- package/dist/resolvers/collections/findVersionByID.js.map +1 -1
- package/dist/resolvers/collections/findVersions.d.ts +1 -0
- package/dist/resolvers/collections/findVersions.d.ts.map +1 -1
- package/dist/resolvers/collections/findVersions.js +11 -10
- package/dist/resolvers/collections/findVersions.js.map +1 -1
- package/dist/resolvers/collections/renameFile.d.ts +8 -0
- package/dist/resolvers/collections/renameFile.d.ts.map +1 -0
- package/dist/resolvers/collections/renameFile.js +10 -0
- package/dist/resolvers/collections/renameFile.js.map +1 -0
- package/dist/resolvers/collections/restoreVersion.d.ts +3 -1
- package/dist/resolvers/collections/restoreVersion.d.ts.map +1 -1
- package/dist/resolvers/collections/restoreVersion.js +10 -3
- package/dist/resolvers/collections/restoreVersion.js.map +1 -1
- package/dist/resolvers/collections/update.d.ts +3 -1
- package/dist/resolvers/collections/update.d.ts.map +1 -1
- package/dist/resolvers/collections/update.js +12 -14
- package/dist/resolvers/collections/update.js.map +1 -1
- package/dist/resolvers/collections/validate.d.ts +16 -0
- package/dist/resolvers/collections/validate.d.ts.map +1 -0
- package/dist/resolvers/collections/validate.js +33 -0
- package/dist/resolvers/collections/validate.js.map +1 -0
- package/dist/resolvers/getGraphQLRequest.d.ts +26 -0
- package/dist/resolvers/getGraphQLRequest.d.ts.map +1 -0
- package/dist/resolvers/getGraphQLRequest.js +69 -0
- package/dist/resolvers/getGraphQLRequest.js.map +1 -0
- package/dist/resolvers/globals/docAccess.d.ts +6 -4
- package/dist/resolvers/globals/docAccess.d.ts.map +1 -1
- package/dist/resolvers/globals/docAccess.js +10 -3
- package/dist/resolvers/globals/docAccess.js.map +1 -1
- package/dist/resolvers/globals/findOne.d.ts +1 -0
- package/dist/resolvers/globals/findOne.d.ts.map +1 -1
- package/dist/resolvers/globals/findOne.js +11 -10
- package/dist/resolvers/globals/findOne.js.map +1 -1
- package/dist/resolvers/globals/findVersionByID.d.ts +1 -0
- package/dist/resolvers/globals/findVersionByID.d.ts.map +1 -1
- package/dist/resolvers/globals/findVersionByID.js +11 -10
- package/dist/resolvers/globals/findVersionByID.js.map +1 -1
- package/dist/resolvers/globals/findVersions.d.ts +1 -0
- package/dist/resolvers/globals/findVersions.d.ts.map +1 -1
- package/dist/resolvers/globals/findVersions.js +11 -10
- package/dist/resolvers/globals/findVersions.js.map +1 -1
- package/dist/resolvers/globals/restoreVersion.d.ts +3 -1
- package/dist/resolvers/globals/restoreVersion.d.ts.map +1 -1
- package/dist/resolvers/globals/restoreVersion.js +11 -4
- package/dist/resolvers/globals/restoreVersion.js.map +1 -1
- package/dist/resolvers/globals/update.d.ts +3 -1
- package/dist/resolvers/globals/update.d.ts.map +1 -1
- package/dist/resolvers/globals/update.js +12 -9
- package/dist/resolvers/globals/update.js.map +1 -1
- package/dist/resolvers/globals/validate.d.ts +15 -0
- package/dist/resolvers/globals/validate.d.ts.map +1 -0
- package/dist/resolvers/globals/validate.js +21 -0
- package/dist/resolvers/globals/validate.js.map +1 -0
- package/dist/schema/buildMutationInputType.d.ts.map +1 -1
- package/dist/schema/buildMutationInputType.js +8 -2
- package/dist/schema/buildMutationInputType.js.map +1 -1
- package/dist/schema/buildPoliciesType.d.ts +1 -1
- package/dist/schema/buildPoliciesType.d.ts.map +1 -1
- package/dist/schema/buildPoliciesType.js +6 -3
- package/dist/schema/buildPoliciesType.js.map +1 -1
- package/dist/schema/buildValidationResultType.d.ts +3 -0
- package/dist/schema/buildValidationResultType.d.ts.map +1 -0
- package/dist/schema/buildValidationResultType.js +30 -0
- package/dist/schema/buildValidationResultType.js.map +1 -0
- package/dist/schema/fieldToSchemaMap.d.ts.map +1 -1
- package/dist/schema/fieldToSchemaMap.js +46 -23
- package/dist/schema/fieldToSchemaMap.js.map +1 -1
- package/dist/schema/initCollections.d.ts.map +1 -1
- package/dist/schema/initCollections.js +92 -6
- package/dist/schema/initCollections.js.map +1 -1
- package/dist/schema/initGlobals.d.ts.map +1 -1
- package/dist/schema/initGlobals.js +49 -0
- package/dist/schema/initGlobals.js.map +1 -1
- package/dist/schema/withOperators.d.ts +6 -0
- package/dist/schema/withOperators.d.ts.map +1 -1
- package/dist/schema/withOperators.js +15 -0
- package/dist/schema/withOperators.js.map +1 -1
- package/dist/utilities/select.d.ts +4 -3
- package/dist/utilities/select.d.ts.map +1 -1
- package/dist/utilities/select.js +83 -45
- package/dist/utilities/select.js.map +1 -1
- package/package.json +4 -4
- package/dist/utilities/formatName.spec.js +0 -57
- package/dist/utilities/formatName.spec.js.map +0 -1
- package/dist/utilities/formatUtcOffset.spec.js +0 -142
- package/dist/utilities/formatUtcOffset.spec.js.map +0 -1
|
@@ -19,8 +19,10 @@ import { findResolver } from '../resolvers/collections/find.js';
|
|
|
19
19
|
import { findByIDResolver } from '../resolvers/collections/findByID.js';
|
|
20
20
|
import { findVersionByIDResolver } from '../resolvers/collections/findVersionByID.js';
|
|
21
21
|
import { findVersionsResolver } from '../resolvers/collections/findVersions.js';
|
|
22
|
+
import { renameFileResolver } from '../resolvers/collections/renameFile.js';
|
|
22
23
|
import { restoreVersionResolver } from '../resolvers/collections/restoreVersion.js';
|
|
23
24
|
import { updateResolver } from '../resolvers/collections/update.js';
|
|
25
|
+
import { validateResolver } from '../resolvers/collections/validate.js';
|
|
24
26
|
import { formatName } from '../utilities/formatName.js';
|
|
25
27
|
import { buildMutationInputType, getCollectionIDType } from './buildMutationInputType.js';
|
|
26
28
|
import { buildObjectType } from './buildObjectType.js';
|
|
@@ -70,6 +72,11 @@ export function initCollections({ config, graphqlResult }) {
|
|
|
70
72
|
type: config.db.defaultIDType
|
|
71
73
|
});
|
|
72
74
|
}
|
|
75
|
+
if (collectionConfig.auth) {
|
|
76
|
+
baseFields._strategy = {
|
|
77
|
+
type: GraphQLString
|
|
78
|
+
};
|
|
79
|
+
}
|
|
73
80
|
const forceNullableObjectType = Boolean(versions?.drafts);
|
|
74
81
|
collection.graphQL.type = buildObjectType({
|
|
75
82
|
name: singularName,
|
|
@@ -131,6 +138,15 @@ export function initCollections({ config, graphqlResult }) {
|
|
|
131
138
|
if (updateMutationInputType) {
|
|
132
139
|
collection.graphQL.updateMutationInputType = new GraphQLNonNull(updateMutationInputType);
|
|
133
140
|
}
|
|
141
|
+
const validationMutationInputType = buildMutationInputType({
|
|
142
|
+
name: `${singularName}Validation`,
|
|
143
|
+
config,
|
|
144
|
+
fields: mutationCreateInputFields,
|
|
145
|
+
forceNullable: true,
|
|
146
|
+
graphqlResult,
|
|
147
|
+
parentIsLocalized: false,
|
|
148
|
+
parentName: `${singularName}Validation`
|
|
149
|
+
});
|
|
134
150
|
const queriesEnabled = typeof collectionConfig.graphQL !== 'object' || !collectionConfig.graphQL.disableQueries;
|
|
135
151
|
const mutationsEnabled = typeof collectionConfig.graphQL !== 'object' || !collectionConfig.graphQL.disableMutations;
|
|
136
152
|
if (queriesEnabled) {
|
|
@@ -140,6 +156,9 @@ export function initCollections({ config, graphqlResult }) {
|
|
|
140
156
|
id: {
|
|
141
157
|
type: new GraphQLNonNull(idType)
|
|
142
158
|
},
|
|
159
|
+
branch: {
|
|
160
|
+
type: GraphQLString
|
|
161
|
+
},
|
|
143
162
|
draft: {
|
|
144
163
|
type: GraphQLBoolean
|
|
145
164
|
},
|
|
@@ -163,6 +182,9 @@ export function initCollections({ config, graphqlResult }) {
|
|
|
163
182
|
graphqlResult.Query.fields[pluralName] = {
|
|
164
183
|
type: buildPaginatedListType(pluralName, collection.graphQL.type),
|
|
165
184
|
args: {
|
|
185
|
+
branch: {
|
|
186
|
+
type: GraphQLString
|
|
187
|
+
},
|
|
166
188
|
draft: {
|
|
167
189
|
type: GraphQLBoolean
|
|
168
190
|
},
|
|
@@ -208,6 +230,9 @@ export function initCollections({ config, graphqlResult }) {
|
|
|
208
230
|
}
|
|
209
231
|
}),
|
|
210
232
|
args: {
|
|
233
|
+
branch: {
|
|
234
|
+
type: GraphQLString
|
|
235
|
+
},
|
|
211
236
|
draft: {
|
|
212
237
|
type: GraphQLBoolean
|
|
213
238
|
},
|
|
@@ -235,6 +260,9 @@ export function initCollections({ config, graphqlResult }) {
|
|
|
235
260
|
args: {
|
|
236
261
|
id: {
|
|
237
262
|
type: new GraphQLNonNull(idType)
|
|
263
|
+
},
|
|
264
|
+
branch: {
|
|
265
|
+
type: GraphQLString
|
|
238
266
|
}
|
|
239
267
|
},
|
|
240
268
|
resolve: docAccessResolver(collection)
|
|
@@ -249,6 +277,9 @@ export function initCollections({ config, graphqlResult }) {
|
|
|
249
277
|
type: collection.graphQL.mutationInputType
|
|
250
278
|
}
|
|
251
279
|
} : {},
|
|
280
|
+
branch: {
|
|
281
|
+
type: GraphQLString
|
|
282
|
+
},
|
|
252
283
|
draft: {
|
|
253
284
|
type: GraphQLBoolean
|
|
254
285
|
},
|
|
@@ -274,6 +305,9 @@ export function initCollections({ config, graphqlResult }) {
|
|
|
274
305
|
type: collection.graphQL.updateMutationInputType
|
|
275
306
|
}
|
|
276
307
|
} : {},
|
|
308
|
+
branch: {
|
|
309
|
+
type: GraphQLString
|
|
310
|
+
},
|
|
277
311
|
draft: {
|
|
278
312
|
type: GraphQLBoolean
|
|
279
313
|
},
|
|
@@ -288,12 +322,37 @@ export function initCollections({ config, graphqlResult }) {
|
|
|
288
322
|
},
|
|
289
323
|
resolve: updateResolver(collection)
|
|
290
324
|
};
|
|
325
|
+
graphqlResult.Mutation.fields[`validate${singularName}`] = {
|
|
326
|
+
type: graphqlResult.types.validationResultType,
|
|
327
|
+
args: {
|
|
328
|
+
id: {
|
|
329
|
+
type: idType
|
|
330
|
+
},
|
|
331
|
+
...validationMutationInputType ? {
|
|
332
|
+
data: {
|
|
333
|
+
type: validationMutationInputType
|
|
334
|
+
}
|
|
335
|
+
} : {},
|
|
336
|
+
draft: {
|
|
337
|
+
type: GraphQLBoolean
|
|
338
|
+
},
|
|
339
|
+
...config.localization ? {
|
|
340
|
+
locale: {
|
|
341
|
+
type: graphqlResult.types.localeInputType
|
|
342
|
+
}
|
|
343
|
+
} : {}
|
|
344
|
+
},
|
|
345
|
+
resolve: validateResolver(collection)
|
|
346
|
+
};
|
|
291
347
|
graphqlResult.Mutation.fields[`delete${singularName}`] = {
|
|
292
348
|
type: collection.graphQL.type,
|
|
293
349
|
args: {
|
|
294
350
|
id: {
|
|
295
351
|
type: new GraphQLNonNull(idType)
|
|
296
352
|
},
|
|
353
|
+
branch: {
|
|
354
|
+
type: GraphQLString
|
|
355
|
+
},
|
|
297
356
|
trash: {
|
|
298
357
|
type: GraphQLBoolean
|
|
299
358
|
}
|
|
@@ -307,6 +366,9 @@ export function initCollections({ config, graphqlResult }) {
|
|
|
307
366
|
id: {
|
|
308
367
|
type: new GraphQLNonNull(idType)
|
|
309
368
|
},
|
|
369
|
+
branch: {
|
|
370
|
+
type: GraphQLString
|
|
371
|
+
},
|
|
310
372
|
...createMutationInputType ? {
|
|
311
373
|
data: {
|
|
312
374
|
type: collection.graphQL.mutationInputType
|
|
@@ -352,6 +414,9 @@ export function initCollections({ config, graphqlResult }) {
|
|
|
352
414
|
id: {
|
|
353
415
|
type: versionIDType
|
|
354
416
|
},
|
|
417
|
+
branch: {
|
|
418
|
+
type: GraphQLString
|
|
419
|
+
},
|
|
355
420
|
...config.localization ? {
|
|
356
421
|
fallbackLocale: {
|
|
357
422
|
type: graphqlResult.types.fallbackLocaleInputType
|
|
@@ -369,6 +434,9 @@ export function initCollections({ config, graphqlResult }) {
|
|
|
369
434
|
graphqlResult.Query.fields[`versions${pluralName}`] = {
|
|
370
435
|
type: buildPaginatedListType(`versions${formatName(pluralName)}`, collection.graphQL.versionType),
|
|
371
436
|
args: {
|
|
437
|
+
branch: {
|
|
438
|
+
type: GraphQLString
|
|
439
|
+
},
|
|
372
440
|
where: {
|
|
373
441
|
type: buildWhereInputType({
|
|
374
442
|
name: `versions${singularName}`,
|
|
@@ -413,6 +481,9 @@ export function initCollections({ config, graphqlResult }) {
|
|
|
413
481
|
id: {
|
|
414
482
|
type: versionIDType
|
|
415
483
|
},
|
|
484
|
+
branch: {
|
|
485
|
+
type: GraphQLString
|
|
486
|
+
},
|
|
416
487
|
draft: {
|
|
417
488
|
type: GraphQLBoolean
|
|
418
489
|
}
|
|
@@ -421,6 +492,23 @@ export function initCollections({ config, graphqlResult }) {
|
|
|
421
492
|
};
|
|
422
493
|
}
|
|
423
494
|
}
|
|
495
|
+
if (mutationsEnabled && collectionConfig.upload) {
|
|
496
|
+
graphqlResult.Mutation.fields[`renameFile${formatName(singularName)}`] = {
|
|
497
|
+
type: collection.graphQL.type,
|
|
498
|
+
args: {
|
|
499
|
+
id: {
|
|
500
|
+
type: new GraphQLNonNull(idType)
|
|
501
|
+
},
|
|
502
|
+
draft: {
|
|
503
|
+
type: GraphQLBoolean
|
|
504
|
+
},
|
|
505
|
+
filename: {
|
|
506
|
+
type: new GraphQLNonNull(GraphQLString)
|
|
507
|
+
}
|
|
508
|
+
},
|
|
509
|
+
resolve: renameFileResolver(collection)
|
|
510
|
+
};
|
|
511
|
+
}
|
|
424
512
|
if (collectionConfig.auth) {
|
|
425
513
|
const authFields = collectionConfig.auth.disableLocalStrategy || collectionConfig.auth.loginWithUsername && !collectionConfig.auth.loginWithUsername.allowEmailLogin && !collectionConfig.auth.loginWithUsername.requireEmail ? [] : [
|
|
426
514
|
{
|
|
@@ -439,6 +527,10 @@ export function initCollections({ config, graphqlResult }) {
|
|
|
439
527
|
name: 'collection',
|
|
440
528
|
type: 'text',
|
|
441
529
|
required: true
|
|
530
|
+
},
|
|
531
|
+
{
|
|
532
|
+
name: '_strategy',
|
|
533
|
+
type: 'text'
|
|
442
534
|
}
|
|
443
535
|
],
|
|
444
536
|
graphqlResult,
|
|
@@ -455,9 +547,6 @@ export function initCollections({ config, graphqlResult }) {
|
|
|
455
547
|
exp: {
|
|
456
548
|
type: GraphQLInt
|
|
457
549
|
},
|
|
458
|
-
strategy: {
|
|
459
|
-
type: GraphQLString
|
|
460
|
-
},
|
|
461
550
|
token: {
|
|
462
551
|
type: GraphQLString
|
|
463
552
|
},
|
|
@@ -484,9 +573,6 @@ export function initCollections({ config, graphqlResult }) {
|
|
|
484
573
|
refreshedToken: {
|
|
485
574
|
type: GraphQLString
|
|
486
575
|
},
|
|
487
|
-
strategy: {
|
|
488
|
-
type: GraphQLString
|
|
489
|
-
},
|
|
490
576
|
user: {
|
|
491
577
|
type: collection.graphQL.JWT
|
|
492
578
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/schema/initCollections.ts"],"sourcesContent":["import type {\n Collection,\n Field,\n GraphQLInfo,\n SanitizedCollectionConfig,\n SanitizedConfig,\n} from 'payload'\n\nimport {\n GraphQLBoolean,\n GraphQLInt,\n GraphQLNonNull,\n GraphQLObjectType,\n GraphQLString,\n} from 'graphql'\nimport { buildVersionCollectionFields, flattenTopLevelFields, formatNames, toWords } from 'payload'\nimport { fieldAffectsData, getLoginOptions } from 'payload/shared'\n\nimport type { ObjectTypeConfig } from './buildObjectType.js'\n\nimport { forgotPassword } from '../resolvers/auth/forgotPassword.js'\nimport { init } from '../resolvers/auth/init.js'\nimport { login } from '../resolvers/auth/login.js'\nimport { logout } from '../resolvers/auth/logout.js'\nimport { me } from '../resolvers/auth/me.js'\nimport { refresh } from '../resolvers/auth/refresh.js'\nimport { resetPassword } from '../resolvers/auth/resetPassword.js'\nimport { unlock } from '../resolvers/auth/unlock.js'\nimport { verifyEmail } from '../resolvers/auth/verifyEmail.js'\nimport { countResolver } from '../resolvers/collections/count.js'\nimport { createResolver } from '../resolvers/collections/create.js'\nimport { getDeleteResolver } from '../resolvers/collections/delete.js'\nimport { docAccessResolver } from '../resolvers/collections/docAccess.js'\nimport { duplicateResolver } from '../resolvers/collections/duplicate.js'\nimport { findResolver } from '../resolvers/collections/find.js'\nimport { findByIDResolver } from '../resolvers/collections/findByID.js'\nimport { findVersionByIDResolver } from '../resolvers/collections/findVersionByID.js'\nimport { findVersionsResolver } from '../resolvers/collections/findVersions.js'\nimport { restoreVersionResolver } from '../resolvers/collections/restoreVersion.js'\nimport { updateResolver } from '../resolvers/collections/update.js'\nimport { formatName } from '../utilities/formatName.js'\nimport { buildMutationInputType, getCollectionIDType } from './buildMutationInputType.js'\nimport { buildObjectType } from './buildObjectType.js'\nimport { buildPaginatedListType } from './buildPaginatedListType.js'\nimport { buildPolicyType } from './buildPoliciesType.js'\nimport { buildWhereInputType } from './buildWhereInputType.js'\n\ntype InitCollectionsGraphQLArgs = {\n config: SanitizedConfig\n graphqlResult: GraphQLInfo\n}\nexport function initCollections({ config, graphqlResult }: InitCollectionsGraphQLArgs): void {\n Object.keys(graphqlResult.collections).forEach((slug) => {\n const collection: Collection = graphqlResult.collections[slug]\n const {\n config: collectionConfig,\n config: { fields, graphQL = {} as SanitizedCollectionConfig['graphQL'], versions },\n } = collection\n\n if (!graphQL) {\n return\n }\n\n let singularName\n let pluralName\n\n const fromSlug = formatNames(collection.config.slug)\n\n if (graphQL.singularName) {\n singularName = toWords(graphQL.singularName, true)\n } else {\n singularName = fromSlug.singular\n }\n if (graphQL.pluralName) {\n pluralName = toWords(graphQL.pluralName, true)\n } else {\n pluralName = fromSlug.plural\n }\n\n // For collections named 'Media' or similar,\n // there is a possibility that the singular name\n // will equal the plural name. Append `all` to the beginning\n // of potential conflicts\n if (singularName === pluralName) {\n pluralName = `all${singularName}`\n }\n\n collection.graphQL = {} as Collection['graphQL']\n\n const hasIDField =\n flattenTopLevelFields(fields).findIndex(\n (field) => fieldAffectsData(field) && field.name === 'id',\n ) > -1\n\n const idType = getCollectionIDType(config.db.defaultIDType, collectionConfig)\n\n const baseFields: ObjectTypeConfig = {}\n\n const whereInputFields = [...fields]\n\n if (!hasIDField) {\n baseFields.id = { type: new GraphQLNonNull(idType) }\n whereInputFields.push({\n name: 'id',\n type: config.db.defaultIDType as 'text',\n })\n }\n\n const forceNullableObjectType = Boolean(versions?.drafts)\n\n collection.graphQL.type = buildObjectType({\n name: singularName,\n baseFields,\n 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 queriesEnabled =\n typeof collectionConfig.graphQL !== 'object' || !collectionConfig.graphQL.disableQueries\n const mutationsEnabled =\n typeof collectionConfig.graphQL !== 'object' || !collectionConfig.graphQL.disableMutations\n\n if (queriesEnabled) {\n graphqlResult.Query.fields[singularName] = {\n type: collection.graphQL.type,\n args: {\n id: { type: new GraphQLNonNull(idType) },\n draft: { type: GraphQLBoolean },\n ...(config.localization\n ? {\n fallbackLocale: { type: graphqlResult.types.fallbackLocaleInputType },\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n select: { type: GraphQLBoolean },\n trash: { type: GraphQLBoolean },\n },\n resolve: findByIDResolver(collection),\n }\n\n graphqlResult.Query.fields[pluralName] = {\n type: buildPaginatedListType(pluralName, collection.graphQL.type),\n args: {\n draft: { type: GraphQLBoolean },\n where: { type: collection.graphQL.whereInputType },\n ...(config.localization\n ? {\n fallbackLocale: { type: graphqlResult.types.fallbackLocaleInputType },\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n limit: { type: GraphQLInt },\n page: { type: GraphQLInt },\n pagination: { type: GraphQLBoolean },\n select: { type: GraphQLBoolean },\n sort: { type: GraphQLString },\n trash: { type: GraphQLBoolean },\n },\n resolve: findResolver(collection),\n }\n\n graphqlResult.Query.fields[`count${pluralName}`] = {\n type: new GraphQLObjectType({\n name: `count${pluralName}`,\n fields: {\n totalDocs: { type: GraphQLInt },\n },\n }),\n args: {\n draft: { type: GraphQLBoolean },\n trash: { type: GraphQLBoolean },\n where: { type: collection.graphQL.whereInputType },\n ...(config.localization\n ? {\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n },\n resolve: countResolver(collection),\n }\n\n graphqlResult.Query.fields[`docAccess${singularName}`] = {\n type: buildPolicyType({\n type: 'collection',\n entity: collectionConfig,\n scope: 'docAccess',\n typeSuffix: 'DocAccess',\n }),\n args: {\n id: { type: new GraphQLNonNull(idType) },\n },\n resolve: docAccessResolver(collection),\n }\n }\n\n if (mutationsEnabled) {\n graphqlResult.Mutation.fields[`create${singularName}`] = {\n type: collection.graphQL.type,\n args: {\n ...(createMutationInputType\n ? { data: { type: collection.graphQL.mutationInputType } }\n : {}),\n draft: { type: GraphQLBoolean },\n ...(config.localization\n ? {\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n },\n resolve: createResolver(collection),\n }\n\n graphqlResult.Mutation.fields[`update${singularName}`] = {\n type: collection.graphQL.type,\n args: {\n id: { type: new GraphQLNonNull(idType) },\n autosave: { type: GraphQLBoolean },\n ...(updateMutationInputType\n ? { data: { type: collection.graphQL.updateMutationInputType } }\n : {}),\n draft: { type: GraphQLBoolean },\n ...(config.localization\n ? {\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n trash: { type: GraphQLBoolean },\n },\n resolve: updateResolver(collection),\n }\n\n graphqlResult.Mutation.fields[`delete${singularName}`] = {\n type: collection.graphQL.type,\n args: {\n id: { type: new GraphQLNonNull(idType) },\n trash: { type: GraphQLBoolean },\n },\n resolve: getDeleteResolver(collection),\n }\n\n if (collectionConfig.disableDuplicate !== true) {\n graphqlResult.Mutation.fields[`duplicate${singularName}`] = {\n type: collection.graphQL.type,\n args: {\n id: { type: new GraphQLNonNull(idType) },\n ...(createMutationInputType\n ? { data: { type: collection.graphQL.mutationInputType } }\n : {}),\n },\n resolve: duplicateResolver(collection),\n }\n }\n }\n\n if (collectionConfig.versions) {\n const versionIDType = config.db.defaultIDType === 'text' ? GraphQLString : GraphQLInt\n const versionCollectionFields: Field[] = [\n ...buildVersionCollectionFields(config, collectionConfig),\n {\n name: 'id',\n type: config.db.defaultIDType as 'text',\n },\n {\n name: 'createdAt',\n type: 'date',\n label: ({ t }) => t('general:createdAt'),\n },\n {\n name: 'updatedAt',\n type: 'date',\n label: ({ t }) => t('general:updatedAt'),\n },\n ]\n\n collection.graphQL.versionType = buildObjectType({\n name: `${singularName}Version`,\n collectionSlug: collectionConfig.slug,\n config,\n fields: versionCollectionFields,\n forceNullable: forceNullableObjectType,\n graphqlResult,\n parentName: `${singularName}Version`,\n })\n\n if (queriesEnabled) {\n graphqlResult.Query.fields[`version${formatName(singularName)}`] = {\n type: collection.graphQL.versionType,\n args: {\n id: { type: versionIDType },\n ...(config.localization\n ? {\n fallbackLocale: { type: graphqlResult.types.fallbackLocaleInputType },\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n trash: { type: GraphQLBoolean },\n },\n resolve: findVersionByIDResolver(collection),\n }\n graphqlResult.Query.fields[`versions${pluralName}`] = {\n type: buildPaginatedListType(\n `versions${formatName(pluralName)}`,\n collection.graphQL.versionType,\n ),\n args: {\n where: {\n type: buildWhereInputType({\n name: `versions${singularName}`,\n fields: versionCollectionFields,\n parentName: `versions${singularName}`,\n }),\n },\n ...(config.localization\n ? {\n fallbackLocale: { type: graphqlResult.types.fallbackLocaleInputType },\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n limit: { type: GraphQLInt },\n page: { type: GraphQLInt },\n pagination: { type: GraphQLBoolean },\n select: { type: GraphQLBoolean },\n sort: { type: GraphQLString },\n trash: { type: GraphQLBoolean },\n },\n resolve: findVersionsResolver(collection),\n }\n }\n\n if (mutationsEnabled) {\n graphqlResult.Mutation.fields[`restoreVersion${formatName(singularName)}`] = {\n type: collection.graphQL.type,\n args: {\n id: { type: versionIDType },\n draft: { type: GraphQLBoolean },\n },\n resolve: restoreVersionResolver(collection),\n }\n }\n }\n\n if (collectionConfig.auth) {\n const authFields: Field[] =\n collectionConfig.auth.disableLocalStrategy ||\n (collectionConfig.auth.loginWithUsername &&\n !collectionConfig.auth.loginWithUsername.allowEmailLogin &&\n !collectionConfig.auth.loginWithUsername.requireEmail)\n ? []\n : [\n {\n name: 'email',\n type: 'email',\n required: true,\n },\n ]\n collection.graphQL.JWT = buildObjectType({\n name: formatName(`${slug}JWT`),\n config,\n fields: [\n ...collectionConfig.fields.filter((field) => fieldAffectsData(field) && field.saveToJWT),\n ...authFields,\n {\n name: 'collection',\n type: 'text',\n required: true,\n },\n ],\n graphqlResult,\n parentName: formatName(`${slug}JWT`),\n })\n\n if (queriesEnabled) {\n graphqlResult.Query.fields[`me${singularName}`] = {\n type: new GraphQLObjectType({\n name: formatName(`${slug}Me`),\n fields: {\n collection: {\n type: GraphQLString,\n },\n exp: {\n type: GraphQLInt,\n },\n strategy: {\n type: GraphQLString,\n },\n token: {\n type: GraphQLString,\n },\n user: {\n type: collection.graphQL.type,\n },\n },\n }),\n resolve: me(collection),\n }\n\n graphqlResult.Query.fields[`initialized${singularName}`] = {\n type: GraphQLBoolean,\n resolve: init(collection.config.slug),\n }\n }\n\n if (mutationsEnabled) {\n graphqlResult.Mutation.fields[`refreshToken${singularName}`] = {\n type: new GraphQLObjectType({\n name: formatName(`${slug}Refreshed${singularName}`),\n fields: {\n exp: {\n type: GraphQLInt,\n },\n refreshedToken: {\n type: GraphQLString,\n },\n strategy: {\n type: GraphQLString,\n },\n user: {\n type: collection.graphQL.JWT,\n },\n },\n }),\n resolve: refresh(collection),\n }\n\n graphqlResult.Mutation.fields[`logout${singularName}`] = {\n type: GraphQLString,\n 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","restoreVersionResolver","updateResolver","formatName","buildMutationInputType","getCollectionIDType","buildObjectType","buildPaginatedListType","buildPolicyType","buildWhereInputType","initCollections","config","graphqlResult","Object","keys","collections","forEach","slug","collection","collectionConfig","fields","graphQL","versions","singularName","pluralName","fromSlug","singular","plural","hasIDField","findIndex","field","name","idType","db","defaultIDType","baseFields","whereInputFields","id","type","push","forceNullableObjectType","Boolean","drafts","collectionSlug","forceNullable","parentName","paginatedType","whereInputType","mutationInputFields","auth","disableLocalStrategy","optionalPassword","label","required","mutationCreateInputFields","allowIDOnCreate","flattenedFields","some","createMutationInputType","parentIsLocalized","mutationInputType","updateMutationInputType","filter","queriesEnabled","disableQueries","mutationsEnabled","disableMutations","Query","args","draft","localization","fallbackLocale","types","fallbackLocaleInputType","locale","localeInputType","select","trash","resolve","where","limit","page","pagination","sort","totalDocs","entity","scope","typeSuffix","Mutation","data","autosave","disableDuplicate","versionIDType","versionCollectionFields","t","versionType","authFields","loginWithUsername","allowEmailLogin","requireEmail","JWT","saveToJWT","exp","strategy","token","user","refreshedToken","allSessions","authArgs","canLoginWithEmail","canLoginWithUsername","maxLoginAttempts","password"],"mappings":"AAQA,SACEA,cAAc,EACdC,UAAU,EACVC,cAA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AN,cAAc4E,QAAQ,CAACpE,MAAM,CAAC,CAAC,aAAa,EAAEG,cAAc,CAAC,GAAG;wBAC9De,MAAM,IAAI/D,kBAAkB;4BAC1BwD,MAAM5B,WAAW,GAAGc,KAAK,aAAa,CAAC;4BACvCG,QAAQ;gCACNoF,OAAO;oCAAElE,MAAM9D;gCAAc;gCAC7BiI,MAAM;oCAAEnE,MAAMpB,WAAWG,OAAO,CAACiB,IAAI;gCAAC;4BACxC;wBACF;wBACA8B,MAAM;4BACJ4C,UAAU;gCAAE1E,MAAM9D;4BAAc;4BAChCgI,OAAO;gCAAElE,MAAM9D;4BAAc;wBAC/B;wBACAsG,SAASzF,cAAc6B;oBACzB;oBAEAN,cAAc4E,QAAQ,CAACpE,MAAM,CAAC,CAAC,WAAW,EAAEG,cAAc,CAAC,GAAG;wBAC5De,MAAMlE;wBACNgG,MAAM;4BACJoC,OAAO;gCAAElE,MAAM9D;4BAAc;wBAC/B;wBACAsG,SAASvF,YAAY2B;oBACvB;gBACF;YACF;QACF;IACF;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../src/schema/initCollections.ts"],"sourcesContent":["import type {\n Collection,\n Field,\n GraphQLInfo,\n SanitizedCollectionConfig,\n SanitizedConfig,\n} from 'payload'\n\nimport {\n GraphQLBoolean,\n GraphQLInt,\n GraphQLNonNull,\n GraphQLObjectType,\n GraphQLString,\n} from 'graphql'\nimport { buildVersionCollectionFields, flattenTopLevelFields, formatNames, toWords } from 'payload'\nimport { fieldAffectsData, getLoginOptions } from 'payload/shared'\n\nimport type { ObjectTypeConfig } from './buildObjectType.js'\n\nimport { forgotPassword } from '../resolvers/auth/forgotPassword.js'\nimport { init } from '../resolvers/auth/init.js'\nimport { login } from '../resolvers/auth/login.js'\nimport { logout } from '../resolvers/auth/logout.js'\nimport { me } from '../resolvers/auth/me.js'\nimport { refresh } from '../resolvers/auth/refresh.js'\nimport { resetPassword } from '../resolvers/auth/resetPassword.js'\nimport { unlock } from '../resolvers/auth/unlock.js'\nimport { verifyEmail } from '../resolvers/auth/verifyEmail.js'\nimport { countResolver } from '../resolvers/collections/count.js'\nimport { createResolver } from '../resolvers/collections/create.js'\nimport { getDeleteResolver } from '../resolvers/collections/delete.js'\nimport { docAccessResolver } from '../resolvers/collections/docAccess.js'\nimport { duplicateResolver } from '../resolvers/collections/duplicate.js'\nimport { findResolver } from '../resolvers/collections/find.js'\nimport { findByIDResolver } from '../resolvers/collections/findByID.js'\nimport { findVersionByIDResolver } from '../resolvers/collections/findVersionByID.js'\nimport { findVersionsResolver } from '../resolvers/collections/findVersions.js'\nimport { 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,uBAAuB,QAAQ,8CAA6C;AACrF,SAASC,oBAAoB,QAAQ,2CAA0C;AAC/E,SAASC,kBAAkB,QAAQ,yCAAwC;AAC3E,SAASC,sBAAsB,QAAQ,6CAA4C;AACnF,SAASC,cAAc,QAAQ,qCAAoC;AACnE,SAASC,gBAAgB,QAAQ,uCAAsC;AACvE,SAASC,UAAU,QAAQ,6BAA4B;AACvD,SAASC,sBAAsB,EAAEC,mBAAmB,QAAQ,8BAA6B;AACzF,SAASC,eAAe,QAAQ,uBAAsB;AACtD,SAASC,sBA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1
|
-
{"version":3,"file":"initGlobals.d.ts","sourceRoot":"","sources":["../../src/schema/initGlobals.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAS,WAAW,EAAE,eAAe,EAAyB,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"initGlobals.d.ts","sourceRoot":"","sources":["../../src/schema/initGlobals.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAS,WAAW,EAAE,eAAe,EAAyB,MAAM,SAAS,CAAA;AAmBzF,KAAK,sBAAsB,GAAG;IAC5B,MAAM,EAAE,eAAe,CAAA;IACvB,aAAa,EAAE,WAAW,CAAA;CAC3B,CAAA;AACD,wBAAgB,WAAW,CAAC,EAAE,MAAM,EAAE,aAAa,EAAE,EAAE,sBAAsB,GAAG,IAAI,CA6MnF"}
|
|
@@ -9,6 +9,7 @@ import { findVersionByID } from '../resolvers/globals/findVersionByID.js';
|
|
|
9
9
|
import { findVersions } from '../resolvers/globals/findVersions.js';
|
|
10
10
|
import { restoreVersion } from '../resolvers/globals/restoreVersion.js';
|
|
11
11
|
import { update } from '../resolvers/globals/update.js';
|
|
12
|
+
import { validateResolver as validateGlobalResolver } from '../resolvers/globals/validate.js';
|
|
12
13
|
import { formatName } from '../utilities/formatName.js';
|
|
13
14
|
import { buildMutationInputType } from './buildMutationInputType.js';
|
|
14
15
|
import { buildObjectType } from './buildObjectType.js';
|
|
@@ -35,6 +36,15 @@ export function initGlobals({ config, graphqlResult }) {
|
|
|
35
36
|
parentIsLocalized: false,
|
|
36
37
|
parentName: formattedName
|
|
37
38
|
});
|
|
39
|
+
const validationMutationInputType = buildMutationInputType({
|
|
40
|
+
name: `${formattedName}Validation`,
|
|
41
|
+
config,
|
|
42
|
+
fields,
|
|
43
|
+
forceNullable: true,
|
|
44
|
+
graphqlResult,
|
|
45
|
+
parentIsLocalized: false,
|
|
46
|
+
parentName: `${formattedName}Validation`
|
|
47
|
+
});
|
|
38
48
|
graphqlResult.globals.graphQL[slug] = {
|
|
39
49
|
type: buildObjectType({
|
|
40
50
|
name: formattedName,
|
|
@@ -52,6 +62,9 @@ export function initGlobals({ config, graphqlResult }) {
|
|
|
52
62
|
graphqlResult.Query.fields[formattedName] = {
|
|
53
63
|
type: graphqlResult.globals.graphQL[slug].type,
|
|
54
64
|
args: {
|
|
65
|
+
branch: {
|
|
66
|
+
type: GraphQLString
|
|
67
|
+
},
|
|
55
68
|
draft: {
|
|
56
69
|
type: GraphQLBoolean
|
|
57
70
|
},
|
|
@@ -76,6 +89,11 @@ export function initGlobals({ config, graphqlResult }) {
|
|
|
76
89
|
scope: 'docAccess',
|
|
77
90
|
typeSuffix: 'DocAccess'
|
|
78
91
|
}),
|
|
92
|
+
args: {
|
|
93
|
+
branch: {
|
|
94
|
+
type: GraphQLString
|
|
95
|
+
}
|
|
96
|
+
},
|
|
79
97
|
resolve: docAccessResolver(global)
|
|
80
98
|
};
|
|
81
99
|
}
|
|
@@ -88,6 +106,9 @@ export function initGlobals({ config, graphqlResult }) {
|
|
|
88
106
|
type: graphqlResult.globals.graphQL[slug].mutationInputType
|
|
89
107
|
}
|
|
90
108
|
} : {},
|
|
109
|
+
branch: {
|
|
110
|
+
type: GraphQLString
|
|
111
|
+
},
|
|
91
112
|
draft: {
|
|
92
113
|
type: GraphQLBoolean
|
|
93
114
|
},
|
|
@@ -99,6 +120,25 @@ export function initGlobals({ config, graphqlResult }) {
|
|
|
99
120
|
},
|
|
100
121
|
resolve: update(global)
|
|
101
122
|
};
|
|
123
|
+
graphqlResult.Mutation.fields[`validate${formattedName}`] = {
|
|
124
|
+
type: graphqlResult.types.validationResultType,
|
|
125
|
+
args: {
|
|
126
|
+
...validationMutationInputType ? {
|
|
127
|
+
data: {
|
|
128
|
+
type: validationMutationInputType
|
|
129
|
+
}
|
|
130
|
+
} : {},
|
|
131
|
+
draft: {
|
|
132
|
+
type: GraphQLBoolean
|
|
133
|
+
},
|
|
134
|
+
...config.localization ? {
|
|
135
|
+
locale: {
|
|
136
|
+
type: graphqlResult.types.localeInputType
|
|
137
|
+
}
|
|
138
|
+
} : {}
|
|
139
|
+
},
|
|
140
|
+
resolve: validateGlobalResolver(global)
|
|
141
|
+
};
|
|
102
142
|
}
|
|
103
143
|
if (global.versions) {
|
|
104
144
|
const idType = config.db.defaultIDType === 'number' ? GraphQLInt : GraphQLString;
|
|
@@ -134,6 +174,9 @@ export function initGlobals({ config, graphqlResult }) {
|
|
|
134
174
|
id: {
|
|
135
175
|
type: idType
|
|
136
176
|
},
|
|
177
|
+
branch: {
|
|
178
|
+
type: GraphQLString
|
|
179
|
+
},
|
|
137
180
|
draft: {
|
|
138
181
|
type: GraphQLBoolean
|
|
139
182
|
},
|
|
@@ -154,6 +197,9 @@ export function initGlobals({ config, graphqlResult }) {
|
|
|
154
197
|
graphqlResult.Query.fields[`versions${formattedName}`] = {
|
|
155
198
|
type: buildPaginatedListType(`versions${formatName(formattedName)}`, graphqlResult.globals.graphQL[slug].versionType),
|
|
156
199
|
args: {
|
|
200
|
+
branch: {
|
|
201
|
+
type: GraphQLString
|
|
202
|
+
},
|
|
157
203
|
where: {
|
|
158
204
|
type: buildWhereInputType({
|
|
159
205
|
name: `versions${formattedName}`,
|
|
@@ -195,6 +241,9 @@ export function initGlobals({ config, graphqlResult }) {
|
|
|
195
241
|
id: {
|
|
196
242
|
type: idType
|
|
197
243
|
},
|
|
244
|
+
branch: {
|
|
245
|
+
type: GraphQLString
|
|
246
|
+
},
|
|
198
247
|
draft: {
|
|
199
248
|
type: GraphQLBoolean
|
|
200
249
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/schema/initGlobals.ts"],"sourcesContent":["import { GraphQLBoolean, GraphQLInt, GraphQLNonNull, GraphQLString } from 'graphql'\nimport pluralize from 'pluralize'\nconst { singular } = pluralize\n\nimport type { Field, GraphQLInfo, SanitizedConfig, SanitizedGlobalConfig } from 'payload'\n\nimport { buildVersionGlobalFields, toWords } from 'payload'\nimport { hasDraftsEnabled } from 'payload/shared'\n\nimport { docAccessResolver } from '../resolvers/globals/docAccess.js'\nimport { findOne } from '../resolvers/globals/findOne.js'\nimport { findVersionByID } from '../resolvers/globals/findVersionByID.js'\nimport { findVersions } from '../resolvers/globals/findVersions.js'\nimport { restoreVersion } from '../resolvers/globals/restoreVersion.js'\nimport { update } from '../resolvers/globals/update.js'\nimport { formatName } from '../utilities/formatName.js'\nimport { buildMutationInputType } from './buildMutationInputType.js'\nimport { buildObjectType } from './buildObjectType.js'\nimport { buildPaginatedListType } from './buildPaginatedListType.js'\nimport { buildPolicyType } from './buildPoliciesType.js'\nimport { buildWhereInputType } from './buildWhereInputType.js'\n\ntype InitGlobalsGraphQLArgs = {\n config: SanitizedConfig\n graphqlResult: GraphQLInfo\n}\nexport function initGlobals({ config, graphqlResult }: InitGlobalsGraphQLArgs): void {\n Object.keys(graphqlResult.globals.config).forEach((slug) => {\n const global: SanitizedGlobalConfig = graphqlResult.globals.config[slug]\n const { fields, graphQL } = global\n\n if (graphQL === false) {\n return\n }\n\n const formattedName = graphQL?.name ? graphQL.name : singular(toWords(global.slug, true))\n\n const forceNullableObjectType = hasDraftsEnabled(global)\n\n if (!graphqlResult.globals.graphQL) {\n graphqlResult.globals.graphQL = {}\n }\n\n const updateMutationInputType = buildMutationInputType({\n name: formattedName,\n config,\n fields,\n graphqlResult,\n parentIsLocalized: false,\n parentName: formattedName,\n })\n graphqlResult.globals.graphQL[slug] = {\n type: buildObjectType({\n name: formattedName,\n config,\n fields,\n forceNullable: forceNullableObjectType,\n graphqlResult,\n parentName: formattedName,\n }),\n mutationInputType: updateMutationInputType\n ? new GraphQLNonNull(updateMutationInputType)\n : null,\n }\n\n const queriesEnabled = typeof global.graphQL !== 'object' || !global.graphQL.disableQueries\n const mutationsEnabled = typeof global.graphQL !== 'object' || !global.graphQL.disableMutations\n\n if (queriesEnabled) {\n graphqlResult.Query.fields[formattedName] = {\n type: graphqlResult.globals.graphQL[slug].type,\n args: {\n draft: { type: GraphQLBoolean },\n ...(config.localization\n ? {\n fallbackLocale: { type: graphqlResult.types.fallbackLocaleInputType },\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n select: { type: GraphQLBoolean },\n },\n resolve: findOne(global),\n }\n\n graphqlResult.Query.fields[`docAccess${formattedName}`] = {\n type: buildPolicyType({\n type: 'global',\n entity: global,\n scope: 'docAccess',\n typeSuffix: 'DocAccess',\n }),\n resolve: docAccessResolver(global),\n }\n }\n\n if (mutationsEnabled) {\n graphqlResult.Mutation.fields[`update${formattedName}`] = {\n type: graphqlResult.globals.graphQL[slug].type,\n args: {\n ...(updateMutationInputType\n ? { data: { type: graphqlResult.globals.graphQL[slug].mutationInputType } }\n : {}),\n draft: { type: GraphQLBoolean },\n ...(config.localization\n ? {\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n },\n resolve: update(global),\n }\n }\n\n if (global.versions) {\n const idType = config.db.defaultIDType === 'number' ? GraphQLInt : GraphQLString\n\n const versionGlobalFields: Field[] = [\n ...buildVersionGlobalFields(config, global),\n {\n name: 'id',\n type: config.db.defaultIDType as 'text',\n },\n {\n name: 'createdAt',\n type: 'date',\n label: 'Created At',\n },\n {\n name: 'updatedAt',\n type: 'date',\n label: 'Updated At',\n },\n ]\n\n graphqlResult.globals.graphQL[slug].versionType = buildObjectType({\n name: `${formattedName}Version`,\n config,\n fields: versionGlobalFields,\n forceNullable: forceNullableObjectType,\n graphqlResult,\n parentName: `${formattedName}Version`,\n })\n\n if (queriesEnabled) {\n graphqlResult.Query.fields[`version${formatName(formattedName)}`] = {\n type: graphqlResult.globals.graphQL[slug].versionType,\n args: {\n id: { type: idType },\n draft: { type: GraphQLBoolean },\n ...(config.localization\n ? {\n fallbackLocale: { type: graphqlResult.types.fallbackLocaleInputType },\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n select: { type: GraphQLBoolean },\n },\n resolve: findVersionByID(global),\n }\n graphqlResult.Query.fields[`versions${formattedName}`] = {\n type: buildPaginatedListType(\n `versions${formatName(formattedName)}`,\n graphqlResult.globals.graphQL[slug].versionType,\n ),\n args: {\n where: {\n type: buildWhereInputType({\n name: `versions${formattedName}`,\n fields: versionGlobalFields,\n parentName: `versions${formattedName}`,\n }),\n },\n ...(config.localization\n ? {\n fallbackLocale: { type: graphqlResult.types.fallbackLocaleInputType },\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n limit: { type: GraphQLInt },\n page: { type: GraphQLInt },\n pagination: { type: GraphQLBoolean },\n select: { type: GraphQLBoolean },\n sort: { type: GraphQLString },\n },\n resolve: findVersions(global),\n }\n }\n\n if (mutationsEnabled) {\n graphqlResult.Mutation.fields[`restoreVersion${formatName(formattedName)}`] = {\n type: graphqlResult.globals.graphQL[slug].type,\n args: {\n id: { type: idType },\n draft: { type: GraphQLBoolean },\n },\n resolve: restoreVersion(global),\n }\n }\n }\n })\n}\n"],"names":["GraphQLBoolean","GraphQLInt","GraphQLNonNull","GraphQLString","pluralize","singular","buildVersionGlobalFields","toWords","hasDraftsEnabled","docAccessResolver","findOne","findVersionByID","findVersions","restoreVersion","update","formatName","buildMutationInputType","buildObjectType","buildPaginatedListType","buildPolicyType","buildWhereInputType","initGlobals","config","graphqlResult","Object","keys","globals","forEach","slug","global","fields","graphQL","formattedName","name","forceNullableObjectType","updateMutationInputType","parentIsLocalized","parentName","type","forceNullable","mutationInputType","queriesEnabled","disableQueries","mutationsEnabled","disableMutations","Query","args","draft","localization","fallbackLocale","types","fallbackLocaleInputType","locale","localeInputType","select","resolve","entity","scope","typeSuffix","Mutation","data","versions","idType","db","defaultIDType","versionGlobalFields","label","versionType","id","where","limit","page","pagination","sort"],"mappings":"AAAA,SAASA,cAAc,EAAEC,UAAU,EAAEC,cAAc,EAAEC,aAAa,QAAQ,UAAS;AACnF,OAAOC,eAAe,YAAW;AACjC,MAAM,EAAEC,QAAQ,EAAE,GAAGD;AAIrB,SAASE,wBAAwB,EAAEC,OAAO,QAAQ,UAAS;AAC3D,SAASC,gBAAgB,QAAQ,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Int, GraphQLNonNull, GraphQLString } from 'graphql'\nimport pluralize from 'pluralize'\nconst { singular } = pluralize\n\nimport type { Field, GraphQLInfo, SanitizedConfig, SanitizedGlobalConfig } from 'payload'\n\nimport { buildVersionGlobalFields, toWords } from 'payload'\nimport { hasDraftsEnabled } from 'payload/shared'\n\nimport { docAccessResolver } from '../resolvers/globals/docAccess.js'\nimport { findOne } from '../resolvers/globals/findOne.js'\nimport { findVersionByID } from '../resolvers/globals/findVersionByID.js'\nimport { findVersions } from '../resolvers/globals/findVersions.js'\nimport { restoreVersion } from '../resolvers/globals/restoreVersion.js'\nimport { update } from '../resolvers/globals/update.js'\nimport { validateResolver as validateGlobalResolver } from '../resolvers/globals/validate.js'\nimport { formatName } from '../utilities/formatName.js'\nimport { buildMutationInputType } from './buildMutationInputType.js'\nimport { buildObjectType } from './buildObjectType.js'\nimport { buildPaginatedListType } from './buildPaginatedListType.js'\nimport { buildPolicyType } from './buildPoliciesType.js'\nimport { buildWhereInputType } from './buildWhereInputType.js'\n\ntype InitGlobalsGraphQLArgs = {\n config: SanitizedConfig\n graphqlResult: GraphQLInfo\n}\nexport function initGlobals({ config, graphqlResult }: InitGlobalsGraphQLArgs): void {\n Object.keys(graphqlResult.globals.config).forEach((slug) => {\n const global: SanitizedGlobalConfig = graphqlResult.globals.config[slug]\n const { fields, graphQL } = global\n\n if (graphQL === false) {\n return\n }\n\n const formattedName = graphQL?.name ? graphQL.name : singular(toWords(global.slug, true))\n\n const forceNullableObjectType = hasDraftsEnabled(global)\n\n if (!graphqlResult.globals.graphQL) {\n graphqlResult.globals.graphQL = {}\n }\n\n const updateMutationInputType = buildMutationInputType({\n name: formattedName,\n config,\n fields,\n graphqlResult,\n parentIsLocalized: false,\n parentName: formattedName,\n })\n const validationMutationInputType = buildMutationInputType({\n name: `${formattedName}Validation`,\n config,\n fields,\n forceNullable: true,\n graphqlResult,\n parentIsLocalized: false,\n parentName: `${formattedName}Validation`,\n })\n graphqlResult.globals.graphQL[slug] = {\n type: buildObjectType({\n name: formattedName,\n config,\n fields,\n forceNullable: forceNullableObjectType,\n graphqlResult,\n parentName: formattedName,\n }),\n mutationInputType: updateMutationInputType\n ? new GraphQLNonNull(updateMutationInputType)\n : null,\n }\n\n const queriesEnabled = typeof global.graphQL !== 'object' || !global.graphQL.disableQueries\n const mutationsEnabled = typeof global.graphQL !== 'object' || !global.graphQL.disableMutations\n\n if (queriesEnabled) {\n graphqlResult.Query.fields[formattedName] = {\n type: graphqlResult.globals.graphQL[slug].type,\n args: {\n branch: { type: GraphQLString },\n draft: { type: GraphQLBoolean },\n ...(config.localization\n ? {\n fallbackLocale: { type: graphqlResult.types.fallbackLocaleInputType },\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n select: { type: GraphQLBoolean },\n },\n resolve: findOne(global),\n }\n\n graphqlResult.Query.fields[`docAccess${formattedName}`] = {\n type: buildPolicyType({\n type: 'global',\n entity: global,\n scope: 'docAccess',\n typeSuffix: 'DocAccess',\n }),\n args: {\n branch: { type: GraphQLString },\n },\n resolve: docAccessResolver(global),\n }\n }\n\n if (mutationsEnabled) {\n graphqlResult.Mutation.fields[`update${formattedName}`] = {\n type: graphqlResult.globals.graphQL[slug].type,\n args: {\n ...(updateMutationInputType\n ? { data: { type: graphqlResult.globals.graphQL[slug].mutationInputType } }\n : {}),\n branch: { type: GraphQLString },\n draft: { type: GraphQLBoolean },\n ...(config.localization\n ? {\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n },\n resolve: update(global),\n }\n\n graphqlResult.Mutation.fields[`validate${formattedName}`] = {\n type: graphqlResult.types.validationResultType,\n args: {\n ...(validationMutationInputType ? { data: { type: validationMutationInputType } } : {}),\n draft: { type: GraphQLBoolean },\n ...(config.localization\n ? {\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n },\n resolve: validateGlobalResolver(global),\n }\n }\n\n if (global.versions) {\n const idType = config.db.defaultIDType === 'number' ? GraphQLInt : GraphQLString\n\n const versionGlobalFields: Field[] = [\n ...buildVersionGlobalFields(config, global),\n {\n name: 'id',\n type: config.db.defaultIDType as 'text',\n },\n {\n name: 'createdAt',\n type: 'date',\n label: 'Created At',\n },\n {\n name: 'updatedAt',\n type: 'date',\n label: 'Updated At',\n },\n ]\n\n graphqlResult.globals.graphQL[slug].versionType = buildObjectType({\n name: `${formattedName}Version`,\n config,\n fields: versionGlobalFields,\n forceNullable: forceNullableObjectType,\n graphqlResult,\n parentName: `${formattedName}Version`,\n })\n\n if (queriesEnabled) {\n graphqlResult.Query.fields[`version${formatName(formattedName)}`] = {\n type: graphqlResult.globals.graphQL[slug].versionType,\n args: {\n id: { type: idType },\n branch: { type: GraphQLString },\n draft: { type: GraphQLBoolean },\n ...(config.localization\n ? {\n fallbackLocale: { type: graphqlResult.types.fallbackLocaleInputType },\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n select: { type: GraphQLBoolean },\n },\n resolve: findVersionByID(global),\n }\n graphqlResult.Query.fields[`versions${formattedName}`] = {\n type: buildPaginatedListType(\n `versions${formatName(formattedName)}`,\n graphqlResult.globals.graphQL[slug].versionType,\n ),\n args: {\n branch: { type: GraphQLString },\n where: {\n type: buildWhereInputType({\n name: `versions${formattedName}`,\n fields: versionGlobalFields,\n parentName: `versions${formattedName}`,\n }),\n },\n ...(config.localization\n ? {\n fallbackLocale: { type: graphqlResult.types.fallbackLocaleInputType },\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n limit: { type: GraphQLInt },\n page: { type: GraphQLInt },\n pagination: { type: GraphQLBoolean },\n select: { type: GraphQLBoolean },\n sort: { type: GraphQLString },\n },\n resolve: findVersions(global),\n }\n }\n\n if (mutationsEnabled) {\n graphqlResult.Mutation.fields[`restoreVersion${formatName(formattedName)}`] = {\n type: graphqlResult.globals.graphQL[slug].type,\n args: {\n id: { type: idType },\n branch: { type: GraphQLString },\n draft: { type: GraphQLBoolean },\n },\n resolve: restoreVersion(global),\n }\n }\n }\n })\n}\n"],"names":["GraphQLBoolean","GraphQLInt","GraphQLNonNull","GraphQLString","pluralize","singular","buildVersionGlobalFields","toWords","hasDraftsEnabled","docAccessResolver","findOne","findVersionByID","findVersions","restoreVersion","update","validateResolver","validateGlobalResolver","formatName","buildMutationInputType","buildObjectType","buildPaginatedListType","buildPolicyType","buildWhereInputType","initGlobals","config","graphqlResult","Object","keys","globals","forEach","slug","global","fields","graphQL","formattedName","name","forceNullableObjectType","updateMutationInputType","parentIsLocalized","parentName","validationMutationInputType","forceNullable","type","mutationInputType","queriesEnabled","disableQueries","mutationsEnabled","disableMutations","Query","args","branch","draft","localization","fallbackLocale","types","fallbackLocaleInputType","locale","localeInputType","select","resolve","entity","scope","typeSuffix","Mutation","data","validationResultType","versions","idType","db","defaultIDType","versionGlobalFields","label","versionType","id","where","limit","page","pagination","sort"],"mappings":"AAAA,SAASA,cAAc,EAAEC,UAAU,EAAEC,cAAc,EAAEC,aAAa,QAAQ,UAAS;AACnF,OAAOC,eAAe,YAAW;AACjC,MAAM,EAAEC,QAAQ,EAAE,GAAGD;AAIrB,SAASE,wBAAwB,EAAEC,OAAO,QAAQ,UAAS;AAC3D,SAASC,gBAAgB,QAAQ,iBAAgB;AAEjD,SAASC,iBAAiB,QAAQ,oCAAmC;AACrE,SAASC,OAAO,QAAQ,kCAAiC;AACzD,SAASC,eAAe,QAAQ,0CAAyC;AACzE,SAASC,YAAY,QAAQ,uCAAsC;AACnE,SAASC,cAAc,QAAQ,yCAAwC;AACvE,SAASC,MAAM,QAAQ,iCAAgC;AACvD,SAASC,oBAAoBC,sBAAsB,QAAQ,mCAAkC;AAC7F,SAASC,UAAU,QAAQ,6BAA4B;AACvD,SAASC,sBAAsB,QAAQ,8BAA6B;AACpE,SAASC,eAAe,QAAQ,uBAAsB;AACtD,SAASC,sBAAsB,QAAQ,8BAA6B;AACpE,SAASC,eAAe,QAAQ,yBAAwB;AACxD,SAASC,mBAAmB,QAAQ,2BAA0B;AAM9D,OAAO,SAASC,YAAY,EAAEC,MAAM,EA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sC,QAAQ,CAAC/B,MAAM,CAAC,CAAC,cAAc,EAAEf,WAAWiB,gBAAgB,CAAC,GAAG;oBAC5EQ,MAAMjB,cAAcG,OAAO,CAACK,OAAO,CAACH,KAAK,CAACY,IAAI;oBAC9CO,MAAM;wBACJwB,IAAI;4BAAE/B,MAAMyB;wBAAO;wBACnBjB,QAAQ;4BAAER,MAAMvC;wBAAc;wBAC9BgD,OAAO;4BAAET,MAAM1C;wBAAe;oBAChC;oBACA2D,SAAS9C,eAAekB;gBAC1B;YACF;QACF;IACF;AACF"}
|
|
@@ -11,6 +11,12 @@ import { GraphQLInputObjectType } from 'graphql';
|
|
|
11
11
|
* @param field the field for which their valid operators inside a "where" argument is being defined
|
|
12
12
|
* @param parentName the name of the parent field (if any)
|
|
13
13
|
* @returns all the operators (including their types) which can be used as a condition for a given field inside a where
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* A has-many relationship accepts a nested query with its relationship operators:
|
|
17
|
+
* ```graphql
|
|
18
|
+
* Burgers(where: { ingredients: { not_equals: { isHealthy: { equals: false } } } })
|
|
19
|
+
* ```
|
|
14
20
|
*/
|
|
15
21
|
export declare const withOperators: (field: FieldAffectingData, parentName: string) => GraphQLInputObjectType;
|
|
16
22
|
//# sourceMappingURL=withOperators.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withOperators.d.ts","sourceRoot":"","sources":["../../src/schema/withOperators.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAwC,MAAM,SAAS,CAAA;AAEvF,OAAO,EAIL,sBAAsB,EAIvB,MAAM,SAAS,CAAA;AA8OhB
|
|
1
|
+
{"version":3,"file":"withOperators.d.ts","sourceRoot":"","sources":["../../src/schema/withOperators.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAwC,MAAM,SAAS,CAAA;AAEvF,OAAO,EAIL,sBAAsB,EAIvB,MAAM,SAAS,CAAA;AA8OhB;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,aAAa,UACjB,kBAAkB,cACb,MAAM,KACjB,sBA4DF,CAAA"}
|
|
@@ -249,6 +249,12 @@ const gqlTypeCache = {};
|
|
|
249
249
|
* @param field the field for which their valid operators inside a "where" argument is being defined
|
|
250
250
|
* @param parentName the name of the parent field (if any)
|
|
251
251
|
* @returns all the operators (including their types) which can be used as a condition for a given field inside a where
|
|
252
|
+
*
|
|
253
|
+
* @example
|
|
254
|
+
* A has-many relationship accepts a nested query with its relationship operators:
|
|
255
|
+
* ```graphql
|
|
256
|
+
* Burgers(where: { ingredients: { not_equals: { isHealthy: { equals: false } } } })
|
|
257
|
+
* ```
|
|
252
258
|
*/ export const withOperators = (field, parentName)=>{
|
|
253
259
|
if (!defaults?.[field.type]) {
|
|
254
260
|
throw new Error(`Error: ${field.type} has no defaults configured.`);
|
|
@@ -258,6 +264,15 @@ const gqlTypeCache = {};
|
|
|
258
264
|
const fieldOperators = [
|
|
259
265
|
...defaults[field.type].operators
|
|
260
266
|
];
|
|
267
|
+
// These operators accept a complete `where` query for the one collection targeted by the
|
|
268
|
+
// relationship. Polymorphic relationships are excluded because they can target multiple schemas.
|
|
269
|
+
if ((field.type === 'relationship' || field.type === 'upload') && field.hasMany && typeof field.relationTo === 'string') {
|
|
270
|
+
// `equals` and `not_equals` already exist for relationship fields.
|
|
271
|
+
fieldOperators.push({
|
|
272
|
+
name: 'contains',
|
|
273
|
+
type: GraphQLJSON
|
|
274
|
+
});
|
|
275
|
+
}
|
|
261
276
|
if (!('required' in field) || !field.required) {
|
|
262
277
|
fieldOperators.push({
|
|
263
278
|
name: 'exists',
|