@payloadcms/graphql 3.45.0-internal.2f73d3c → 3.45.0
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 +16 -0
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AACjD,OAAO,KAAK,EAAe,eAAe,EAAE,MAAM,SAAS,CAAA;AAE3D,OAAO,KAAK,OAAO,MAAM,SAAS,CAAA;AAelC,wBAAgB,cAAc,CAAC,MAAM,EAAE,eAAe,GAAG;IACvD,MAAM,EAAE,OAAO,CAAC,aAAa,CAAA;IAC7B,eAAe,EAAE,CAAC,IAAI,EAAE,aAAa,CAAC,GAAG,CAAC,KAAK,OAAO,CAAC,cAAc,EAAE,CAAA;CACxE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AACjD,OAAO,KAAK,EAAe,eAAe,EAAE,MAAM,SAAS,CAAA;AAE3D,OAAO,KAAK,OAAO,MAAM,SAAS,CAAA;AAelC,wBAAgB,cAAc,CAAC,MAAM,EAAE,eAAe,GAAG;IACvD,MAAM,EAAE,OAAO,CAAC,aAAa,CAAA;IAC7B,eAAe,EAAE,CAAC,IAAI,EAAE,aAAa,CAAC,GAAG,CAAC,KAAK,OAAO,CAAC,cAAc,EAAE,CAAA;CACxE,CAwGA"}
|
package/dist/index.js
CHANGED
|
@@ -95,6 +95,9 @@ export function configToSchema(config) {
|
|
|
95
95
|
maximumComplexity: config.graphQL.maxComplexity,
|
|
96
96
|
variables: args.variableValues
|
|
97
97
|
}),
|
|
98
|
+
...config.graphQL.disableIntrospectionInProduction ? [
|
|
99
|
+
NoProductionIntrospection
|
|
100
|
+
] : [],
|
|
98
101
|
...typeof config?.graphQL?.validationRules === 'function' ? config.graphQL.validationRules(args) : []
|
|
99
102
|
];
|
|
100
103
|
return {
|
|
@@ -102,5 +105,18 @@ export function configToSchema(config) {
|
|
|
102
105
|
validationRules
|
|
103
106
|
};
|
|
104
107
|
}
|
|
108
|
+
const NoProductionIntrospection = (context)=>({
|
|
109
|
+
Field (node) {
|
|
110
|
+
if (process.env.NODE_ENV === 'production') {
|
|
111
|
+
if (node.name.value === '__schema' || node.name.value === '__type') {
|
|
112
|
+
context.reportError(new GraphQL.GraphQLError('GraphQL introspection is not allowed, but the query contained __schema or __type', {
|
|
113
|
+
nodes: [
|
|
114
|
+
node
|
|
115
|
+
]
|
|
116
|
+
}));
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
});
|
|
105
121
|
|
|
106
122
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { OperationArgs } from 'graphql-http'\nimport type { GraphQLInfo, SanitizedConfig } from 'payload'\n\nimport * as GraphQL from 'graphql'\n\nimport {\n createComplexityRule,\n fieldExtensionsEstimator,\n simpleEstimator,\n} from './packages/graphql-query-complexity/index.js'\nimport { accessResolver } from './resolvers/auth/access.js'\nimport { buildFallbackLocaleInputType } from './schema/buildFallbackLocaleInputType.js'\nimport { buildLocaleInputType } from './schema/buildLocaleInputType.js'\nimport { buildPoliciesType } from './schema/buildPoliciesType.js'\nimport { initCollections } from './schema/initCollections.js'\nimport { initGlobals } from './schema/initGlobals.js'\nimport { wrapCustomFields } from './utilities/wrapCustomResolver.js'\n\nexport function configToSchema(config: SanitizedConfig): {\n schema: GraphQL.GraphQLSchema\n validationRules: (args: OperationArgs<any>) => GraphQL.ValidationRule[]\n} {\n const collections = config.collections.reduce((acc, collection) => {\n acc[collection.slug] = {\n config: collection,\n }\n\n return acc\n }, {})\n\n const globals = {\n config: config.globals,\n }\n\n const graphqlResult: GraphQLInfo = {\n collections,\n globals,\n Mutation: {\n name: 'Mutation',\n fields: {},\n },\n Query: {\n name: 'Query',\n fields: {},\n },\n types: {\n arrayTypes: {},\n blockInputTypes: {},\n blockTypes: {},\n groupTypes: {},\n tabTypes: {},\n },\n }\n\n if (config.localization) {\n graphqlResult.types['localeInputType'] = buildLocaleInputType(config.localization)\n graphqlResult.types['fallbackLocaleInputType'] = buildFallbackLocaleInputType(\n config.localization,\n )\n }\n\n initCollections({ config, graphqlResult })\n initGlobals({ config, graphqlResult })\n\n graphqlResult.Query.fields['Access'] = {\n type: buildPoliciesType(config),\n resolve: accessResolver(config),\n }\n\n if (typeof config.graphQL.queries === 'function') {\n const customQueries = config.graphQL.queries(GraphQL, {\n ...graphqlResult,\n config,\n })\n graphqlResult.Query = {\n ...graphqlResult.Query,\n fields: {\n ...graphqlResult.Query.fields,\n ...wrapCustomFields((customQueries || {}) as never),\n },\n }\n }\n\n if (typeof config.graphQL.mutations === 'function') {\n const customMutations = config.graphQL.mutations(GraphQL, {\n ...graphqlResult,\n config,\n })\n graphqlResult.Mutation = {\n ...graphqlResult.Mutation,\n fields: {\n ...graphqlResult.Mutation.fields,\n ...wrapCustomFields((customMutations || {}) as never),\n },\n }\n }\n\n const query = new GraphQL.GraphQLObjectType(graphqlResult.Query)\n const mutation = new GraphQL.GraphQLObjectType(graphqlResult.Mutation)\n\n const schema = new GraphQL.GraphQLSchema({\n mutation,\n query,\n })\n\n const validationRules = (args): GraphQL.ValidationRule[] => [\n createComplexityRule({\n estimators: [\n fieldExtensionsEstimator(),\n simpleEstimator({ defaultComplexity: 1 }), // Fallback if complexity not set\n ],\n maximumComplexity: config.graphQL.maxComplexity,\n variables: args.variableValues,\n // onComplete: (complexity) => { console.log('Query Complexity:', complexity); },\n }),\n ...(typeof config?.graphQL?.validationRules === 'function'\n ? config.graphQL.validationRules(args)\n : []),\n ]\n\n return {\n schema,\n validationRules,\n }\n}\n"],"names":["GraphQL","createComplexityRule","fieldExtensionsEstimator","simpleEstimator","accessResolver","buildFallbackLocaleInputType","buildLocaleInputType","buildPoliciesType","initCollections","initGlobals","wrapCustomFields","configToSchema","config","collections","reduce","acc","collection","slug","globals","graphqlResult","Mutation","name","fields","Query","types","arrayTypes","blockInputTypes","blockTypes","groupTypes","tabTypes","localization","type","resolve","graphQL","queries","customQueries","mutations","customMutations","query","GraphQLObjectType","mutation","schema","GraphQLSchema","validationRules","args","estimators","defaultComplexity","maximumComplexity","maxComplexity","variables","variableValues"],"mappings":"AAGA,YAAYA,aAAa,UAAS;AAElC,SACEC,oBAAoB,EACpBC,wBAAwB,EACxBC,eAAe,QACV,+CAA8C;AACrD,SAASC,cAAc,QAAQ,6BAA4B;AAC3D,SAASC,4BAA4B,QAAQ,2CAA0C;AACvF,SAASC,oBAAoB,QAAQ,mCAAkC;AACvE,SAASC,iBAAiB,QAAQ,gCAA+B;AACjE,SAASC,eAAe,QAAQ,8BAA6B;AAC7D,SAASC,WAAW,QAAQ,0BAAyB;AACrD,SAASC,gBAAgB,QAAQ,oCAAmC;AAEpE,OAAO,SAASC,eAAeC,MAAuB;IAIpD,MAAMC,cAAcD,OAAOC,WAAW,CAACC,MAAM,CAAC,CAACC,KAAKC;QAClDD,GAAG,CAACC,WAAWC,IAAI,CAAC,GAAG;YACrBL,QAAQI;QACV;QAEA,OAAOD;IACT,GAAG,CAAC;IAEJ,MAAMG,UAAU;QACdN,QAAQA,OAAOM,OAAO;IACxB;IAEA,MAAMC,gBAA6B;QACjCN;QACAK;QACAE,UAAU;YACRC,MAAM;YACNC,QAAQ,CAAC;QACX;QACAC,OAAO;YACLF,MAAM;YACNC,QAAQ,CAAC;QACX;QACAE,OAAO;YACLC,YAAY,CAAC;YACbC,iBAAiB,CAAC;YAClBC,YAAY,CAAC;YACbC,YAAY,CAAC;YACbC,U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A,MAAMK,kBAAkB,CAACC,OAAmC;YAC1D3C,qBAAqB;gBACnB4C,YAAY;oBACV3C;oBACAC,gBAAgB;wBAAE2C,mBAAmB;oBAAE;iBACxC;gBACDC,mBAAmBnC,OAAOqB,OAAO,CAACe,aAAa;gBAC/CC,WAAWL,KAAKM,cAAc;YAEhC;
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { OperationArgs } from 'graphql-http'\nimport type { GraphQLInfo, SanitizedConfig } from 'payload'\n\nimport * as GraphQL from 'graphql'\n\nimport {\n createComplexityRule,\n fieldExtensionsEstimator,\n simpleEstimator,\n} from './packages/graphql-query-complexity/index.js'\nimport { accessResolver } from './resolvers/auth/access.js'\nimport { buildFallbackLocaleInputType } from './schema/buildFallbackLocaleInputType.js'\nimport { buildLocaleInputType } from './schema/buildLocaleInputType.js'\nimport { buildPoliciesType } from './schema/buildPoliciesType.js'\nimport { initCollections } from './schema/initCollections.js'\nimport { initGlobals } from './schema/initGlobals.js'\nimport { wrapCustomFields } from './utilities/wrapCustomResolver.js'\n\nexport function configToSchema(config: SanitizedConfig): {\n schema: GraphQL.GraphQLSchema\n validationRules: (args: OperationArgs<any>) => GraphQL.ValidationRule[]\n} {\n const collections = config.collections.reduce((acc, collection) => {\n acc[collection.slug] = {\n config: collection,\n }\n\n return acc\n }, {})\n\n const globals = {\n config: config.globals,\n }\n\n const graphqlResult: GraphQLInfo = {\n collections,\n globals,\n Mutation: {\n name: 'Mutation',\n fields: {},\n },\n Query: {\n name: 'Query',\n fields: {},\n },\n types: {\n arrayTypes: {},\n blockInputTypes: {},\n blockTypes: {},\n groupTypes: {},\n tabTypes: {},\n },\n }\n\n if (config.localization) {\n graphqlResult.types['localeInputType'] = buildLocaleInputType(config.localization)\n graphqlResult.types['fallbackLocaleInputType'] = buildFallbackLocaleInputType(\n config.localization,\n )\n }\n\n initCollections({ config, graphqlResult })\n initGlobals({ config, graphqlResult })\n\n graphqlResult.Query.fields['Access'] = {\n type: buildPoliciesType(config),\n resolve: accessResolver(config),\n }\n\n if (typeof config.graphQL.queries === 'function') {\n const customQueries = config.graphQL.queries(GraphQL, {\n ...graphqlResult,\n config,\n })\n graphqlResult.Query = {\n ...graphqlResult.Query,\n fields: {\n ...graphqlResult.Query.fields,\n ...wrapCustomFields((customQueries || {}) as never),\n },\n }\n }\n\n if (typeof config.graphQL.mutations === 'function') {\n const customMutations = config.graphQL.mutations(GraphQL, {\n ...graphqlResult,\n config,\n })\n graphqlResult.Mutation = {\n ...graphqlResult.Mutation,\n fields: {\n ...graphqlResult.Mutation.fields,\n ...wrapCustomFields((customMutations || {}) as never),\n },\n }\n }\n\n const query = new GraphQL.GraphQLObjectType(graphqlResult.Query)\n const mutation = new GraphQL.GraphQLObjectType(graphqlResult.Mutation)\n\n const schema = new GraphQL.GraphQLSchema({\n mutation,\n query,\n })\n\n const validationRules = (args): GraphQL.ValidationRule[] => [\n createComplexityRule({\n estimators: [\n fieldExtensionsEstimator(),\n simpleEstimator({ defaultComplexity: 1 }), // Fallback if complexity not set\n ],\n maximumComplexity: config.graphQL.maxComplexity,\n variables: args.variableValues,\n // onComplete: (complexity) => { console.log('Query Complexity:', complexity); },\n }),\n ...(config.graphQL.disableIntrospectionInProduction ? [NoProductionIntrospection] : []),\n ...(typeof config?.graphQL?.validationRules === 'function'\n ? config.graphQL.validationRules(args)\n : []),\n ]\n\n return {\n schema,\n validationRules,\n }\n}\n\nconst NoProductionIntrospection: GraphQL.ValidationRule = (context) => ({\n Field(node) {\n if (process.env.NODE_ENV === 'production') {\n if (node.name.value === '__schema' || node.name.value === '__type') {\n context.reportError(\n new GraphQL.GraphQLError(\n 'GraphQL introspection is not allowed, but the query contained __schema or __type',\n { nodes: [node] },\n ),\n )\n }\n }\n },\n})\n"],"names":["GraphQL","createComplexityRule","fieldExtensionsEstimator","simpleEstimator","accessResolver","buildFallbackLocaleInputType","buildLocaleInputType","buildPoliciesType","initCollections","initGlobals","wrapCustomFields","configToSchema","config","collections","reduce","acc","collection","slug","globals","graphqlResult","Mutation","name","fields","Query","types","arrayTypes","blockInputTypes","blockTypes","groupTypes","tabTypes","localization","type","resolve","graphQL","queries","customQueries","mutations","customMutations","query","GraphQLObjectType","mutation","schema","GraphQLSchema","validationRules","args","estimators","defaultComplexity","maximumComplexity","maxComplexity","variables","variableValues","disableIntrospectionInProduction","NoProductionIntrospection","context","Field","node","process","env","NODE_ENV","value","reportError","GraphQLError","nodes"],"mappings":"AAGA,YAAYA,aAAa,UAAS;AAElC,SACEC,oBAAoB,EACpBC,wBAAwB,EACxBC,eAAe,QACV,+CAA8C;AACrD,SAASC,cAAc,QAAQ,6BAA4B;AAC3D,SAASC,4BAA4B,QAAQ,2CAA0C;AACvF,SAASC,oBAAoB,QAAQ,mCAAkC;AACvE,SAASC,iBAAiB,QAAQ,gCAA+B;AACjE,SAASC,eAAe,QAAQ,8BAA6B;AAC7D,SAASC,WAAW,QAAQ,0BAAyB;AACrD,SAASC,gBAAgB,QAAQ,oCAAmC;AAEpE,OAAO,SAASC,eAAeC,MAAuB;IAIpD,MAAMC,cAAcD,OAAOC,WAAW,CAACC,MAAM,CAAC,CAACC,KAAKC;QAClDD,GAAG,CAACC,WAAWC,IAAI,CAAC,GAAG;YACrBL,QAAQI;QACV;QAEA,OAAOD;IACT,GAAG,CAAC;IAEJ,MAAMG,UAAU;QACdN,QAAQA,OAAOM,OAAO;IACxB;IAEA,MAAMC,gBAA6B;QACjCN;QACAK;QACAE,UAAU;YACRC,MAAM;YACNC,QAAQ,CAAC;QACX;QACAC,OAAO;YACLF,MAAM;YACNC,QAAQ,CAAC;QACX;QACAE,OAAO;YACLC,YAAY,CAAC;YACbC,iBAAiB,CAAC;YAClBC,YAAY,CAAC;YACbC,YAAY,CAAC;YACbC,UAAU,CAAC;QACb;IACF;IAEA,IAAIjB,OAAOkB,YAAY,EAAE;QACvBX,cAAcK,KAAK,CAAC,kBAAkB,GAAGlB,qBAAqBM,OAAOkB,YAAY;QACjFX,cAAcK,KA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OAAOqB,OAAO,CAACe,aAAa;gBAC/CC,WAAWL,KAAKM,cAAc;YAEhC;eACItC,OAAOqB,OAAO,CAACkB,gCAAgC,GAAG;gBAACC;aAA0B,GAAG,EAAE;eAClF,OAAOxC,QAAQqB,SAASU,oBAAoB,aAC5C/B,OAAOqB,OAAO,CAACU,eAAe,CAACC,QAC/B,EAAE;SACP;IAED,OAAO;QACLH;QACAE;IACF;AACF;AAEA,MAAMS,4BAAoD,CAACC,UAAa,CAAA;QACtEC,OAAMC,IAAI;YACR,IAAIC,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;gBACzC,IAAIH,KAAKlC,IAAI,CAACsC,KAAK,KAAK,cAAcJ,KAAKlC,IAAI,CAACsC,KAAK,KAAK,UAAU;oBAClEN,QAAQO,WAAW,CACjB,IAAI5D,QAAQ6D,YAAY,CACtB,oFACA;wBAAEC,OAAO;4BAACP;yBAAK;oBAAC;gBAGtB;YACF;QACF;IACF,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/graphql",
|
|
3
|
-
"version": "3.45.0
|
|
3
|
+
"version": "3.45.0",
|
|
4
4
|
"homepage": "https://payloadcms.com",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -53,11 +53,11 @@
|
|
|
53
53
|
"@types/pluralize": "^0.0.33",
|
|
54
54
|
"graphql-http": "^1.22.0",
|
|
55
55
|
"@payloadcms/eslint-config": "3.28.0",
|
|
56
|
-
"payload": "3.45.0
|
|
56
|
+
"payload": "3.45.0"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
59
|
"graphql": "^16.8.1",
|
|
60
|
-
"payload": "3.45.0
|
|
60
|
+
"payload": "3.45.0"
|
|
61
61
|
},
|
|
62
62
|
"scripts": {
|
|
63
63
|
"build": "pnpm build:types && pnpm build:swc",
|