@payloadcms/graphql 4.0.0-internal.d21c039 → 4.0.0-internal.d3909a9
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/find.d.ts.map +1 -1
- package/dist/resolvers/collections/find.js +1 -1
- package/dist/resolvers/collections/find.js.map +1 -1
- package/dist/resolvers/collections/findByID.d.ts.map +1 -1
- package/dist/resolvers/collections/findByID.js +1 -1
- package/dist/resolvers/collections/findByID.js.map +1 -1
- package/dist/resolvers/collections/findVersionByID.d.ts.map +1 -1
- package/dist/resolvers/collections/findVersionByID.js +1 -1
- package/dist/resolvers/collections/findVersionByID.js.map +1 -1
- package/dist/resolvers/collections/findVersions.d.ts.map +1 -1
- package/dist/resolvers/collections/findVersions.js +1 -1
- 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/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/globals/findOne.d.ts.map +1 -1
- package/dist/resolvers/globals/findOne.js +1 -1
- package/dist/resolvers/globals/findOne.js.map +1 -1
- package/dist/resolvers/globals/findVersionByID.d.ts.map +1 -1
- package/dist/resolvers/globals/findVersionByID.js +1 -1
- package/dist/resolvers/globals/findVersionByID.js.map +1 -1
- package/dist/resolvers/globals/findVersions.d.ts.map +1 -1
- package/dist/resolvers/globals/findVersions.js +1 -1
- package/dist/resolvers/globals/findVersions.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 +5 -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/buildWhereInputType.js.map +1 -1
- package/dist/schema/fieldToSchemaMap.js +3 -3
- package/dist/schema/fieldToSchemaMap.js.map +1 -1
- package/dist/schema/initCollections.d.ts.map +1 -1
- package/dist/schema/initCollections.js +50 -0
- package/dist/schema/initCollections.js.map +1 -1
- package/dist/schema/initGlobals.d.ts.map +1 -1
- package/dist/schema/initGlobals.js +29 -0
- package/dist/schema/initGlobals.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 +19 -22
|
@@ -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,
|
|
@@ -99,6 +109,25 @@ export function initGlobals({ config, graphqlResult }) {
|
|
|
99
109
|
},
|
|
100
110
|
resolve: update(global)
|
|
101
111
|
};
|
|
112
|
+
graphqlResult.Mutation.fields[`validate${formattedName}`] = {
|
|
113
|
+
type: graphqlResult.types.validationResultType,
|
|
114
|
+
args: {
|
|
115
|
+
...validationMutationInputType ? {
|
|
116
|
+
data: {
|
|
117
|
+
type: validationMutationInputType
|
|
118
|
+
}
|
|
119
|
+
} : {},
|
|
120
|
+
draft: {
|
|
121
|
+
type: GraphQLBoolean
|
|
122
|
+
},
|
|
123
|
+
...config.localization ? {
|
|
124
|
+
locale: {
|
|
125
|
+
type: graphqlResult.types.localeInputType
|
|
126
|
+
}
|
|
127
|
+
} : {}
|
|
128
|
+
},
|
|
129
|
+
resolve: validateGlobalResolver(global)
|
|
130
|
+
};
|
|
102
131
|
}
|
|
103
132
|
if (global.versions) {
|
|
104
133
|
const idType = config.db.defaultIDType === 'number' ? GraphQLInt : GraphQLString;
|
|
@@ -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,U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"],"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 { 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 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 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 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","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","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,EAAEC,aAAa,EAA0B;IAC3EC,OAAOC,IAAI,CAACF,cAAcG,OAAO,CAACJ,MAAM,EAAEK,OAAO,CA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8 +1,9 @@
|
|
|
1
1
|
import type { GraphQLResolveInfo } from 'graphql';
|
|
2
2
|
import type { TypedCollectionSelect } from 'payload';
|
|
3
|
-
|
|
4
|
-
export declare function
|
|
5
|
-
export declare function
|
|
3
|
+
import type { Context } from '../resolvers/types.js';
|
|
4
|
+
export declare function buildSelectForCollection(info: GraphQLResolveInfo, context?: Context): SelectType;
|
|
5
|
+
export declare function buildSelectForCollectionMany(info: GraphQLResolveInfo, context?: Context): SelectType;
|
|
6
|
+
export declare function resolveSelect(info: GraphQLResolveInfo, select: SelectType, context?: Context): SelectType;
|
|
6
7
|
type SelectType = TypedCollectionSelect['any'];
|
|
7
8
|
export {};
|
|
8
9
|
//# sourceMappingURL=select.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select.d.ts","sourceRoot":"","sources":["../../src/utilities/select.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAqB,kBAAkB,EAAoB,MAAM,SAAS,CAAA;AACtF,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"select.d.ts","sourceRoot":"","sources":["../../src/utilities/select.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAqB,kBAAkB,EAAoB,MAAM,SAAS,CAAA;AACtF,OAAO,KAAK,EAKV,qBAAqB,EAEtB,MAAM,SAAS,CAAA;AAIhB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAA;AASpD,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,kBAAkB,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,UAAU,CAMhG;AACD,wBAAgB,4BAA4B,CAC1C,IAAI,EAAE,kBAAkB,EACxB,OAAO,CAAC,EAAE,OAAO,GAChB,UAAU,CAMZ;AAED,wBAAgB,aAAa,CAC3B,IAAI,EAAE,kBAAkB,EACxB,MAAM,EAAE,UAAU,EAClB,OAAO,CAAC,EAAE,OAAO,GAChB,UAAU,CA0BZ;AA+JD,KAAK,UAAU,GAAG,qBAAqB,CAAC,KAAK,CAAC,CAAA"}
|
package/dist/utilities/select.js
CHANGED
|
@@ -1,52 +1,47 @@
|
|
|
1
1
|
import { getNamedType, isInterfaceType, isObjectType, isUnionType, Kind } from 'graphql';
|
|
2
|
-
|
|
2
|
+
const selectRootPathsByContext = new WeakMap();
|
|
3
|
+
export function buildSelectForCollection(info, context) {
|
|
4
|
+
if (context) {
|
|
5
|
+
registerSelectRootPath(context, info);
|
|
6
|
+
}
|
|
3
7
|
return buildSelect(info);
|
|
4
8
|
}
|
|
5
|
-
export function buildSelectForCollectionMany(info) {
|
|
6
|
-
|
|
9
|
+
export function buildSelectForCollectionMany(info, context) {
|
|
10
|
+
if (context) {
|
|
11
|
+
registerSelectRootPath(context, info);
|
|
12
|
+
}
|
|
13
|
+
return buildSelect(info)?.docs;
|
|
7
14
|
}
|
|
8
|
-
export function resolveSelect(info, select) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const pathKey = path.key;
|
|
13
|
-
const pathType = info.schema.getType(path.typename);
|
|
14
|
-
if (pathType) {
|
|
15
|
-
const field = pathType?.getFields()?.[pathKey]?.extensions?.field;
|
|
16
|
-
if (field?.type === 'join') {
|
|
17
|
-
path = path.prev;
|
|
18
|
-
traversePath.unshift('docs');
|
|
19
|
-
}
|
|
20
|
-
if (field?.type === 'relationship' && Array.isArray(field.relationTo)) {
|
|
21
|
-
path = path.prev;
|
|
22
|
-
traversePath.unshift('value');
|
|
23
|
-
}
|
|
24
|
-
if (field) {
|
|
25
|
-
traversePath.unshift(field.name);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
if (path.prev) {
|
|
29
|
-
traverseTree(path.prev);
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
traverseTree(info.path);
|
|
33
|
-
traversePath.forEach((key)=>{
|
|
34
|
-
select = select?.[key];
|
|
35
|
-
});
|
|
15
|
+
export function resolveSelect(info, select, context) {
|
|
16
|
+
const isSelectEnabled = context ? hasSelectRootPath(context, info) : typeof select !== 'undefined';
|
|
17
|
+
if (!isSelectEnabled) {
|
|
18
|
+
return undefined;
|
|
36
19
|
}
|
|
37
|
-
|
|
20
|
+
const field = info.parentType.getFields()[info.fieldName]?.extensions?.field;
|
|
21
|
+
const fieldSelect = buildSelect(info);
|
|
22
|
+
if (field?.type === 'join') {
|
|
23
|
+
return fieldSelect?.docs;
|
|
24
|
+
}
|
|
25
|
+
if ((field?.type === 'relationship' || field?.type === 'upload') && Array.isArray(field.relationTo)) {
|
|
26
|
+
return fieldSelect?.value;
|
|
27
|
+
}
|
|
28
|
+
return fieldSelect;
|
|
38
29
|
}
|
|
39
30
|
function buildSelect(info) {
|
|
40
31
|
const returnType = getNamedType(info.returnType);
|
|
41
|
-
const selectionSet = info.fieldNodes[0].selectionSet;
|
|
42
32
|
if (!returnType) {
|
|
43
33
|
return;
|
|
44
34
|
}
|
|
45
|
-
return
|
|
35
|
+
return info.fieldNodes.reduce((fieldTree, fieldNode)=>{
|
|
36
|
+
if (!fieldNode.selectionSet) {
|
|
37
|
+
return fieldTree;
|
|
38
|
+
}
|
|
39
|
+
return mergeSelectTrees(fieldTree, buildSelectTree(info, fieldNode.selectionSet, returnType));
|
|
40
|
+
}, {});
|
|
46
41
|
}
|
|
47
42
|
function buildSelectTree(info, selectionSet, type) {
|
|
48
43
|
const fieldMap = type.getFields?.();
|
|
49
|
-
|
|
44
|
+
let fieldTree = {};
|
|
50
45
|
for (const selection of selectionSet.selections){
|
|
51
46
|
switch(selection.kind){
|
|
52
47
|
case Kind.FIELD:
|
|
@@ -64,11 +59,15 @@ function buildSelectTree(info, selectionSet, type) {
|
|
|
64
59
|
if (selection.selectionSet) {
|
|
65
60
|
const type = getNamedType(fieldSchema.type);
|
|
66
61
|
if (isObjectType(type) || isInterfaceType(type) || isUnionType(type)) {
|
|
67
|
-
fieldTree
|
|
62
|
+
fieldTree = mergeSelectTrees(fieldTree, {
|
|
63
|
+
[fieldNameOriginal]: buildSelectTree(info, selection.selectionSet, type)
|
|
64
|
+
});
|
|
68
65
|
continue;
|
|
69
66
|
}
|
|
70
67
|
}
|
|
71
|
-
fieldTree
|
|
68
|
+
fieldTree = mergeSelectTrees(fieldTree, {
|
|
69
|
+
[fieldNameOriginal]: true
|
|
70
|
+
});
|
|
72
71
|
break;
|
|
73
72
|
}
|
|
74
73
|
case Kind.FRAGMENT_SPREAD:
|
|
@@ -77,7 +76,7 @@ function buildSelectTree(info, selectionSet, type) {
|
|
|
77
76
|
const fragment = info.fragments[fragmentName];
|
|
78
77
|
const fragmentType = fragment && info.schema.getType(fragment.typeCondition.name.value);
|
|
79
78
|
if (fragmentType) {
|
|
80
|
-
|
|
79
|
+
fieldTree = mergeSelectTrees(fieldTree, buildFragmentSelectTree(info, fragment.selectionSet, fragmentType, type));
|
|
81
80
|
}
|
|
82
81
|
break;
|
|
83
82
|
}
|
|
@@ -85,13 +84,7 @@ function buildSelectTree(info, selectionSet, type) {
|
|
|
85
84
|
{
|
|
86
85
|
const fragmentType = selection.typeCondition ? info.schema.getType(selection.typeCondition.name.value) : type;
|
|
87
86
|
if (fragmentType) {
|
|
88
|
-
|
|
89
|
-
const blockSlug = fragmentType.extensions?.blockSlug;
|
|
90
|
-
if (blockSlug && isUnionType(type)) {
|
|
91
|
-
fieldTree[blockSlug] = buildSelectTree(info, selection.selectionSet, fragmentType);
|
|
92
|
-
} else {
|
|
93
|
-
Object.assign(fieldTree, buildSelectTree(info, selection.selectionSet, fragmentType));
|
|
94
|
-
}
|
|
87
|
+
fieldTree = mergeSelectTrees(fieldTree, buildFragmentSelectTree(info, selection.selectionSet, fragmentType, type));
|
|
95
88
|
}
|
|
96
89
|
break;
|
|
97
90
|
}
|
|
@@ -99,5 +92,50 @@ function buildSelectTree(info, selectionSet, type) {
|
|
|
99
92
|
}
|
|
100
93
|
return fieldTree;
|
|
101
94
|
}
|
|
95
|
+
function buildFragmentSelectTree(info, selectionSet, fragmentType, parentType) {
|
|
96
|
+
const fragmentSelectTree = buildSelectTree(info, selectionSet, fragmentType);
|
|
97
|
+
const blockSlug = fragmentType.extensions?.blockSlug;
|
|
98
|
+
if (blockSlug && isUnionType(parentType)) {
|
|
99
|
+
return {
|
|
100
|
+
[blockSlug]: fragmentSelectTree
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
return fragmentSelectTree;
|
|
104
|
+
}
|
|
105
|
+
function getRootPathKey(path) {
|
|
106
|
+
while(path.prev){
|
|
107
|
+
path = path.prev;
|
|
108
|
+
}
|
|
109
|
+
return path.key;
|
|
110
|
+
}
|
|
111
|
+
function hasSelectRootPath(context, info) {
|
|
112
|
+
return Boolean(selectRootPathsByContext.get(context)?.get(info.operation)?.has(getRootPathKey(info.path)));
|
|
113
|
+
}
|
|
114
|
+
function isSelectTree(value) {
|
|
115
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
116
|
+
}
|
|
117
|
+
function mergeSelectTrees(firstTree, secondTree) {
|
|
118
|
+
const mergedTree = {
|
|
119
|
+
...firstTree
|
|
120
|
+
};
|
|
121
|
+
for (const [fieldName, fieldSelect] of Object.entries(secondTree)){
|
|
122
|
+
const existingFieldSelect = mergedTree[fieldName];
|
|
123
|
+
mergedTree[fieldName] = isSelectTree(existingFieldSelect) && isSelectTree(fieldSelect) ? mergeSelectTrees(existingFieldSelect, fieldSelect) : fieldSelect;
|
|
124
|
+
}
|
|
125
|
+
return mergedTree;
|
|
126
|
+
}
|
|
127
|
+
function registerSelectRootPath(context, info) {
|
|
128
|
+
let selectRootPathsByOperation = selectRootPathsByContext.get(context);
|
|
129
|
+
if (!selectRootPathsByOperation) {
|
|
130
|
+
selectRootPathsByOperation = new WeakMap();
|
|
131
|
+
selectRootPathsByContext.set(context, selectRootPathsByOperation);
|
|
132
|
+
}
|
|
133
|
+
let selectRootPaths = selectRootPathsByOperation.get(info.operation);
|
|
134
|
+
if (!selectRootPaths) {
|
|
135
|
+
selectRootPaths = new Set();
|
|
136
|
+
selectRootPathsByOperation.set(info.operation, selectRootPaths);
|
|
137
|
+
}
|
|
138
|
+
selectRootPaths.add(getRootPathKey(info.path));
|
|
139
|
+
}
|
|
102
140
|
|
|
103
141
|
//# sourceMappingURL=select.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/select.ts"],"sourcesContent":["import type { GraphQLObjectType, GraphQLResolveInfo, SelectionSetNode } from 'graphql'\nimport type { FieldBase, JoinField, RelationshipField, TypedCollectionSelect } from 'payload'\n\nimport { getNamedType, isInterfaceType, isObjectType, isUnionType, Kind } from 'graphql'\n\nexport function buildSelectForCollection(info: GraphQLResolveInfo): SelectType {\n return buildSelect(info)\n}\nexport function buildSelectForCollectionMany(info: GraphQLResolveInfo): SelectType {\n return buildSelect(info).docs as SelectType\n}\n\nexport function resolveSelect(info: GraphQLResolveInfo, select: SelectType): SelectType {\n if (select) {\n const traversePath: string[] = []\n const traverseTree = (path: GraphQLResolveInfo['path']) => {\n const pathKey = path.key\n const pathType = info.schema.getType(path.typename) as GraphQLObjectType\n\n if (pathType) {\n const field = pathType?.getFields()?.[pathKey]?.extensions?.field as\n | JoinField\n | RelationshipField\n\n if (field?.type === 'join') {\n path = path.prev\n traversePath.unshift('docs')\n }\n if (field?.type === 'relationship' && Array.isArray(field.relationTo)) {\n path = path.prev\n traversePath.unshift('value')\n }\n if (field) {\n traversePath.unshift(field.name)\n }\n }\n\n if (path.prev) {\n traverseTree(path.prev)\n }\n }\n\n traverseTree(info.path)\n traversePath.forEach((key) => {\n select = select?.[key] as SelectType\n })\n }\n\n return select\n}\n\nfunction buildSelect(info: GraphQLResolveInfo) {\n const returnType = getNamedType(info.returnType) as GraphQLObjectType\n const selectionSet = info.fieldNodes[0].selectionSet\n\n if (!returnType) {\n return\n }\n\n return buildSelectTree(info, selectionSet, returnType)\n}\nfunction buildSelectTree(\n info: GraphQLResolveInfo,\n selectionSet: SelectionSetNode,\n type: GraphQLObjectType,\n): SelectType {\n const fieldMap = type.getFields?.()\n const fieldTree: SelectType = {}\n\n for (const selection of selectionSet.selections) {\n switch (selection.kind) {\n case Kind.FIELD: {\n const fieldName = selection.name.value\n const fieldSchema = fieldMap?.[fieldName]\n\n const field = fieldSchema?.extensions?.field as FieldBase\n const fieldNameOriginal = field?.name || fieldName\n\n if (fieldName === '__typename') {\n continue\n }\n if (fieldSchema == undefined) {\n continue\n }\n\n if (selection.selectionSet) {\n const type = getNamedType(fieldSchema.type) as GraphQLObjectType\n\n if (isObjectType(type) || isInterfaceType(type) || isUnionType(type)) {\n fieldTree[fieldNameOriginal] = buildSelectTree(info, selection.selectionSet, type)\n continue\n }\n }\n\n fieldTree[fieldNameOriginal] = true\n break\n }\n\n case Kind.FRAGMENT_SPREAD: {\n const fragmentName = selection.name.value\n const fragment = info.fragments[fragmentName]\n const fragmentType =\n fragment && (info.schema.getType(fragment.typeCondition.name.value) as GraphQLObjectType)\n\n if (fragmentType) {\n Object.assign(fieldTree, buildSelectTree(info, fragment.selectionSet, fragmentType))\n }\n break\n }\n\n case Kind.INLINE_FRAGMENT: {\n const fragmentType = selection.typeCondition\n ? (info.schema.getType(selection.typeCondition.name.value) as GraphQLObjectType)\n : type\n\n if (fragmentType) {\n // Block types in unions need selections nested under their slug\n const blockSlug = fragmentType.extensions?.blockSlug as string | undefined\n\n if (blockSlug && isUnionType(type)) {\n fieldTree[blockSlug] = buildSelectTree(info, selection.selectionSet, fragmentType)\n } else {\n Object.assign(fieldTree, buildSelectTree(info, selection.selectionSet, fragmentType))\n }\n }\n break\n }\n }\n }\n\n return fieldTree\n}\n\ntype SelectType = TypedCollectionSelect['any']\n"],"names":["getNamedType","isInterfaceType","isObjectType","isUnionType","Kind","buildSelectForCollection","info","buildSelect","buildSelectForCollectionMany","docs","resolveSelect","select","traversePath","traverseTree","path","pathKey","key","pathType","schema","getType","typename","field","getFields","extensions","type","prev","unshift","Array","isArray","relationTo","name","forEach","returnType","selectionSet","fieldNodes","buildSelectTree","fieldMap","fieldTree","selection","selections","kind","FIELD","fieldName","value","fieldSchema","fieldNameOriginal","undefined","FRAGMENT_SPREAD","fragmentName","fragment","fragments","fragmentType","typeCondition","Object","assign","INLINE_FRAGMENT","blockSlug"],"mappings":"AAGA,SAASA,YAAY,EAAEC,eAAe,EAAEC,YAAY,EAAEC,WAAW,EAAEC,IAAI,QAAQ,UAAS;AAExF,OAAO,SAASC,yBAAyBC,IAAwB;IAC/D,OAAOC,YAAYD;AACrB;AACA,OAAO,SAASE,6BAA6BF,IAAwB;IACnE,OAAOC,YAAYD,MAAMG,IAAI;AAC/B;AAEA,OAAO,SAASC,cAAcJ,IAAwB,EAAEK,MAAkB;IACxE,IAAIA,QAAQ;QACV,MAAMC,eAAyB,EAAE;QACjC,MAAMC,eAAe,CAACC;YACpB,MAAMC,UAAUD,KAAKE,GAAG;YACxB,MAAMC,WAAWX,KAAKY,MAAM,CAACC,OAAO,CAACL,KAAKM,QAAQ;YAElD,IAAIH,UAAU;gBACZ,MAAMI,QAAQJ,UAAUK,aAAa,CAACP,QAAQ,EAAEQ,YAAYF;gBAI5D,IAAIA,OAAOG,SAAS,QAAQ;oBAC1BV,OAAOA,KAAKW,IAAI;oBAChBb,aAAac,OAAO,CAAC;gBACvB;gBACA,IAAIL,OAAOG,SAAS,kBAAkBG,MAAMC,OAAO,CAACP,MAAMQ,UAAU,GAAG;oBACrEf,OAAOA,KAAKW,IAAI;oBAChBb,aAAac,OAAO,CAAC;gBACvB;gBACA,IAAIL,OAAO;oBACTT,aAAac,OAAO,CAACL,MAAMS,IAAI;gBACjC;YACF;YAEA,IAAIhB,KAAKW,IAAI,EAAE;gBACbZ,aAAaC,KAAKW,IAAI;YACxB;QACF;QAEAZ,aAAaP,KAAKQ,IAAI;QACtBF,aAAamB,OAAO,CAAC,CAACf;YACpBL,SAASA,QAAQ,CAACK,IAAI;QACxB;IACF;IAEA,OAAOL;AACT;AAEA,SAASJ,YAAYD,IAAwB;IAC3C,MAAM0B,aAAahC,aAAaM,KAAK0B,UAAU;IAC/C,MAAMC,eA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oBACxE;oBACA;gBACF;YAEA,KAAK/C,KAAKmD,eAAe;gBAAE;oBACzB,MAAMJ,eAAeb,UAAUc,aAAa,GACvC9C,KAAKY,MAAM,CAACC,OAAO,CAACmB,UAAUc,aAAa,CAACtB,IAAI,CAACa,KAAK,IACvDnB;oBAEJ,IAAI2B,cAAc;wBAChB,gEAAgE;wBAChE,MAAMK,YAAYL,aAAa5B,UAAU,EAAEiC;wBAE3C,IAAIA,aAAarD,YAAYqB,OAAO;4BAClCa,SAAS,CAACmB,UAAU,GAAGrB,gBAAgB7B,MAAMgC,UAAUL,YAAY,EAAEkB;wBACvE,OAAO;4BACLE,OAAOC,MAAM,CAACjB,WAAWF,gBAAgB7B,MAAMgC,UAAUL,YAAY,EAAEkB;wBACzE;oBACF;oBACA;gBACF;QACF;IACF;IAEA,OAAOd;AACT"}
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/select.ts"],"sourcesContent":["import type { GraphQLObjectType, GraphQLResolveInfo, SelectionSetNode } from 'graphql'\nimport type {\n FieldBase,\n JoinField,\n RelationshipField,\n SelectIncludeType,\n TypedCollectionSelect,\n UploadField,\n} from 'payload'\n\nimport { getNamedType, isInterfaceType, isObjectType, isUnionType, Kind } from 'graphql'\n\nimport type { Context } from '../resolvers/types.js'\n\ntype SelectRootPathsByOperation = WeakMap<\n GraphQLResolveInfo['operation'],\n Set<GraphQLResolveInfo['path']['key']>\n>\n\nconst selectRootPathsByContext = new WeakMap<Context, SelectRootPathsByOperation>()\n\nexport function buildSelectForCollection(info: GraphQLResolveInfo, context?: Context): SelectType {\n if (context) {\n registerSelectRootPath(context, info)\n }\n\n return buildSelect(info)\n}\nexport function buildSelectForCollectionMany(\n info: GraphQLResolveInfo,\n context?: Context,\n): SelectType {\n if (context) {\n registerSelectRootPath(context, info)\n }\n\n return buildSelect(info)?.docs as SelectType\n}\n\nexport function resolveSelect(\n info: GraphQLResolveInfo,\n select: SelectType,\n context?: Context,\n): SelectType {\n const isSelectEnabled = context ? hasSelectRootPath(context, info) : typeof select !== 'undefined'\n\n if (!isSelectEnabled) {\n return undefined\n }\n\n const field = info.parentType.getFields()[info.fieldName]?.extensions?.field as\n | JoinField\n | RelationshipField\n | undefined\n | UploadField\n const fieldSelect = buildSelect(info)\n\n if (field?.type === 'join') {\n return fieldSelect?.docs as SelectType\n }\n\n if (\n (field?.type === 'relationship' || field?.type === 'upload') &&\n Array.isArray(field.relationTo)\n ) {\n return fieldSelect?.value as SelectType\n }\n\n return fieldSelect\n}\n\nfunction buildSelect(info: GraphQLResolveInfo) {\n const returnType = getNamedType(info.returnType) as GraphQLObjectType\n\n if (!returnType) {\n return\n }\n\n return info.fieldNodes.reduce<SelectTree>((fieldTree, fieldNode) => {\n if (!fieldNode.selectionSet) {\n return fieldTree\n }\n\n return mergeSelectTrees(fieldTree, buildSelectTree(info, fieldNode.selectionSet, returnType))\n }, {})\n}\n\nfunction buildSelectTree(\n info: GraphQLResolveInfo,\n selectionSet: SelectionSetNode,\n type: GraphQLObjectType,\n): SelectTree {\n const fieldMap = type.getFields?.()\n let fieldTree: SelectTree = {}\n\n for (const selection of selectionSet.selections) {\n switch (selection.kind) {\n case Kind.FIELD: {\n const fieldName = selection.name.value\n const fieldSchema = fieldMap?.[fieldName]\n\n const field = fieldSchema?.extensions?.field as FieldBase\n const fieldNameOriginal = field?.name || fieldName\n\n if (fieldName === '__typename') {\n continue\n }\n if (fieldSchema == undefined) {\n continue\n }\n\n if (selection.selectionSet) {\n const type = getNamedType(fieldSchema.type) as GraphQLObjectType\n\n if (isObjectType(type) || isInterfaceType(type) || isUnionType(type)) {\n fieldTree = mergeSelectTrees(fieldTree, {\n [fieldNameOriginal]: buildSelectTree(info, selection.selectionSet, type),\n })\n continue\n }\n }\n\n fieldTree = mergeSelectTrees(fieldTree, { [fieldNameOriginal]: true })\n break\n }\n\n case Kind.FRAGMENT_SPREAD: {\n const fragmentName = selection.name.value\n const fragment = info.fragments[fragmentName]\n const fragmentType =\n fragment && (info.schema.getType(fragment.typeCondition.name.value) as GraphQLObjectType)\n\n if (fragmentType) {\n fieldTree = mergeSelectTrees(\n fieldTree,\n buildFragmentSelectTree(info, fragment.selectionSet, fragmentType, type),\n )\n }\n break\n }\n\n case Kind.INLINE_FRAGMENT: {\n const fragmentType = selection.typeCondition\n ? (info.schema.getType(selection.typeCondition.name.value) as GraphQLObjectType)\n : type\n\n if (fragmentType) {\n fieldTree = mergeSelectTrees(\n fieldTree,\n buildFragmentSelectTree(info, selection.selectionSet, fragmentType, type),\n )\n }\n break\n }\n }\n }\n\n return fieldTree\n}\n\nfunction buildFragmentSelectTree(\n info: GraphQLResolveInfo,\n selectionSet: SelectionSetNode,\n fragmentType: GraphQLObjectType,\n parentType: GraphQLObjectType,\n): SelectTree {\n const fragmentSelectTree = buildSelectTree(info, selectionSet, fragmentType)\n const blockSlug = fragmentType.extensions?.blockSlug as string | undefined\n\n if (blockSlug && isUnionType(parentType)) {\n return { [blockSlug]: fragmentSelectTree }\n }\n\n return fragmentSelectTree\n}\n\nfunction getRootPathKey(path: GraphQLResolveInfo['path']): GraphQLResolveInfo['path']['key'] {\n while (path.prev) {\n path = path.prev\n }\n\n return path.key\n}\n\nfunction hasSelectRootPath(context: Context, info: GraphQLResolveInfo): boolean {\n return Boolean(\n selectRootPathsByContext.get(context)?.get(info.operation)?.has(getRootPathKey(info.path)),\n )\n}\n\nfunction isSelectTree(value: unknown): value is SelectTree {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n\nfunction mergeSelectTrees(firstTree: SelectTree, secondTree: SelectTree): SelectTree {\n const mergedTree = { ...firstTree }\n\n for (const [fieldName, fieldSelect] of Object.entries(secondTree)) {\n const existingFieldSelect = mergedTree[fieldName]\n\n mergedTree[fieldName] =\n isSelectTree(existingFieldSelect) && isSelectTree(fieldSelect)\n ? mergeSelectTrees(existingFieldSelect, fieldSelect)\n : fieldSelect\n }\n\n return mergedTree\n}\n\nfunction registerSelectRootPath(context: Context, info: GraphQLResolveInfo): void {\n let selectRootPathsByOperation = selectRootPathsByContext.get(context)\n\n if (!selectRootPathsByOperation) {\n selectRootPathsByOperation = new WeakMap()\n selectRootPathsByContext.set(context, selectRootPathsByOperation)\n }\n\n let selectRootPaths = selectRootPathsByOperation.get(info.operation)\n\n if (!selectRootPaths) {\n selectRootPaths = new Set()\n selectRootPathsByOperation.set(info.operation, selectRootPaths)\n }\n\n selectRootPaths.add(getRootPathKey(info.path))\n}\n\ntype SelectTree = SelectIncludeType\ntype SelectType = TypedCollectionSelect['any']\n"],"names":["getNamedType","isInterfaceType","isObjectType","isUnionType","Kind","selectRootPathsByContext","WeakMap","buildSelectForCollection","info","context","registerSelectRootPath","buildSelect","buildSelectForCollectionMany","docs","resolveSelect","select","isSelectEnabled","hasSelectRootPath","undefined","field","parentType","getFields","fieldName","extensions","fieldSelect","type","Array","isArray","relationTo","value","returnType","fieldNodes","reduce","fieldTree","fieldNode","selectionSet","mergeSelectTrees","buildSelectTree","fieldMap","selection","selections","kind","FIELD","name","fieldSchema","fieldNameOriginal","FRAGMENT_SPREAD","fragmentName","fragment","fragments","fragmentType","schema","getType","typeCondition","buildFragmentSelectTree","INLINE_FRAGMENT","fragmentSelectTree","blockSlug","getRootPathKey","path","prev","key","Boolean","get","operation","has","isSelectTree","firstTree","secondTree","mergedTree","Object","entries","existingFieldSelect","selectRootPathsByOperation","set","selectRootPaths","Set","add"],"mappings":"AAUA,SAASA,YAAY,EAAEC,eAAe,EAAEC,YAAY,EAAEC,WAAW,EAAEC,IAAI,QAAQ,UAAS;AASxF,MAAMC,2BAA2B,IAAIC;AAErC,OAAO,SAASC,yBAAyBC,IAAwB,EAAEC,OAAiB;IAClF,IAAIA,SAAS;QACXC,uBAAuBD,SAASD;IAClC;IAEA,OAAOG,YAAYH;AACrB;AACA,OAAO,SAASI,6BACdJ,IAAwB,EACxBC,OAAiB;IAEjB,IAAIA,SAAS;QACXC,uBAAuBD,SAASD;IAClC;IAEA,OAAOG,YAAYH,OAAOK;AAC5B;AAEA,OA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AEAA,gBAAgBE,GAAG,CAACnB,eAAelD,KAAKmD,IAAI;AAC9C"}
|
package/package.json
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/graphql",
|
|
3
|
-
"version": "4.0.0-internal.
|
|
3
|
+
"version": "4.0.0-internal.d3909a9",
|
|
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
|
-
"
|
|
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,37 +43,26 @@
|
|
|
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",
|
|
49
49
|
"ts-essentials": "10.0.3",
|
|
50
|
-
"tsx": "4.
|
|
50
|
+
"tsx": "4.23.15"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@types/pluralize": "^0.0.33",
|
|
54
54
|
"graphql-http": "1.22.4",
|
|
55
|
-
"
|
|
56
|
-
"payload": "4.0.0-internal.d21c039"
|
|
55
|
+
"payload": "4.0.0-internal.d3909a9"
|
|
57
56
|
},
|
|
58
57
|
"peerDependencies": {
|
|
59
58
|
"graphql": "^16.8.1",
|
|
60
|
-
"payload": "4.0.0-internal.
|
|
59
|
+
"payload": "4.0.0-internal.d3909a9"
|
|
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
|
}
|