@strapi/plugin-graphql 5.52.1 → 5.52.3
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/server/bootstrap.js
CHANGED
|
@@ -20,6 +20,19 @@ const merge = fp.mergeWith((a, b)=>{
|
|
|
20
20
|
return a.concat(b);
|
|
21
21
|
}
|
|
22
22
|
});
|
|
23
|
+
const getOperationLimitsWarning = ({ depthLimit: configuredDepthLimit, maxLimit })=>{
|
|
24
|
+
const unboundedOrInvalidKeys = [];
|
|
25
|
+
if (typeof configuredDepthLimit !== 'number' || !Number.isFinite(configuredDepthLimit) || configuredDepthLimit <= 0) {
|
|
26
|
+
unboundedOrInvalidKeys.push('depthLimit');
|
|
27
|
+
}
|
|
28
|
+
if (typeof maxLimit !== 'number' || !Number.isFinite(maxLimit) || maxLimit <= 0) {
|
|
29
|
+
unboundedOrInvalidKeys.push('maxLimit');
|
|
30
|
+
}
|
|
31
|
+
if (unboundedOrInvalidKeys.length === 0) {
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
34
|
+
return `Built-in GraphQL operation limits are unbounded or invalid for: ${unboundedOrInvalidKeys.join(', ')}. Configure these limits (for example: defaultLimit: 25, maxLimit: 100, depthLimit: 10). Custom Apollo validation rules may independently enforce limits. See https://docs.strapi.io/cms/configurations/plugins.`;
|
|
35
|
+
};
|
|
23
36
|
const determineLandingPage = (strapi)=>{
|
|
24
37
|
const { config } = strapi.plugin('graphql');
|
|
25
38
|
const utils = strapi.plugin('graphql').service('utils');
|
|
@@ -90,6 +103,15 @@ async function bootstrap({ strapi }) {
|
|
|
90
103
|
}
|
|
91
104
|
const { config } = strapi.plugin('graphql');
|
|
92
105
|
const path = config('endpoint');
|
|
106
|
+
const configuredDepthLimit = config('depthLimit');
|
|
107
|
+
const maxLimit = config('maxLimit');
|
|
108
|
+
const operationLimitsWarning = getOperationLimitsWarning({
|
|
109
|
+
depthLimit: configuredDepthLimit,
|
|
110
|
+
maxLimit
|
|
111
|
+
});
|
|
112
|
+
if (operationLimitsWarning) {
|
|
113
|
+
strapi.log.warn(operationLimitsWarning);
|
|
114
|
+
}
|
|
93
115
|
const landingPage = determineLandingPage(strapi);
|
|
94
116
|
/**
|
|
95
117
|
* We need the arguments passed to the root query to be available in the association resolver
|
|
@@ -125,8 +147,10 @@ async function bootstrap({ strapi }) {
|
|
|
125
147
|
// Schema
|
|
126
148
|
schema,
|
|
127
149
|
// Validation
|
|
150
|
+
// Keep v5 compatibility: depthLimit is passed through unchanged, so an unset or invalid value
|
|
151
|
+
// does not become an enforced finite limit during an upgrade.
|
|
128
152
|
validationRules: [
|
|
129
|
-
depthLimit__default.default(
|
|
153
|
+
depthLimit__default.default(configuredDepthLimit)
|
|
130
154
|
],
|
|
131
155
|
// Errors
|
|
132
156
|
formatError: formatGraphqlError.formatGraphqlError,
|
|
@@ -218,4 +242,5 @@ async function bootstrap({ strapi }) {
|
|
|
218
242
|
|
|
219
243
|
exports.bootstrap = bootstrap;
|
|
220
244
|
exports.determineLandingPage = determineLandingPage;
|
|
245
|
+
exports.getOperationLimitsWarning = getOperationLimitsWarning;
|
|
221
246
|
//# sourceMappingURL=bootstrap.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bootstrap.js","sources":["../../server/src/bootstrap.ts"],"sourcesContent":["import { isEmpty, mergeWith, isArray, isObject, isFunction } from 'lodash/fp';\nimport { ApolloServer, type ApolloServerPlugin, type ApolloServerOptions } from '@apollo/server';\nimport {\n ApolloServerPluginLandingPageLocalDefault,\n ApolloServerPluginLandingPageProductionDefault,\n} from '@apollo/server/plugin/landingPage/default';\nimport { koaMiddleware } from '@as-integrations/koa';\nimport depthLimit from 'graphql-depth-limit';\nimport bodyParser from 'koa-bodyparser';\nimport cors from '@koa/cors';\n\nimport type { Core } from '@strapi/types';\nimport type { Options } from '@koa/cors';\nimport type { BaseContext, DefaultContextExtends, DefaultStateExtends } from 'koa';\n\nimport { formatGraphqlError } from './format-graphql-error';\n\nconst merge = mergeWith((a, b) => {\n if (isArray(a) && isArray(b)) {\n return a.concat(b);\n }\n});\n\ntype StrapiGraphQLContext = BaseContext & {\n rootQueryArgsByPath?: Map<string | number, Record<string, unknown>>;\n};\n\nexport const determineLandingPage = (\n strapi: Core.Strapi\n): ApolloServerPlugin<StrapiGraphQLContext> => {\n const { config } = strapi.plugin('graphql');\n const utils = strapi.plugin('graphql').service('utils');\n\n /**\n * configLanding page may be one of the following:\n *\n * - true: always use \"playground\" even in production\n * - false: never show \"playground\" even in non-production\n * - undefined: default Apollo behavior (hide playground on production)\n * - a function that returns an Apollo plugin that implements renderLandingPage\n ** */\n const configLandingPage = config('landingPage');\n\n const isProduction = process.env.NODE_ENV === 'production';\n\n const localLanding = () => {\n strapi.log.debug('Apollo landing page: local');\n utils.playground.setEnabled(true);\n return ApolloServerPluginLandingPageLocalDefault();\n };\n\n const prodLanding = () => {\n strapi.log.debug('Apollo landing page: production');\n utils.playground.setEnabled(false);\n return ApolloServerPluginLandingPageProductionDefault();\n };\n\n const userLanding = (userFunction: (strapi?: Core.Strapi) => ApolloServerPlugin | boolean) => {\n strapi.log.debug('Apollo landing page: from user-defined function...');\n const result = userFunction(strapi);\n if (result === true) {\n return localLanding();\n }\n if (result === false) {\n return prodLanding();\n }\n strapi.log.debug('Apollo landing page: user-defined');\n return result;\n };\n\n // DEPRECATED, remove in Strapi v6\n const playgroundAlways = config('playgroundAlways');\n if (playgroundAlways !== undefined) {\n strapi.log.warn(\n 'The graphql config playgroundAlways is deprecated. This will be removed in Strapi 6. Please use landingPage instead. '\n );\n }\n if (playgroundAlways === false) {\n strapi.log.warn(\n 'graphql config playgroundAlways:false has no effect, please use landingPage:false to disable Graphql Playground in all environments'\n );\n }\n\n if (playgroundAlways || configLandingPage === true) {\n return localLanding();\n }\n\n // if landing page has been disabled, use production\n if (configLandingPage === false) {\n return prodLanding();\n }\n\n // If user did not define any settings, use our defaults\n if (configLandingPage === undefined) {\n return isProduction ? prodLanding() : localLanding();\n }\n\n // if user provided a landing page function, return that\n if (isFunction(configLandingPage)) {\n return userLanding(configLandingPage);\n }\n\n // If no other setting could be found, default to production settings\n strapi.log.warn(\n 'Your Graphql landing page has been disabled because there is a problem with your Graphql settings'\n );\n return prodLanding();\n};\n\nexport async function bootstrap({ strapi }: { strapi: Core.Strapi }) {\n // Generate the GraphQL schema for the content API\n const schema = strapi.plugin('graphql').service('content-api').buildSchema();\n\n if (isEmpty(schema)) {\n strapi.log.warn('The GraphQL schema has not been generated because it is empty');\n\n return;\n }\n\n const { config } = strapi.plugin('graphql');\n\n const path: string = config('endpoint');\n\n const landingPage = determineLandingPage(strapi);\n /**\n * We need the arguments passed to the root query to be available in the association resolver\n * so we can forward those arguments along to any relations.\n *\n * In order to do that we are currently storing the arguments in context.\n * There is likely a better solution, but for now this is the simplest fix we could find.\n *\n * @see https://github.com/strapi/strapi/issues/23524\n */\n const pluginAddRootQueryArgs: ApolloServerPlugin<StrapiGraphQLContext> = {\n async requestDidStart() {\n return {\n async executionDidStart() {\n return {\n willResolveField({ source, args, contextValue, info }) {\n if (!source && info.operation.operation === 'query') {\n // Key args per root field (alias)\n if (!contextValue.rootQueryArgsByPath) {\n contextValue.rootQueryArgsByPath = new Map();\n }\n contextValue.rootQueryArgsByPath.set(info.path.key, {\n ...args,\n _originField: info.fieldName,\n });\n }\n },\n };\n },\n };\n },\n };\n\n type CustomOptions = {\n cors?: boolean | Options;\n uploads: boolean;\n bodyParserConfig: boolean;\n };\n\n const defaultServerConfig: ApolloServerOptions<StrapiGraphQLContext> & CustomOptions = {\n // Schema\n schema,\n\n // Validation\n validationRules: [depthLimit(config('depthLimit') as number) as any],\n\n // Errors\n formatError: formatGraphqlError,\n\n // Misc\n cors: undefined,\n uploads: false,\n bodyParserConfig: true,\n // send 400 http status instead of 200 for input validation errors\n status400ForVariableCoercionErrors: true,\n plugins: [landingPage, pluginAddRootQueryArgs],\n\n cache: 'bounded' as const,\n };\n\n const serverConfig = merge(\n defaultServerConfig,\n config('apolloServer')\n ) as ApolloServerOptions<StrapiGraphQLContext> & CustomOptions;\n\n // Create a new Apollo server\n const server = new ApolloServer(serverConfig);\n\n try {\n // server.start() must be called before using server.applyMiddleware()\n await server.start();\n } catch (error) {\n if (error instanceof Error) {\n strapi.log.error('Failed to start the Apollo server', error.message);\n }\n\n throw error;\n }\n\n // Create the route handlers for Strapi\n const handler: Core.MiddlewareHandler[] = [];\n\n // add cors middleware\n if (serverConfig.cors === false) {\n // Explicitly disabled - don't add middleware\n } else if (serverConfig.cors === undefined || serverConfig.cors === true) {\n // enable with defaults (backwards compatible)\n handler.push(cors());\n } else {\n // Custom options object\n handler.push(cors(serverConfig.cors));\n }\n\n // add koa bodyparser middleware\n if (isObject(serverConfig.bodyParserConfig)) {\n handler.push(bodyParser(serverConfig.bodyParserConfig));\n } else if (serverConfig.bodyParserConfig) {\n handler.push(bodyParser());\n } else {\n strapi.log.debug('Body parser has been disabled for Apollo server');\n }\n\n // add the Strapi auth middleware\n handler.push((ctx, next) => {\n ctx.state.route = {\n info: {\n // Indicate it's a content API route\n type: 'content-api',\n },\n };\n\n const isPlaygroundRequest =\n ctx.request.method === 'GET' &&\n ctx.request.url === path && // Matches the GraphQL endpoint\n strapi.plugin('graphql').service('utils').playground.isEnabled() && // Only allow if the Playground is enabled\n ctx.request.header.accept?.includes('text/html'); // Specific to Playground UI loading\n\n // Skip authentication for the GraphQL Playground UI\n if (isPlaygroundRequest) {\n return next();\n }\n\n return strapi.auth.authenticate(ctx, next);\n });\n\n // add the graphql server for koa\n handler.push(\n koaMiddleware<DefaultStateExtends, DefaultContextExtends>(server, {\n // Initialize loaders for this request.\n context: async ({ ctx }) => ({\n state: ctx.state,\n koaContext: ctx,\n }),\n })\n );\n\n // now that handlers are set up, add the graphql route to our apollo server\n strapi.server.routes([\n {\n method: 'ALL',\n path,\n handler,\n config: {\n auth: false,\n },\n },\n ]);\n\n // Register destroy behavior\n // We're doing it here instead of exposing a destroy method to the strapi-server.js\n // file since we need to have access to the ApolloServer instance\n strapi.plugin('graphql').destroy = async () => {\n await server.stop();\n };\n}\n"],"names":["merge","mergeWith","a","b","isArray","concat","determineLandingPage","strapi","config","plugin","utils","service","configLandingPage","isProduction","process","env","NODE_ENV","localLanding","log","debug","playground","setEnabled","ApolloServerPluginLandingPageLocalDefault","prodLanding","ApolloServerPluginLandingPageProductionDefault","userLanding","userFunction","result","playgroundAlways","undefined","warn","isFunction","bootstrap","schema","buildSchema","isEmpty","path","landingPage","pluginAddRootQueryArgs","requestDidStart","executionDidStart","willResolveField","source","args","contextValue","info","operation","rootQueryArgsByPath","Map","set","key","_originField","fieldName","defaultServerConfig","validationRules","depthLimit","formatError","formatGraphqlError","cors","uploads","bodyParserConfig","status400ForVariableCoercionErrors","plugins","cache","serverConfig","server","ApolloServer","start","error","Error","message","handler","push","isObject","bodyParser","ctx","next","state","route","type","isPlaygroundRequest","request","method","url","isEnabled","header","accept","includes","auth","authenticate","koaMiddleware","context","koaContext","routes","destroy","stop"],"mappings":";;;;;;;;;;;;;;;;;AAiBA,MAAMA,KAAAA,GAAQC,YAAAA,CAAU,CAACC,CAAAA,EAAGC,CAAAA,GAAAA;IAC1B,IAAIC,UAAAA,CAAQF,CAAAA,CAAAA,IAAME,UAAAA,CAAQD,CAAAA,CAAAA,EAAI;QAC5B,OAAOD,CAAAA,CAAEG,MAAM,CAACF,CAAAA,CAAAA;AAClB,IAAA;AACF,CAAA,CAAA;AAMO,MAAMG,uBAAuB,CAClCC,MAAAA,GAAAA;AAEA,IAAA,MAAM,EAAEC,MAAM,EAAE,GAAGD,MAAAA,CAAOE,MAAM,CAAC,SAAA,CAAA;AACjC,IAAA,MAAMC,QAAQH,MAAAA,CAAOE,MAAM,CAAC,SAAA,CAAA,CAAWE,OAAO,CAAC,OAAA,CAAA;AAE/C;;;;;;;SAQA,MAAMC,oBAAoBJ,MAAAA,CAAO,aAAA,CAAA;AAEjC,IAAA,MAAMK,YAAAA,GAAeC,OAAAA,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A,QAAA,OAAOrE,MAAAA,CAAOiF,IAAI,CAACC,YAAY,CAACd,GAAAA,EAAKC,IAAAA,CAAAA;AACvC,IAAA,CAAA,CAAA;;IAGAL,OAAAA,CAAQC,IAAI,CACVkB,iBAAAA,CAA0DzB,QAAAA,EAAQ;;AAEhE0B,QAAAA,OAAAA,EAAS,OAAO,EAAEhB,GAAG,EAAE,IAAM;AAC3BE,gBAAAA,KAAAA,EAAOF,IAAIE,KAAK;gBAChBe,UAAAA,EAAYjB;aACd;AACF,KAAA,CAAA,CAAA;;IAIFpE,MAAAA,CAAO0D,MAAM,CAAC4B,MAAM,CAAC;AACnB,QAAA;YACEX,MAAAA,EAAQ,KAAA;AACR9C,YAAAA,IAAAA;AACAmC,YAAAA,OAAAA;YACA/D,MAAAA,EAAQ;gBACNgF,IAAAA,EAAM;AACR;AACF;AACD,KAAA,CAAA;;;;AAKDjF,IAAAA,MAAAA,CAAOE,MAAM,CAAC,SAAA,CAAA,CAAWqF,OAAO,GAAG,UAAA;AACjC,QAAA,MAAM7B,SAAO8B,IAAI,EAAA;AACnB,IAAA,CAAA;AACF;;;;;"}
|
|
1
|
+
{"version":3,"file":"bootstrap.js","sources":["../../server/src/bootstrap.ts"],"sourcesContent":["import { isEmpty, mergeWith, isArray, isObject, isFunction } from 'lodash/fp';\nimport { ApolloServer, type ApolloServerPlugin, type ApolloServerOptions } from '@apollo/server';\nimport {\n ApolloServerPluginLandingPageLocalDefault,\n ApolloServerPluginLandingPageProductionDefault,\n} from '@apollo/server/plugin/landingPage/default';\nimport { koaMiddleware } from '@as-integrations/koa';\nimport depthLimit from 'graphql-depth-limit';\nimport bodyParser from 'koa-bodyparser';\nimport cors from '@koa/cors';\n\nimport type { Core } from '@strapi/types';\nimport type { Options } from '@koa/cors';\nimport type { BaseContext, DefaultContextExtends, DefaultStateExtends } from 'koa';\n\nimport { formatGraphqlError } from './format-graphql-error';\n\nconst merge = mergeWith((a, b) => {\n if (isArray(a) && isArray(b)) {\n return a.concat(b);\n }\n});\n\ntype StrapiGraphQLContext = BaseContext & {\n rootQueryArgsByPath?: Map<string | number, Record<string, unknown>>;\n};\n\ntype OperationLimitConfig = {\n depthLimit?: unknown;\n maxLimit?: unknown;\n};\n\nexport const getOperationLimitsWarning = ({\n depthLimit: configuredDepthLimit,\n maxLimit,\n}: OperationLimitConfig): string | undefined => {\n const unboundedOrInvalidKeys: string[] = [];\n\n if (\n typeof configuredDepthLimit !== 'number' ||\n !Number.isFinite(configuredDepthLimit) ||\n configuredDepthLimit <= 0\n ) {\n unboundedOrInvalidKeys.push('depthLimit');\n }\n\n if (typeof maxLimit !== 'number' || !Number.isFinite(maxLimit) || maxLimit <= 0) {\n unboundedOrInvalidKeys.push('maxLimit');\n }\n\n if (unboundedOrInvalidKeys.length === 0) {\n return undefined;\n }\n\n return `Built-in GraphQL operation limits are unbounded or invalid for: ${unboundedOrInvalidKeys.join(', ')}. Configure these limits (for example: defaultLimit: 25, maxLimit: 100, depthLimit: 10). Custom Apollo validation rules may independently enforce limits. See https://docs.strapi.io/cms/configurations/plugins.`;\n};\n\nexport const determineLandingPage = (\n strapi: Core.Strapi\n): ApolloServerPlugin<StrapiGraphQLContext> => {\n const { config } = strapi.plugin('graphql');\n const utils = strapi.plugin('graphql').service('utils');\n\n /**\n * configLanding page may be one of the following:\n *\n * - true: always use \"playground\" even in production\n * - false: never show \"playground\" even in non-production\n * - undefined: default Apollo behavior (hide playground on production)\n * - a function that returns an Apollo plugin that implements renderLandingPage\n ** */\n const configLandingPage = config('landingPage');\n\n const isProduction = process.env.NODE_ENV === 'production';\n\n const localLanding = () => {\n strapi.log.debug('Apollo landing page: local');\n utils.playground.setEnabled(true);\n return ApolloServerPluginLandingPageLocalDefault();\n };\n\n const prodLanding = () => {\n strapi.log.debug('Apollo landing page: production');\n utils.playground.setEnabled(false);\n return ApolloServerPluginLandingPageProductionDefault();\n };\n\n const userLanding = (userFunction: (strapi?: Core.Strapi) => ApolloServerPlugin | boolean) => {\n strapi.log.debug('Apollo landing page: from user-defined function...');\n const result = userFunction(strapi);\n if (result === true) {\n return localLanding();\n }\n if (result === false) {\n return prodLanding();\n }\n strapi.log.debug('Apollo landing page: user-defined');\n return result;\n };\n\n // DEPRECATED, remove in Strapi v6\n const playgroundAlways = config('playgroundAlways');\n if (playgroundAlways !== undefined) {\n strapi.log.warn(\n 'The graphql config playgroundAlways is deprecated. This will be removed in Strapi 6. Please use landingPage instead. '\n );\n }\n if (playgroundAlways === false) {\n strapi.log.warn(\n 'graphql config playgroundAlways:false has no effect, please use landingPage:false to disable Graphql Playground in all environments'\n );\n }\n\n if (playgroundAlways || configLandingPage === true) {\n return localLanding();\n }\n\n // if landing page has been disabled, use production\n if (configLandingPage === false) {\n return prodLanding();\n }\n\n // If user did not define any settings, use our defaults\n if (configLandingPage === undefined) {\n return isProduction ? prodLanding() : localLanding();\n }\n\n // if user provided a landing page function, return that\n if (isFunction(configLandingPage)) {\n return userLanding(configLandingPage);\n }\n\n // If no other setting could be found, default to production settings\n strapi.log.warn(\n 'Your Graphql landing page has been disabled because there is a problem with your Graphql settings'\n );\n return prodLanding();\n};\n\nexport async function bootstrap({ strapi }: { strapi: Core.Strapi }) {\n // Generate the GraphQL schema for the content API\n const schema = strapi.plugin('graphql').service('content-api').buildSchema();\n\n if (isEmpty(schema)) {\n strapi.log.warn('The GraphQL schema has not been generated because it is empty');\n\n return;\n }\n\n const { config } = strapi.plugin('graphql');\n\n const path: string = config('endpoint');\n const configuredDepthLimit = config('depthLimit');\n const maxLimit = config('maxLimit');\n const operationLimitsWarning = getOperationLimitsWarning({\n depthLimit: configuredDepthLimit,\n maxLimit,\n });\n\n if (operationLimitsWarning) {\n strapi.log.warn(operationLimitsWarning);\n }\n\n const landingPage = determineLandingPage(strapi);\n /**\n * We need the arguments passed to the root query to be available in the association resolver\n * so we can forward those arguments along to any relations.\n *\n * In order to do that we are currently storing the arguments in context.\n * There is likely a better solution, but for now this is the simplest fix we could find.\n *\n * @see https://github.com/strapi/strapi/issues/23524\n */\n const pluginAddRootQueryArgs: ApolloServerPlugin<StrapiGraphQLContext> = {\n async requestDidStart() {\n return {\n async executionDidStart() {\n return {\n willResolveField({ source, args, contextValue, info }) {\n if (!source && info.operation.operation === 'query') {\n // Key args per root field (alias)\n if (!contextValue.rootQueryArgsByPath) {\n contextValue.rootQueryArgsByPath = new Map();\n }\n contextValue.rootQueryArgsByPath.set(info.path.key, {\n ...args,\n _originField: info.fieldName,\n });\n }\n },\n };\n },\n };\n },\n };\n\n type CustomOptions = {\n cors?: boolean | Options;\n uploads: boolean;\n bodyParserConfig: boolean;\n };\n\n const defaultServerConfig: ApolloServerOptions<StrapiGraphQLContext> & CustomOptions = {\n // Schema\n schema,\n\n // Validation\n // Keep v5 compatibility: depthLimit is passed through unchanged, so an unset or invalid value\n // does not become an enforced finite limit during an upgrade.\n validationRules: [depthLimit(configuredDepthLimit as number) as any],\n\n // Errors\n formatError: formatGraphqlError,\n\n // Misc\n cors: undefined,\n uploads: false,\n bodyParserConfig: true,\n // send 400 http status instead of 200 for input validation errors\n status400ForVariableCoercionErrors: true,\n plugins: [landingPage, pluginAddRootQueryArgs],\n\n cache: 'bounded' as const,\n };\n\n const serverConfig = merge(\n defaultServerConfig,\n config('apolloServer')\n ) as ApolloServerOptions<StrapiGraphQLContext> & CustomOptions;\n\n // Create a new Apollo server\n const server = new ApolloServer(serverConfig);\n\n try {\n // server.start() must be called before using server.applyMiddleware()\n await server.start();\n } catch (error) {\n if (error instanceof Error) {\n strapi.log.error('Failed to start the Apollo server', error.message);\n }\n\n throw error;\n }\n\n // Create the route handlers for Strapi\n const handler: Core.MiddlewareHandler[] = [];\n\n // add cors middleware\n if (serverConfig.cors === false) {\n // Explicitly disabled - don't add middleware\n } else if (serverConfig.cors === undefined || serverConfig.cors === true) {\n // enable with defaults (backwards compatible)\n handler.push(cors());\n } else {\n // Custom options object\n handler.push(cors(serverConfig.cors));\n }\n\n // add koa bodyparser middleware\n if (isObject(serverConfig.bodyParserConfig)) {\n handler.push(bodyParser(serverConfig.bodyParserConfig));\n } else if (serverConfig.bodyParserConfig) {\n handler.push(bodyParser());\n } else {\n strapi.log.debug('Body parser has been disabled for Apollo server');\n }\n\n // add the Strapi auth middleware\n handler.push((ctx, next) => {\n ctx.state.route = {\n info: {\n // Indicate it's a content API route\n type: 'content-api',\n },\n };\n\n const isPlaygroundRequest =\n ctx.request.method === 'GET' &&\n ctx.request.url === path && // Matches the GraphQL endpoint\n strapi.plugin('graphql').service('utils').playground.isEnabled() && // Only allow if the Playground is enabled\n ctx.request.header.accept?.includes('text/html'); // Specific to Playground UI loading\n\n // Skip authentication for the GraphQL Playground UI\n if (isPlaygroundRequest) {\n return next();\n }\n\n return strapi.auth.authenticate(ctx, next);\n });\n\n // add the graphql server for koa\n handler.push(\n koaMiddleware<DefaultStateExtends, DefaultContextExtends>(server, {\n // Initialize loaders for this request.\n context: async ({ ctx }) => ({\n state: ctx.state,\n koaContext: ctx,\n }),\n })\n );\n\n // now that handlers are set up, add the graphql route to our apollo server\n strapi.server.routes([\n {\n method: 'ALL',\n path,\n handler,\n config: {\n auth: false,\n },\n },\n ]);\n\n // Register destroy behavior\n // We're doing it here instead of exposing a destroy method to the strapi-server.js\n // file since we need to have access to the ApolloServer instance\n strapi.plugin('graphql').destroy = async () => {\n await server.stop();\n };\n}\n"],"names":["merge","mergeWith","a","b","isArray","concat","getOperationLimitsWarning","depthLimit","configuredDepthLimit","maxLimit","unboundedOrInvalidKeys","Number","isFinite","push","length","undefined","join","determineLandingPage","strapi","config","plugin","utils","service","configLandingPage","isProduction","process","env","NODE_ENV","localLanding","log","debug","playground","setEnabled","ApolloServerPluginLandingPageLocalDefault","prodLanding","ApolloServerPluginLandingPageProductionDefault","userLanding","userFunction","result","playgroundAlways","warn","isFunction","bootstrap","schema","buildSchema","isEmpty","path","operationLimitsWarning","landingPage","pluginAddRootQueryArgs","requestDidStart","executionDidStart","willResolveField","source","args","contextValue","info","operation","rootQueryArgsByPath","Map","set","key","_originField","fieldName","defaultServerConfig","validationRules","formatError","formatGraphqlError","cors","uploads","bodyParserConfig","status400ForVariableCoercionErrors","plugins","cache","serverConfig","server","ApolloServer","start","error","Error","message","handler","isObject","bodyParser","ctx","next","state","route","type","isPlaygroundRequest","request","method","url","isEnabled","header","accept","includes","auth","authenticate","koaMiddleware","context","koaContext","routes","destroy","stop"],"mappings":";;;;;;;;;;;;;;;;;AAiBA,MAAMA,KAAAA,GAAQC,YAAAA,CAAU,CAACC,CAAAA,EAAGC,CAAAA,GAAAA;IAC1B,IAAIC,UAAAA,CAAQF,CAAAA,CAAAA,IAAME,UAAAA,CAAQD,CAAAA,CAAAA,EAAI;QAC5B,OAAOD,CAAAA,CAAEG,MAAM,CAACF,CAAAA,CAAAA;AAClB,IAAA;AACF,CAAA,CAAA;AAWO,MAAMG,4BAA4B,CAAC,EACxCC,YAAYC,oBAAoB,EAChCC,QAAQ,EACa,GAAA;AACrB,IAAA,MAAMC,yBAAmC,EAAE;IAE3C,IACE,OAAOF,yBAAyB,QAAA,IAChC,CAACG,OAAOC,QAAQ,CAACJ,oBAAAA,CAAAA,IACjBA,oBAAAA,IAAwB,CAAA,EACxB;AACAE,QAAAA,sBAAAA,CAAuBG,IAAI,CAAC,YAAA,CAAA;AAC9B,IAAA;IAEA,IAAI,OAAOJ,aAAa,QAAA,IAAY,CAACE,OAAOC,QAAQ,CAACH,QAAAA,CAAAA,IAAaA,QAAAA,IAAY,CAAA,EAAG;AAC/EC,QAAAA,sBAAAA,CAAuBG,IAAI,CAAC,UAAA,CAAA;AAC9B,IAAA;IAEA,IAAIH,sBAAAA,CAAuBI,MAAM,KAAK,CAAA,EAAG;QACvC,OAAOC,SAAAA;AACT,IAAA;IAEA,OAAO,CAAC,gEAAgE,EAAEL,sBAAAA,CAAuBM,IAAI,CAAC,IAAA,CAAA,CAAM,gNAAgN,CAAC;AAC/T;AAEO,MAAMC,uBAAuB,CAClCC,MAAAA,GAAAA;AAEA,IAAA,MAAM,EAAEC,MAA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A;AACnB,IAAA,CAAA;AACF;;;;;;"}
|
|
@@ -12,6 +12,19 @@ const merge = mergeWith((a, b)=>{
|
|
|
12
12
|
return a.concat(b);
|
|
13
13
|
}
|
|
14
14
|
});
|
|
15
|
+
const getOperationLimitsWarning = ({ depthLimit: configuredDepthLimit, maxLimit })=>{
|
|
16
|
+
const unboundedOrInvalidKeys = [];
|
|
17
|
+
if (typeof configuredDepthLimit !== 'number' || !Number.isFinite(configuredDepthLimit) || configuredDepthLimit <= 0) {
|
|
18
|
+
unboundedOrInvalidKeys.push('depthLimit');
|
|
19
|
+
}
|
|
20
|
+
if (typeof maxLimit !== 'number' || !Number.isFinite(maxLimit) || maxLimit <= 0) {
|
|
21
|
+
unboundedOrInvalidKeys.push('maxLimit');
|
|
22
|
+
}
|
|
23
|
+
if (unboundedOrInvalidKeys.length === 0) {
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
return `Built-in GraphQL operation limits are unbounded or invalid for: ${unboundedOrInvalidKeys.join(', ')}. Configure these limits (for example: defaultLimit: 25, maxLimit: 100, depthLimit: 10). Custom Apollo validation rules may independently enforce limits. See https://docs.strapi.io/cms/configurations/plugins.`;
|
|
27
|
+
};
|
|
15
28
|
const determineLandingPage = (strapi)=>{
|
|
16
29
|
const { config } = strapi.plugin('graphql');
|
|
17
30
|
const utils = strapi.plugin('graphql').service('utils');
|
|
@@ -82,6 +95,15 @@ async function bootstrap({ strapi }) {
|
|
|
82
95
|
}
|
|
83
96
|
const { config } = strapi.plugin('graphql');
|
|
84
97
|
const path = config('endpoint');
|
|
98
|
+
const configuredDepthLimit = config('depthLimit');
|
|
99
|
+
const maxLimit = config('maxLimit');
|
|
100
|
+
const operationLimitsWarning = getOperationLimitsWarning({
|
|
101
|
+
depthLimit: configuredDepthLimit,
|
|
102
|
+
maxLimit
|
|
103
|
+
});
|
|
104
|
+
if (operationLimitsWarning) {
|
|
105
|
+
strapi.log.warn(operationLimitsWarning);
|
|
106
|
+
}
|
|
85
107
|
const landingPage = determineLandingPage(strapi);
|
|
86
108
|
/**
|
|
87
109
|
* We need the arguments passed to the root query to be available in the association resolver
|
|
@@ -117,8 +139,10 @@ async function bootstrap({ strapi }) {
|
|
|
117
139
|
// Schema
|
|
118
140
|
schema,
|
|
119
141
|
// Validation
|
|
142
|
+
// Keep v5 compatibility: depthLimit is passed through unchanged, so an unset or invalid value
|
|
143
|
+
// does not become an enforced finite limit during an upgrade.
|
|
120
144
|
validationRules: [
|
|
121
|
-
depthLimit(
|
|
145
|
+
depthLimit(configuredDepthLimit)
|
|
122
146
|
],
|
|
123
147
|
// Errors
|
|
124
148
|
formatError: formatGraphqlError,
|
|
@@ -208,5 +232,5 @@ async function bootstrap({ strapi }) {
|
|
|
208
232
|
};
|
|
209
233
|
}
|
|
210
234
|
|
|
211
|
-
export { bootstrap, determineLandingPage };
|
|
235
|
+
export { bootstrap, determineLandingPage, getOperationLimitsWarning };
|
|
212
236
|
//# sourceMappingURL=bootstrap.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bootstrap.mjs","sources":["../../server/src/bootstrap.ts"],"sourcesContent":["import { isEmpty, mergeWith, isArray, isObject, isFunction } from 'lodash/fp';\nimport { ApolloServer, type ApolloServerPlugin, type ApolloServerOptions } from '@apollo/server';\nimport {\n ApolloServerPluginLandingPageLocalDefault,\n ApolloServerPluginLandingPageProductionDefault,\n} from '@apollo/server/plugin/landingPage/default';\nimport { koaMiddleware } from '@as-integrations/koa';\nimport depthLimit from 'graphql-depth-limit';\nimport bodyParser from 'koa-bodyparser';\nimport cors from '@koa/cors';\n\nimport type { Core } from '@strapi/types';\nimport type { Options } from '@koa/cors';\nimport type { BaseContext, DefaultContextExtends, DefaultStateExtends } from 'koa';\n\nimport { formatGraphqlError } from './format-graphql-error';\n\nconst merge = mergeWith((a, b) => {\n if (isArray(a) && isArray(b)) {\n return a.concat(b);\n }\n});\n\ntype StrapiGraphQLContext = BaseContext & {\n rootQueryArgsByPath?: Map<string | number, Record<string, unknown>>;\n};\n\nexport const determineLandingPage = (\n strapi: Core.Strapi\n): ApolloServerPlugin<StrapiGraphQLContext> => {\n const { config } = strapi.plugin('graphql');\n const utils = strapi.plugin('graphql').service('utils');\n\n /**\n * configLanding page may be one of the following:\n *\n * - true: always use \"playground\" even in production\n * - false: never show \"playground\" even in non-production\n * - undefined: default Apollo behavior (hide playground on production)\n * - a function that returns an Apollo plugin that implements renderLandingPage\n ** */\n const configLandingPage = config('landingPage');\n\n const isProduction = process.env.NODE_ENV === 'production';\n\n const localLanding = () => {\n strapi.log.debug('Apollo landing page: local');\n utils.playground.setEnabled(true);\n return ApolloServerPluginLandingPageLocalDefault();\n };\n\n const prodLanding = () => {\n strapi.log.debug('Apollo landing page: production');\n utils.playground.setEnabled(false);\n return ApolloServerPluginLandingPageProductionDefault();\n };\n\n const userLanding = (userFunction: (strapi?: Core.Strapi) => ApolloServerPlugin | boolean) => {\n strapi.log.debug('Apollo landing page: from user-defined function...');\n const result = userFunction(strapi);\n if (result === true) {\n return localLanding();\n }\n if (result === false) {\n return prodLanding();\n }\n strapi.log.debug('Apollo landing page: user-defined');\n return result;\n };\n\n // DEPRECATED, remove in Strapi v6\n const playgroundAlways = config('playgroundAlways');\n if (playgroundAlways !== undefined) {\n strapi.log.warn(\n 'The graphql config playgroundAlways is deprecated. This will be removed in Strapi 6. Please use landingPage instead. '\n );\n }\n if (playgroundAlways === false) {\n strapi.log.warn(\n 'graphql config playgroundAlways:false has no effect, please use landingPage:false to disable Graphql Playground in all environments'\n );\n }\n\n if (playgroundAlways || configLandingPage === true) {\n return localLanding();\n }\n\n // if landing page has been disabled, use production\n if (configLandingPage === false) {\n return prodLanding();\n }\n\n // If user did not define any settings, use our defaults\n if (configLandingPage === undefined) {\n return isProduction ? prodLanding() : localLanding();\n }\n\n // if user provided a landing page function, return that\n if (isFunction(configLandingPage)) {\n return userLanding(configLandingPage);\n }\n\n // If no other setting could be found, default to production settings\n strapi.log.warn(\n 'Your Graphql landing page has been disabled because there is a problem with your Graphql settings'\n );\n return prodLanding();\n};\n\nexport async function bootstrap({ strapi }: { strapi: Core.Strapi }) {\n // Generate the GraphQL schema for the content API\n const schema = strapi.plugin('graphql').service('content-api').buildSchema();\n\n if (isEmpty(schema)) {\n strapi.log.warn('The GraphQL schema has not been generated because it is empty');\n\n return;\n }\n\n const { config } = strapi.plugin('graphql');\n\n const path: string = config('endpoint');\n\n const landingPage = determineLandingPage(strapi);\n /**\n * We need the arguments passed to the root query to be available in the association resolver\n * so we can forward those arguments along to any relations.\n *\n * In order to do that we are currently storing the arguments in context.\n * There is likely a better solution, but for now this is the simplest fix we could find.\n *\n * @see https://github.com/strapi/strapi/issues/23524\n */\n const pluginAddRootQueryArgs: ApolloServerPlugin<StrapiGraphQLContext> = {\n async requestDidStart() {\n return {\n async executionDidStart() {\n return {\n willResolveField({ source, args, contextValue, info }) {\n if (!source && info.operation.operation === 'query') {\n // Key args per root field (alias)\n if (!contextValue.rootQueryArgsByPath) {\n contextValue.rootQueryArgsByPath = new Map();\n }\n contextValue.rootQueryArgsByPath.set(info.path.key, {\n ...args,\n _originField: info.fieldName,\n });\n }\n },\n };\n },\n };\n },\n };\n\n type CustomOptions = {\n cors?: boolean | Options;\n uploads: boolean;\n bodyParserConfig: boolean;\n };\n\n const defaultServerConfig: ApolloServerOptions<StrapiGraphQLContext> & CustomOptions = {\n // Schema\n schema,\n\n // Validation\n validationRules: [depthLimit(config('depthLimit') as number) as any],\n\n // Errors\n formatError: formatGraphqlError,\n\n // Misc\n cors: undefined,\n uploads: false,\n bodyParserConfig: true,\n // send 400 http status instead of 200 for input validation errors\n status400ForVariableCoercionErrors: true,\n plugins: [landingPage, pluginAddRootQueryArgs],\n\n cache: 'bounded' as const,\n };\n\n const serverConfig = merge(\n defaultServerConfig,\n config('apolloServer')\n ) as ApolloServerOptions<StrapiGraphQLContext> & CustomOptions;\n\n // Create a new Apollo server\n const server = new ApolloServer(serverConfig);\n\n try {\n // server.start() must be called before using server.applyMiddleware()\n await server.start();\n } catch (error) {\n if (error instanceof Error) {\n strapi.log.error('Failed to start the Apollo server', error.message);\n }\n\n throw error;\n }\n\n // Create the route handlers for Strapi\n const handler: Core.MiddlewareHandler[] = [];\n\n // add cors middleware\n if (serverConfig.cors === false) {\n // Explicitly disabled - don't add middleware\n } else if (serverConfig.cors === undefined || serverConfig.cors === true) {\n // enable with defaults (backwards compatible)\n handler.push(cors());\n } else {\n // Custom options object\n handler.push(cors(serverConfig.cors));\n }\n\n // add koa bodyparser middleware\n if (isObject(serverConfig.bodyParserConfig)) {\n handler.push(bodyParser(serverConfig.bodyParserConfig));\n } else if (serverConfig.bodyParserConfig) {\n handler.push(bodyParser());\n } else {\n strapi.log.debug('Body parser has been disabled for Apollo server');\n }\n\n // add the Strapi auth middleware\n handler.push((ctx, next) => {\n ctx.state.route = {\n info: {\n // Indicate it's a content API route\n type: 'content-api',\n },\n };\n\n const isPlaygroundRequest =\n ctx.request.method === 'GET' &&\n ctx.request.url === path && // Matches the GraphQL endpoint\n strapi.plugin('graphql').service('utils').playground.isEnabled() && // Only allow if the Playground is enabled\n ctx.request.header.accept?.includes('text/html'); // Specific to Playground UI loading\n\n // Skip authentication for the GraphQL Playground UI\n if (isPlaygroundRequest) {\n return next();\n }\n\n return strapi.auth.authenticate(ctx, next);\n });\n\n // add the graphql server for koa\n handler.push(\n koaMiddleware<DefaultStateExtends, DefaultContextExtends>(server, {\n // Initialize loaders for this request.\n context: async ({ ctx }) => ({\n state: ctx.state,\n koaContext: ctx,\n }),\n })\n );\n\n // now that handlers are set up, add the graphql route to our apollo server\n strapi.server.routes([\n {\n method: 'ALL',\n path,\n handler,\n config: {\n auth: false,\n },\n },\n ]);\n\n // Register destroy behavior\n // We're doing it here instead of exposing a destroy method to the strapi-server.js\n // file since we need to have access to the ApolloServer instance\n strapi.plugin('graphql').destroy = async () => {\n await server.stop();\n };\n}\n"],"names":["merge","mergeWith","a","b","isArray","concat","determineLandingPage","strapi","config","plugin","utils","service","configLandingPage","isProduction","process","env","NODE_ENV","localLanding","log","debug","playground","setEnabled","ApolloServerPluginLandingPageLocalDefault","prodLanding","ApolloServerPluginLandingPageProductionDefault","userLanding","userFunction","result","playgroundAlways","undefined","warn","isFunction","bootstrap","schema","buildSchema","isEmpty","path","landingPage","pluginAddRootQueryArgs","requestDidStart","executionDidStart","willResolveField","source","args","contextValue","info","operation","rootQueryArgsByPath","Map","set","key","_originField","fieldName","defaultServerConfig","validationRules","depthLimit","formatError","formatGraphqlError","cors","uploads","bodyParserConfig","status400ForVariableCoercionErrors","plugins","cache","serverConfig","server","ApolloServer","start","error","Error","message","handler","push","isObject","bodyParser","ctx","next","state","route","type","isPlaygroundRequest","request","method","url","isEnabled","header","accept","includes","auth","authenticate","koaMiddleware","context","koaContext","routes","destroy","stop"],"mappings":";;;;;;;;;AAiBA,MAAMA,KAAAA,GAAQC,SAAAA,CAAU,CAACC,CAAAA,EAAGC,CAAAA,GAAAA;IAC1B,IAAIC,OAAAA,CAAQF,CAAAA,CAAAA,IAAME,OAAAA,CAAQD,CAAAA,CAAAA,EAAI;QAC5B,OAAOD,CAAAA,CAAEG,MAAM,CAACF,CAAAA,CAAAA;AAClB,IAAA;AACF,CAAA,CAAA;AAMO,MAAMG,uBAAuB,CAClCC,MAAAA,GAAAA;AAEA,IAAA,MAAM,EAAEC,MAAM,EAAE,GAAGD,MAAAA,CAAOE,MAAM,CAAC,SAAA,CAAA;AACjC,IAAA,MAAMC,QAAQH,MAAAA,CAAOE,MAAM,CAAC,SAAA,CAAA,CAAWE,OAAO,CAAC,OAAA,CAAA;AAE/C;;;;;;;SAQA,MAAMC,oBAAoBJ,MAAAA,CAAO,aAAA,CAAA;AAEjC,IAAA,MAAMK,YAAAA,GAAeC,OAAAA,CAAQC,GAAG,CAACC,QAAQ,KAAK,YAAA;AAE9C,IAAA,MAAMC,YAAAA,GAAe,IAAA;QACnBV,MAAAA,CAAOW,GAAG,CAACC,KAAK,CAAC,4BAAA,CAAA;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,aAAAA,CAA0DzB,MAAAA,EAAQ;;AAEhE0B,QAAAA,OAAAA,EAAS,OAAO,EAAEhB,GAAG,EAAE,IAAM;AAC3BE,gBAAAA,KAAAA,EAAOF,IAAIE,KAAK;gBAChBe,UAAAA,EAAYjB;aACd;AACF,KAAA,CAAA,CAAA;;IAIFpE,MAAAA,CAAO0D,MAAM,CAAC4B,MAAM,CAAC;AACnB,QAAA;YACEX,MAAAA,EAAQ,KAAA;AACR9C,YAAAA,IAAAA;AACAmC,YAAAA,OAAAA;YACA/D,MAAAA,EAAQ;gBACNgF,IAAAA,EAAM;AACR;AACF;AACD,KAAA,CAAA;;;;AAKDjF,IAAAA,MAAAA,CAAOE,MAAM,CAAC,SAAA,CAAA,CAAWqF,OAAO,GAAG,UAAA;AACjC,QAAA,MAAM7B,OAAO8B,IAAI,EAAA;AACnB,IAAA,CAAA;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"bootstrap.mjs","sources":["../../server/src/bootstrap.ts"],"sourcesContent":["import { isEmpty, mergeWith, isArray, isObject, isFunction } from 'lodash/fp';\nimport { ApolloServer, type ApolloServerPlugin, type ApolloServerOptions } from '@apollo/server';\nimport {\n ApolloServerPluginLandingPageLocalDefault,\n ApolloServerPluginLandingPageProductionDefault,\n} from '@apollo/server/plugin/landingPage/default';\nimport { koaMiddleware } from '@as-integrations/koa';\nimport depthLimit from 'graphql-depth-limit';\nimport bodyParser from 'koa-bodyparser';\nimport cors from '@koa/cors';\n\nimport type { Core } from '@strapi/types';\nimport type { Options } from '@koa/cors';\nimport type { BaseContext, DefaultContextExtends, DefaultStateExtends } from 'koa';\n\nimport { formatGraphqlError } from './format-graphql-error';\n\nconst merge = mergeWith((a, b) => {\n if (isArray(a) && isArray(b)) {\n return a.concat(b);\n }\n});\n\ntype StrapiGraphQLContext = BaseContext & {\n rootQueryArgsByPath?: Map<string | number, Record<string, unknown>>;\n};\n\ntype OperationLimitConfig = {\n depthLimit?: unknown;\n maxLimit?: unknown;\n};\n\nexport const getOperationLimitsWarning = ({\n depthLimit: configuredDepthLimit,\n maxLimit,\n}: OperationLimitConfig): string | undefined => {\n const unboundedOrInvalidKeys: string[] = [];\n\n if (\n typeof configuredDepthLimit !== 'number' ||\n !Number.isFinite(configuredDepthLimit) ||\n configuredDepthLimit <= 0\n ) {\n unboundedOrInvalidKeys.push('depthLimit');\n }\n\n if (typeof maxLimit !== 'number' || !Number.isFinite(maxLimit) || maxLimit <= 0) {\n unboundedOrInvalidKeys.push('maxLimit');\n }\n\n if (unboundedOrInvalidKeys.length === 0) {\n return undefined;\n }\n\n return `Built-in GraphQL operation limits are unbounded or invalid for: ${unboundedOrInvalidKeys.join(', ')}. Configure these limits (for example: defaultLimit: 25, maxLimit: 100, depthLimit: 10). Custom Apollo validation rules may independently enforce limits. See https://docs.strapi.io/cms/configurations/plugins.`;\n};\n\nexport const determineLandingPage = (\n strapi: Core.Strapi\n): ApolloServerPlugin<StrapiGraphQLContext> => {\n const { config } = strapi.plugin('graphql');\n const utils = strapi.plugin('graphql').service('utils');\n\n /**\n * configLanding page may be one of the following:\n *\n * - true: always use \"playground\" even in production\n * - false: never show \"playground\" even in non-production\n * - undefined: default Apollo behavior (hide playground on production)\n * - a function that returns an Apollo plugin that implements renderLandingPage\n ** */\n const configLandingPage = config('landingPage');\n\n const isProduction = process.env.NODE_ENV === 'production';\n\n const localLanding = () => {\n strapi.log.debug('Apollo landing page: local');\n utils.playground.setEnabled(true);\n return ApolloServerPluginLandingPageLocalDefault();\n };\n\n const prodLanding = () => {\n strapi.log.debug('Apollo landing page: production');\n utils.playground.setEnabled(false);\n return ApolloServerPluginLandingPageProductionDefault();\n };\n\n const userLanding = (userFunction: (strapi?: Core.Strapi) => ApolloServerPlugin | boolean) => {\n strapi.log.debug('Apollo landing page: from user-defined function...');\n const result = userFunction(strapi);\n if (result === true) {\n return localLanding();\n }\n if (result === false) {\n return prodLanding();\n }\n strapi.log.debug('Apollo landing page: user-defined');\n return result;\n };\n\n // DEPRECATED, remove in Strapi v6\n const playgroundAlways = config('playgroundAlways');\n if (playgroundAlways !== undefined) {\n strapi.log.warn(\n 'The graphql config playgroundAlways is deprecated. This will be removed in Strapi 6. Please use landingPage instead. '\n );\n }\n if (playgroundAlways === false) {\n strapi.log.warn(\n 'graphql config playgroundAlways:false has no effect, please use landingPage:false to disable Graphql Playground in all environments'\n );\n }\n\n if (playgroundAlways || configLandingPage === true) {\n return localLanding();\n }\n\n // if landing page has been disabled, use production\n if (configLandingPage === false) {\n return prodLanding();\n }\n\n // If user did not define any settings, use our defaults\n if (configLandingPage === undefined) {\n return isProduction ? prodLanding() : localLanding();\n }\n\n // if user provided a landing page function, return that\n if (isFunction(configLandingPage)) {\n return userLanding(configLandingPage);\n }\n\n // If no other setting could be found, default to production settings\n strapi.log.warn(\n 'Your Graphql landing page has been disabled because there is a problem with your Graphql settings'\n );\n return prodLanding();\n};\n\nexport async function bootstrap({ strapi }: { strapi: Core.Strapi }) {\n // Generate the GraphQL schema for the content API\n const schema = strapi.plugin('graphql').service('content-api').buildSchema();\n\n if (isEmpty(schema)) {\n strapi.log.warn('The GraphQL schema has not been generated because it is empty');\n\n return;\n }\n\n const { config } = strapi.plugin('graphql');\n\n const path: string = config('endpoint');\n const configuredDepthLimit = config('depthLimit');\n const maxLimit = config('maxLimit');\n const operationLimitsWarning = getOperationLimitsWarning({\n depthLimit: configuredDepthLimit,\n maxLimit,\n });\n\n if (operationLimitsWarning) {\n strapi.log.warn(operationLimitsWarning);\n }\n\n const landingPage = determineLandingPage(strapi);\n /**\n * We need the arguments passed to the root query to be available in the association resolver\n * so we can forward those arguments along to any relations.\n *\n * In order to do that we are currently storing the arguments in context.\n * There is likely a better solution, but for now this is the simplest fix we could find.\n *\n * @see https://github.com/strapi/strapi/issues/23524\n */\n const pluginAddRootQueryArgs: ApolloServerPlugin<StrapiGraphQLContext> = {\n async requestDidStart() {\n return {\n async executionDidStart() {\n return {\n willResolveField({ source, args, contextValue, info }) {\n if (!source && info.operation.operation === 'query') {\n // Key args per root field (alias)\n if (!contextValue.rootQueryArgsByPath) {\n contextValue.rootQueryArgsByPath = new Map();\n }\n contextValue.rootQueryArgsByPath.set(info.path.key, {\n ...args,\n _originField: info.fieldName,\n });\n }\n },\n };\n },\n };\n },\n };\n\n type CustomOptions = {\n cors?: boolean | Options;\n uploads: boolean;\n bodyParserConfig: boolean;\n };\n\n const defaultServerConfig: ApolloServerOptions<StrapiGraphQLContext> & CustomOptions = {\n // Schema\n schema,\n\n // Validation\n // Keep v5 compatibility: depthLimit is passed through unchanged, so an unset or invalid value\n // does not become an enforced finite limit during an upgrade.\n validationRules: [depthLimit(configuredDepthLimit as number) as any],\n\n // Errors\n formatError: formatGraphqlError,\n\n // Misc\n cors: undefined,\n uploads: false,\n bodyParserConfig: true,\n // send 400 http status instead of 200 for input validation errors\n status400ForVariableCoercionErrors: true,\n plugins: [landingPage, pluginAddRootQueryArgs],\n\n cache: 'bounded' as const,\n };\n\n const serverConfig = merge(\n defaultServerConfig,\n config('apolloServer')\n ) as ApolloServerOptions<StrapiGraphQLContext> & CustomOptions;\n\n // Create a new Apollo server\n const server = new ApolloServer(serverConfig);\n\n try {\n // server.start() must be called before using server.applyMiddleware()\n await server.start();\n } catch (error) {\n if (error instanceof Error) {\n strapi.log.error('Failed to start the Apollo server', error.message);\n }\n\n throw error;\n }\n\n // Create the route handlers for Strapi\n const handler: Core.MiddlewareHandler[] = [];\n\n // add cors middleware\n if (serverConfig.cors === false) {\n // Explicitly disabled - don't add middleware\n } else if (serverConfig.cors === undefined || serverConfig.cors === true) {\n // enable with defaults (backwards compatible)\n handler.push(cors());\n } else {\n // Custom options object\n handler.push(cors(serverConfig.cors));\n }\n\n // add koa bodyparser middleware\n if (isObject(serverConfig.bodyParserConfig)) {\n handler.push(bodyParser(serverConfig.bodyParserConfig));\n } else if (serverConfig.bodyParserConfig) {\n handler.push(bodyParser());\n } else {\n strapi.log.debug('Body parser has been disabled for Apollo server');\n }\n\n // add the Strapi auth middleware\n handler.push((ctx, next) => {\n ctx.state.route = {\n info: {\n // Indicate it's a content API route\n type: 'content-api',\n },\n };\n\n const isPlaygroundRequest =\n ctx.request.method === 'GET' &&\n ctx.request.url === path && // Matches the GraphQL endpoint\n strapi.plugin('graphql').service('utils').playground.isEnabled() && // Only allow if the Playground is enabled\n ctx.request.header.accept?.includes('text/html'); // Specific to Playground UI loading\n\n // Skip authentication for the GraphQL Playground UI\n if (isPlaygroundRequest) {\n return next();\n }\n\n return strapi.auth.authenticate(ctx, next);\n });\n\n // add the graphql server for koa\n handler.push(\n koaMiddleware<DefaultStateExtends, DefaultContextExtends>(server, {\n // Initialize loaders for this request.\n context: async ({ ctx }) => ({\n state: ctx.state,\n koaContext: ctx,\n }),\n })\n );\n\n // now that handlers are set up, add the graphql route to our apollo server\n strapi.server.routes([\n {\n method: 'ALL',\n path,\n handler,\n config: {\n auth: false,\n },\n },\n ]);\n\n // Register destroy behavior\n // We're doing it here instead of exposing a destroy method to the strapi-server.js\n // file since we need to have access to the ApolloServer instance\n strapi.plugin('graphql').destroy = async () => {\n await server.stop();\n };\n}\n"],"names":["merge","mergeWith","a","b","isArray","concat","getOperationLimitsWarning","depthLimit","configuredDepthLimit","maxLimit","unboundedOrInvalidKeys","Number","isFinite","push","length","undefined","join","determineLandingPage","strapi","config","plugin","utils","service","configLandingPage","isProduction","process","env","NODE_ENV","localLanding","log","debug","playground","setEnabled","ApolloServerPluginLandingPageLocalDefault","prodLanding","ApolloServerPluginLandingPageProductionDefault","userLanding","userFunction","result","playgroundAlways","warn","isFunction","bootstrap","schema","buildSchema","isEmpty","path","operationLimitsWarning","landingPage","pluginAddRootQueryArgs","requestDidStart","executionDidStart","willResolveField","source","args","contextValue","info","operation","rootQueryArgsByPath","Map","set","key","_originField","fieldName","defaultServerConfig","validationRules","formatError","formatGraphqlError","cors","uploads","bodyParserConfig","status400ForVariableCoercionErrors","plugins","cache","serverConfig","server","ApolloServer","start","error","Error","message","handler","isObject","bodyParser","ctx","next","state","route","type","isPlaygroundRequest","request","method","url","isEnabled","header","accept","includes","auth","authenticate","koaMiddleware","context","koaContext","routes","destroy","stop"],"mappings":";;;;;;;;;AAiBA,MAAMA,KAAAA,GAAQC,SAAAA,CAAU,CAACC,CAAAA,EAAGC,CAAAA,GAAAA;IAC1B,IAAIC,OAAAA,CAAQF,CAAAA,CAAAA,IAAME,OAAAA,CAAQD,CAAAA,CAAAA,EAAI;QAC5B,OAAOD,CAAAA,CAAEG,MAAM,CAACF,CAAAA,CAAAA;AAClB,IAAA;AACF,CAAA,CAAA;AAWO,MAAMG,4BAA4B,CAAC,EACxCC,YAAYC,oBAAoB,EAChCC,QAAQ,EACa,GAAA;AACrB,IAAA,MAAMC,yBAAmC,EAAE;IAE3C,IACE,OAAOF,yBAAyB,QAAA,IAChC,CAACG,OAAOC,QAAQ,CAACJ,oBAAAA,CAAAA,IACjBA,oBAAAA,IAAwB,CAAA,EACxB;AACAE,QAAAA,sBAAAA,CAAuBG,IAAI,CAAC,YAAA,CAAA;AAC9B,IAAA;IAEA,IAAI,OAAOJ,aAAa,QAAA,IAAY,CAACE,OAAOC,QAAQ,CAACH,QAAAA,CAAAA,IAAaA,QAAAA,IAAY,CAAA,EAAG;AAC/EC,QAAAA,sBAAAA,CAAuBG,IAAI,CAAC,UAAA,CAAA;AAC9B,IAAA;IAEA,IAAIH,sBAAAA,CAAuBI,MAAM,KAAK,CAAA,EAAG;QACvC,OAAOC,SAAAA;AACT,IAAA;IAEA,OAAO,CAAC,gEAAgE,EAAEL,sBAAAA,CAAuBM,IAAI,CAAC,IAAA,CAAA,CAAM,gNAAgN,CAAC;AAC/T;AAEO,MAAMC,uBAAuB,CAClCC,MAAAA,GAAAA;AAEA,IAAA,MAAM,EAAEC,MAAM,EAAE,GAAGD,MAAAA,CAAOE,MAAM,CAAC,SAAA,CAAA;AACjC,IAAA,MAAMC,QAAQH,MAAAA,CAAOE,MAAM,CAAC,SAAA,CAAA,CAAWE,OAAO,CAAC,OAAA,CAAA;AAE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AA,EAAM;AACR;AACF,SAAA;AAEA,QAAA,MAAMC,mBAAAA,GACJL,GAAAA,CAAIM,OAAO,CAACC,MAAM,KAAK,KAAA,IACvBP,GAAAA,CAAIM,OAAO,CAACE,GAAG,KAAK9C;QACpB5B,MAAAA,CAAOE,MAAM,CAAC,SAAA,CAAA,CAAWE,OAAO,CAAC,SAASS,UAAU,CAAC8D,SAAS,EAAA;QAC9DT,GAAAA,CAAIM,OAAO,CAACI,MAAM,CAACC,MAAM,EAAEC,QAAAA,CAAS;;AAGtC,QAAA,IAAIP,mBAAAA,EAAqB;YACvB,OAAOJ,IAAAA,EAAAA;AACT,QAAA;AAEA,QAAA,OAAOnE,MAAAA,CAAO+E,IAAI,CAACC,YAAY,CAACd,GAAAA,EAAKC,IAAAA,CAAAA;AACvC,IAAA,CAAA,CAAA;;IAGAJ,OAAAA,CAAQpE,IAAI,CACVsF,aAAAA,CAA0DxB,MAAAA,EAAQ;;AAEhEyB,QAAAA,OAAAA,EAAS,OAAO,EAAEhB,GAAG,EAAE,IAAM;AAC3BE,gBAAAA,KAAAA,EAAOF,IAAIE,KAAK;gBAChBe,UAAAA,EAAYjB;aACd;AACF,KAAA,CAAA,CAAA;;IAIFlE,MAAAA,CAAOyD,MAAM,CAAC2B,MAAM,CAAC;AACnB,QAAA;YACEX,MAAAA,EAAQ,KAAA;AACR7C,YAAAA,IAAAA;AACAmC,YAAAA,OAAAA;YACA9D,MAAAA,EAAQ;gBACN8E,IAAAA,EAAM;AACR;AACF;AACD,KAAA,CAAA;;;;AAKD/E,IAAAA,MAAAA,CAAOE,MAAM,CAAC,SAAA,CAAA,CAAWmF,OAAO,GAAG,UAAA;AACjC,QAAA,MAAM5B,OAAO6B,IAAI,EAAA;AACnB,IAAA,CAAA;AACF;;;;"}
|
|
@@ -4,6 +4,11 @@ import type { BaseContext } from 'koa';
|
|
|
4
4
|
type StrapiGraphQLContext = BaseContext & {
|
|
5
5
|
rootQueryArgsByPath?: Map<string | number, Record<string, unknown>>;
|
|
6
6
|
};
|
|
7
|
+
type OperationLimitConfig = {
|
|
8
|
+
depthLimit?: unknown;
|
|
9
|
+
maxLimit?: unknown;
|
|
10
|
+
};
|
|
11
|
+
export declare const getOperationLimitsWarning: ({ depthLimit: configuredDepthLimit, maxLimit, }: OperationLimitConfig) => string | undefined;
|
|
7
12
|
export declare const determineLandingPage: (strapi: Core.Strapi) => ApolloServerPlugin<StrapiGraphQLContext>;
|
|
8
13
|
export declare function bootstrap({ strapi }: {
|
|
9
14
|
strapi: Core.Strapi;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bootstrap.d.ts","sourceRoot":"","sources":["../../../server/src/bootstrap.ts"],"names":[],"mappings":"AACA,OAAO,EAAgB,KAAK,kBAAkB,EAA4B,MAAM,gBAAgB,CAAC;AAUjG,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAE1C,OAAO,KAAK,EAAE,WAAW,EAA8C,MAAM,KAAK,CAAC;AAUnF,KAAK,oBAAoB,GAAG,WAAW,GAAG;IACxC,mBAAmB,CAAC,EAAE,GAAG,CAAC,MAAM,GAAG,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CACrE,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAC/B,QAAQ,IAAI,CAAC,MAAM,KAClB,kBAAkB,CAAC,oBAAoB,CA8EzC,CAAC;AAEF,wBAAsB,SAAS,CAAC,EAAE,MAAM,EAAE,EAAE;IAAE,MAAM,EAAE,IAAI,CAAC,MAAM,CAAA;CAAE,
|
|
1
|
+
{"version":3,"file":"bootstrap.d.ts","sourceRoot":"","sources":["../../../server/src/bootstrap.ts"],"names":[],"mappings":"AACA,OAAO,EAAgB,KAAK,kBAAkB,EAA4B,MAAM,gBAAgB,CAAC;AAUjG,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAE1C,OAAO,KAAK,EAAE,WAAW,EAA8C,MAAM,KAAK,CAAC;AAUnF,KAAK,oBAAoB,GAAG,WAAW,GAAG;IACxC,mBAAmB,CAAC,EAAE,GAAG,CAAC,MAAM,GAAG,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CACrE,CAAC;AAEF,KAAK,oBAAoB,GAAG;IAC1B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,eAAO,MAAM,yBAAyB,GAAI,iDAGvC,oBAAoB,KAAG,MAAM,GAAG,SAoBlC,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAC/B,QAAQ,IAAI,CAAC,MAAM,KAClB,kBAAkB,CAAC,oBAAoB,CA8EzC,CAAC;AAEF,wBAAsB,SAAS,CAAC,EAAE,MAAM,EAAE,EAAE;IAAE,MAAM,EAAE,IAAI,CAAC,MAAM,CAAA;CAAE,iBAoLlE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@strapi/plugin-graphql",
|
|
3
|
-
"version": "5.52.
|
|
3
|
+
"version": "5.52.3",
|
|
4
4
|
"description": "Adds GraphQL endpoint with default API methods.",
|
|
5
5
|
"homepage": "https://strapi.io",
|
|
6
6
|
"bugs": {
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"@koa/cors": "5.0.0",
|
|
68
68
|
"@strapi/design-system": "2.2.4",
|
|
69
69
|
"@strapi/icons": "2.2.4",
|
|
70
|
-
"@strapi/utils": "5.52.
|
|
70
|
+
"@strapi/utils": "5.52.3",
|
|
71
71
|
"graphql": "^16.8.1",
|
|
72
72
|
"graphql-depth-limit": "^1.1.0",
|
|
73
73
|
"graphql-playground-middleware-koa": "^1.6.21",
|
|
@@ -79,25 +79,27 @@
|
|
|
79
79
|
"pluralize": "8.0.0"
|
|
80
80
|
},
|
|
81
81
|
"devDependencies": {
|
|
82
|
-
"@strapi/
|
|
83
|
-
"@strapi/
|
|
82
|
+
"@strapi/admin": "5.52.3",
|
|
83
|
+
"@strapi/strapi": "5.52.3",
|
|
84
|
+
"@strapi/types": "5.52.3",
|
|
84
85
|
"@types/graphql-depth-limit": "1.1.5",
|
|
85
86
|
"@types/jest": "29.5.2",
|
|
86
87
|
"@types/koa-bodyparser": "4.3.12",
|
|
87
88
|
"@types/koa__cors": "5.0.0",
|
|
88
89
|
"@types/node": "20.19.41",
|
|
89
90
|
"cross-env": "^7.0.3",
|
|
90
|
-
"eslint-config-custom": "5.52.
|
|
91
|
+
"eslint-config-custom": "5.52.3",
|
|
91
92
|
"jest": "29.6.0",
|
|
92
93
|
"koa": "2.16.4",
|
|
93
94
|
"react": "18.3.1",
|
|
94
95
|
"react-dom": "18.3.1",
|
|
95
96
|
"react-router-dom": "6.30.4",
|
|
96
97
|
"styled-components": "6.4.1",
|
|
97
|
-
"tsconfig": "5.52.
|
|
98
|
+
"tsconfig": "5.52.3",
|
|
98
99
|
"typescript": "5.9.3"
|
|
99
100
|
},
|
|
100
101
|
"peerDependencies": {
|
|
102
|
+
"@strapi/admin": "^5.0.0",
|
|
101
103
|
"@strapi/strapi": "^5.0.0",
|
|
102
104
|
"react": "^17.0.0 || ^18.0.0",
|
|
103
105
|
"react-dom": "^17.0.0 || ^18.0.0",
|