@strapi/plugin-graphql 5.55.1 → 5.57.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.
Files changed (138) hide show
  1. package/dist/server/bootstrap.js +10 -10
  2. package/dist/server/bootstrap.js.map +1 -1
  3. package/dist/server/bootstrap.mjs +8 -8
  4. package/dist/server/bootstrap.mjs.map +1 -1
  5. package/dist/server/format-graphql-error.js +5 -5
  6. package/dist/server/format-graphql-error.js.map +1 -1
  7. package/dist/server/format-graphql-error.mjs +4 -4
  8. package/dist/server/format-graphql-error.mjs.map +1 -1
  9. package/dist/server/services/builders/dynamic-zones.js +3 -3
  10. package/dist/server/services/builders/dynamic-zones.js.map +1 -1
  11. package/dist/server/services/builders/dynamic-zones.mjs +3 -3
  12. package/dist/server/services/builders/dynamic-zones.mjs.map +1 -1
  13. package/dist/server/services/builders/entity.js +4 -4
  14. package/dist/server/services/builders/entity.js.map +1 -1
  15. package/dist/server/services/builders/entity.mjs +2 -2
  16. package/dist/server/services/builders/entity.mjs.map +1 -1
  17. package/dist/server/services/builders/enums.js +2 -2
  18. package/dist/server/services/builders/enums.js.map +1 -1
  19. package/dist/server/services/builders/enums.mjs +2 -2
  20. package/dist/server/services/builders/enums.mjs.map +1 -1
  21. package/dist/server/services/builders/filters/operators/index.js +3 -3
  22. package/dist/server/services/builders/filters/operators/index.js.map +1 -1
  23. package/dist/server/services/builders/filters/operators/index.mjs +3 -3
  24. package/dist/server/services/builders/filters/operators/index.mjs.map +1 -1
  25. package/dist/server/services/builders/generic-morph.js +1 -2
  26. package/dist/server/services/builders/generic-morph.js.map +1 -1
  27. package/dist/server/services/builders/generic-morph.mjs +1 -2
  28. package/dist/server/services/builders/generic-morph.mjs.map +1 -1
  29. package/dist/server/services/builders/index.js +2 -4
  30. package/dist/server/services/builders/index.js.map +1 -1
  31. package/dist/server/services/builders/index.mjs +2 -4
  32. package/dist/server/services/builders/index.mjs.map +1 -1
  33. package/dist/server/services/builders/relation-response-collection.js +3 -3
  34. package/dist/server/services/builders/relation-response-collection.js.map +1 -1
  35. package/dist/server/services/builders/relation-response-collection.mjs +3 -3
  36. package/dist/server/services/builders/relation-response-collection.mjs.map +1 -1
  37. package/dist/server/services/builders/resolvers/association.js +3 -3
  38. package/dist/server/services/builders/resolvers/association.js.map +1 -1
  39. package/dist/server/services/builders/resolvers/association.mjs +3 -3
  40. package/dist/server/services/builders/resolvers/association.mjs.map +1 -1
  41. package/dist/server/services/builders/resolvers/query.js +3 -3
  42. package/dist/server/services/builders/resolvers/query.js.map +1 -1
  43. package/dist/server/services/builders/resolvers/query.mjs +3 -3
  44. package/dist/server/services/builders/resolvers/query.mjs.map +1 -1
  45. package/dist/server/services/builders/response-collection.js +4 -4
  46. package/dist/server/services/builders/response-collection.js.map +1 -1
  47. package/dist/server/services/builders/response-collection.mjs +3 -3
  48. package/dist/server/services/builders/response-collection.mjs.map +1 -1
  49. package/dist/server/services/builders/response.js +1 -2
  50. package/dist/server/services/builders/response.js.map +1 -1
  51. package/dist/server/services/builders/response.mjs +1 -2
  52. package/dist/server/services/builders/response.mjs.map +1 -1
  53. package/dist/server/services/builders/type.js +4 -4
  54. package/dist/server/services/builders/type.js.map +1 -1
  55. package/dist/server/services/builders/type.mjs +3 -3
  56. package/dist/server/services/builders/type.mjs.map +1 -1
  57. package/dist/server/services/builders/utils.js +6 -6
  58. package/dist/server/services/builders/utils.js.map +1 -1
  59. package/dist/server/services/builders/utils.mjs +6 -6
  60. package/dist/server/services/builders/utils.mjs.map +1 -1
  61. package/dist/server/services/content-api/index.js +1 -2
  62. package/dist/server/services/content-api/index.js.map +1 -1
  63. package/dist/server/services/content-api/index.mjs +1 -2
  64. package/dist/server/services/content-api/index.mjs.map +1 -1
  65. package/dist/server/services/content-api/policy.js +2 -3
  66. package/dist/server/services/content-api/policy.js.map +1 -1
  67. package/dist/server/services/content-api/policy.mjs +2 -3
  68. package/dist/server/services/content-api/policy.mjs.map +1 -1
  69. package/dist/server/services/content-api/wrap-resolvers.js +9 -9
  70. package/dist/server/services/content-api/wrap-resolvers.js.map +1 -1
  71. package/dist/server/services/content-api/wrap-resolvers.mjs +9 -9
  72. package/dist/server/services/content-api/wrap-resolvers.mjs.map +1 -1
  73. package/dist/server/services/extension/extension.js +3 -3
  74. package/dist/server/services/extension/extension.js.map +1 -1
  75. package/dist/server/services/extension/extension.mjs +3 -3
  76. package/dist/server/services/extension/extension.mjs.map +1 -1
  77. package/dist/server/services/internals/helpers/get-enabled-scalars.js +2 -2
  78. package/dist/server/services/internals/helpers/get-enabled-scalars.js.map +1 -1
  79. package/dist/server/services/internals/helpers/get-enabled-scalars.mjs +1 -1
  80. package/dist/server/services/internals/helpers/get-enabled-scalars.mjs.map +1 -1
  81. package/dist/server/services/internals/types/error.js +1 -2
  82. package/dist/server/services/internals/types/error.js.map +1 -1
  83. package/dist/server/services/internals/types/error.mjs +1 -2
  84. package/dist/server/services/internals/types/error.mjs.map +1 -1
  85. package/dist/server/services/type-registry.js +1 -2
  86. package/dist/server/services/type-registry.js.map +1 -1
  87. package/dist/server/services/type-registry.mjs +1 -2
  88. package/dist/server/services/type-registry.mjs.map +1 -1
  89. package/dist/server/services/utils/attributes.js +6 -6
  90. package/dist/server/services/utils/attributes.js.map +1 -1
  91. package/dist/server/services/utils/attributes.mjs +6 -6
  92. package/dist/server/services/utils/attributes.mjs.map +1 -1
  93. package/dist/server/services/utils/mappers/entity-to-response-entity.js +2 -2
  94. package/dist/server/services/utils/mappers/entity-to-response-entity.js.map +1 -1
  95. package/dist/server/services/utils/mappers/entity-to-response-entity.mjs +2 -2
  96. package/dist/server/services/utils/mappers/entity-to-response-entity.mjs.map +1 -1
  97. package/dist/server/services/utils/mappers/graphql-filters-to-strapi-query.js +5 -5
  98. package/dist/server/services/utils/mappers/graphql-filters-to-strapi-query.js.map +1 -1
  99. package/dist/server/services/utils/mappers/graphql-filters-to-strapi-query.mjs +4 -4
  100. package/dist/server/services/utils/mappers/graphql-filters-to-strapi-query.mjs.map +1 -1
  101. package/dist/server/services/utils/mappers/graphql-scalar-to-operators.js +3 -3
  102. package/dist/server/services/utils/mappers/graphql-scalar-to-operators.js.map +1 -1
  103. package/dist/server/services/utils/mappers/graphql-scalar-to-operators.mjs +3 -3
  104. package/dist/server/services/utils/mappers/graphql-scalar-to-operators.mjs.map +1 -1
  105. package/dist/server/services/utils/mappers/strapi-scalar-to-graphql-scalar.js +3 -3
  106. package/dist/server/services/utils/mappers/strapi-scalar-to-graphql-scalar.js.map +1 -1
  107. package/dist/server/services/utils/mappers/strapi-scalar-to-graphql-scalar.mjs +2 -2
  108. package/dist/server/services/utils/mappers/strapi-scalar-to-graphql-scalar.mjs.map +1 -1
  109. package/dist/server/services/utils/naming.js +13 -10
  110. package/dist/server/services/utils/naming.js.map +1 -1
  111. package/dist/server/services/utils/naming.mjs +9 -6
  112. package/dist/server/services/utils/naming.mjs.map +1 -1
  113. package/dist/server/src/bootstrap.d.ts.map +1 -1
  114. package/dist/server/src/index.d.ts +128 -13
  115. package/dist/server/src/index.d.ts.map +1 -1
  116. package/dist/server/src/services/builders/filters/operators/index.d.ts +112 -5
  117. package/dist/server/src/services/builders/filters/operators/index.d.ts.map +1 -1
  118. package/dist/server/src/services/builders/generic-morph.d.ts.map +1 -1
  119. package/dist/server/src/services/builders/index.d.ts +116 -7
  120. package/dist/server/src/services/builders/index.d.ts.map +1 -1
  121. package/dist/server/src/services/builders/resolvers/index.d.ts.map +1 -1
  122. package/dist/server/src/services/builders/response.d.ts.map +1 -1
  123. package/dist/server/src/services/builders/utils.d.ts +3 -1
  124. package/dist/server/src/services/builders/utils.d.ts.map +1 -1
  125. package/dist/server/src/services/content-api/index.d.ts.map +1 -1
  126. package/dist/server/src/services/content-api/policy.d.ts.map +1 -1
  127. package/dist/server/src/services/index.d.ts +128 -13
  128. package/dist/server/src/services/index.d.ts.map +1 -1
  129. package/dist/server/src/services/internals/types/error.d.ts.map +1 -1
  130. package/dist/server/src/services/type-registry.d.ts.map +1 -1
  131. package/dist/server/src/services/utils/index.d.ts +12 -6
  132. package/dist/server/src/services/utils/index.d.ts.map +1 -1
  133. package/dist/server/src/services/utils/mappers/entity-to-response-entity.d.ts +14 -7
  134. package/dist/server/src/services/utils/mappers/entity-to-response-entity.d.ts.map +1 -1
  135. package/dist/server/src/services/utils/mappers/graphql-scalar-to-operators.d.ts.map +1 -1
  136. package/dist/server/src/services/utils/mappers/index.d.ts +12 -6
  137. package/dist/server/src/services/utils/mappers/index.d.ts.map +1 -1
  138. package/package.json +16 -16
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var fp = require('lodash/fp');
3
+ var lodash = require('lodash');
4
4
  var server = require('@apollo/server');
5
5
  var _default = require('@apollo/server/plugin/landingPage/default');
6
6
  var koa = require('@as-integrations/koa');
@@ -15,11 +15,6 @@ var depthLimit__default = /*#__PURE__*/_interopDefault(depthLimit);
15
15
  var bodyParser__default = /*#__PURE__*/_interopDefault(bodyParser);
16
16
  var cors__default = /*#__PURE__*/_interopDefault(cors);
17
17
 
18
- const merge = fp.mergeWith((a, b)=>{
19
- if (fp.isArray(a) && fp.isArray(b)) {
20
- return a.concat(b);
21
- }
22
- });
23
18
  const getOperationLimitsWarning = ({ depthLimit: configuredDepthLimit, maxLimit })=>{
24
19
  const unboundedOrInvalidKeys = [];
25
20
  if (typeof configuredDepthLimit !== 'number' || !Number.isFinite(configuredDepthLimit) || configuredDepthLimit <= 0) {
@@ -87,7 +82,7 @@ const determineLandingPage = (strapi)=>{
87
82
  return isProduction ? prodLanding() : localLanding();
88
83
  }
89
84
  // if user provided a landing page function, return that
90
- if (fp.isFunction(configLandingPage)) {
85
+ if (typeof configLandingPage === 'function') {
91
86
  return userLanding(configLandingPage);
92
87
  }
93
88
  // If no other setting could be found, default to production settings
@@ -97,7 +92,7 @@ const determineLandingPage = (strapi)=>{
97
92
  async function bootstrap({ strapi }) {
98
93
  // Generate the GraphQL schema for the content API
99
94
  const schema = strapi.plugin('graphql').service('content-api').buildSchema();
100
- if (fp.isEmpty(schema)) {
95
+ if (lodash.isEmpty(schema)) {
101
96
  strapi.log.warn('The GraphQL schema has not been generated because it is empty');
102
97
  return;
103
98
  }
@@ -166,7 +161,12 @@ async function bootstrap({ strapi }) {
166
161
  ],
167
162
  cache: 'bounded'
168
163
  };
169
- const serverConfig = merge(defaultServerConfig, config('apolloServer'));
164
+ const serverConfig = lodash.mergeWith({}, defaultServerConfig, config('apolloServer'), (a, b)=>{
165
+ if (Array.isArray(a) && Array.isArray(b)) {
166
+ return a.concat(b);
167
+ }
168
+ return undefined;
169
+ });
170
170
  // Create a new Apollo server
171
171
  const server$1 = new server.ApolloServer(serverConfig);
172
172
  try {
@@ -189,7 +189,7 @@ async function bootstrap({ strapi }) {
189
189
  handler.push(cors__default.default(serverConfig.cors));
190
190
  }
191
191
  // add koa bodyparser middleware
192
- if (fp.isObject(serverConfig.bodyParserConfig)) {
192
+ if (lodash.isObject(serverConfig.bodyParserConfig)) {
193
193
  handler.push(bodyParser__default.default(serverConfig.bodyParserConfig));
194
194
  } else if (serverConfig.bodyParserConfig) {
195
195
  handler.push(bodyParser__default.default());
@@ -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\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,MA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O6B,IAAI,EAAA;AACnB,IAAA,CAAA;AACF;;;;;;"}
1
+ {"version":3,"file":"bootstrap.js","sources":["../../server/src/bootstrap.ts"],"sourcesContent":["import { mergeWith, isEmpty, isObject } from 'lodash';\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\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<\n boolean | ((strapi?: Core.Strapi) => ApolloServerPlugin | boolean)\n >('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 (typeof configLandingPage === 'function') {\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 = mergeWith(\n {},\n defaultServerConfig,\n config('apolloServer'),\n (a: unknown, b: unknown) => {\n if (Array.isArray(a) && Array.isArray(b)) {\n return a.concat(b);\n }\n return undefined;\n }\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":["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","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","mergeWith","a","b","Array","isArray","concat","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":";;;;;;;;;;;;;;;;;AA0BO,MAAMA,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,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GAAAA,EAAKC,IAAAA,CAAAA;AACvC,IAAA,CAAA,CAAA;;IAGAJ,OAAAA,CAAQzE,IAAI,CACV2F,iBAAAA,CAA0DxB,QAAAA,EAAQ;;AAEhEyB,QAAAA,OAAAA,EAAS,OAAO,EAAEhB,GAAG,EAAE,IAAM;AAC3BE,gBAAAA,KAAAA,EAAOF,IAAIE,KAAK;gBAChBe,UAAAA,EAAYjB;aACd;AACF,KAAA,CAAA,CAAA;;IAIFvE,MAAAA,CAAO8D,MAAM,CAAC2B,MAAM,CAAC;AACnB,QAAA;YACEX,MAAAA,EAAQ,KAAA;AACRnD,YAAAA,IAAAA;AACAyC,YAAAA,OAAAA;YACAnE,MAAAA,EAAQ;gBACNmF,IAAAA,EAAM;AACR;AACF;AACD,KAAA,CAAA;;;;AAKDpF,IAAAA,MAAAA,CAAOE,MAAM,CAAC,SAAA,CAAA,CAAWwF,OAAO,GAAG,UAAA;AACjC,QAAA,MAAM5B,SAAO6B,IAAI,EAAA;AACnB,IAAA,CAAA;AACF;;;;;;"}
@@ -1,4 +1,4 @@
1
- import { mergeWith, isArray, isEmpty, isObject, isFunction } from 'lodash/fp';
1
+ import { isEmpty, mergeWith, isObject } from 'lodash';
2
2
  import { ApolloServer } from '@apollo/server';
3
3
  import { ApolloServerPluginLandingPageLocalDefault, ApolloServerPluginLandingPageProductionDefault } from '@apollo/server/plugin/landingPage/default';
4
4
  import { koaMiddleware } from '@as-integrations/koa';
@@ -7,11 +7,6 @@ import bodyParser from 'koa-bodyparser';
7
7
  import cors from '@koa/cors';
8
8
  import { formatGraphqlError } from './format-graphql-error.mjs';
9
9
 
10
- const merge = mergeWith((a, b)=>{
11
- if (isArray(a) && isArray(b)) {
12
- return a.concat(b);
13
- }
14
- });
15
10
  const getOperationLimitsWarning = ({ depthLimit: configuredDepthLimit, maxLimit })=>{
16
11
  const unboundedOrInvalidKeys = [];
17
12
  if (typeof configuredDepthLimit !== 'number' || !Number.isFinite(configuredDepthLimit) || configuredDepthLimit <= 0) {
@@ -79,7 +74,7 @@ const determineLandingPage = (strapi)=>{
79
74
  return isProduction ? prodLanding() : localLanding();
80
75
  }
81
76
  // if user provided a landing page function, return that
82
- if (isFunction(configLandingPage)) {
77
+ if (typeof configLandingPage === 'function') {
83
78
  return userLanding(configLandingPage);
84
79
  }
85
80
  // If no other setting could be found, default to production settings
@@ -158,7 +153,12 @@ async function bootstrap({ strapi }) {
158
153
  ],
159
154
  cache: 'bounded'
160
155
  };
161
- const serverConfig = merge(defaultServerConfig, config('apolloServer'));
156
+ const serverConfig = mergeWith({}, defaultServerConfig, config('apolloServer'), (a, b)=>{
157
+ if (Array.isArray(a) && Array.isArray(b)) {
158
+ return a.concat(b);
159
+ }
160
+ return undefined;
161
+ });
162
162
  // Create a new Apollo server
163
163
  const server = new ApolloServer(serverConfig);
164
164
  try {
@@ -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\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","isEnab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AEA,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;;;;"}
1
+ {"version":3,"file":"bootstrap.mjs","sources":["../../server/src/bootstrap.ts"],"sourcesContent":["import { mergeWith, isEmpty, isObject } from 'lodash';\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\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<\n boolean | ((strapi?: Core.Strapi) => ApolloServerPlugin | boolean)\n >('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 (typeof configLandingPage === 'function') {\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 = mergeWith(\n {},\n defaultServerConfig,\n config('apolloServer'),\n (a: unknown, b: unknown) => {\n if (Array.isArray(a) && Array.isArray(b)) {\n return a.concat(b);\n }\n return undefined;\n }\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":["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","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","mergeWith","a","b","Array","isArray","concat","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":";;;;;;;;;AA0BO,MAAMA,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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IE,KAAK;gBAChBe,UAAAA,EAAYjB;aACd;AACF,KAAA,CAAA,CAAA;;IAIFvE,MAAAA,CAAO8D,MAAM,CAAC2B,MAAM,CAAC;AACnB,QAAA;YACEX,MAAAA,EAAQ,KAAA;AACRnD,YAAAA,IAAAA;AACAyC,YAAAA,OAAAA;YACAnE,MAAAA,EAAQ;gBACNmF,IAAAA,EAAM;AACR;AACF;AACD,KAAA,CAAA;;;;AAKDpF,IAAAA,MAAAA,CAAOE,MAAM,CAAC,SAAA,CAAA,CAAWwF,OAAO,GAAG,UAAA;AACjC,QAAA,MAAM5B,OAAO6B,IAAI,EAAA;AACnB,IAAA,CAAA;AACF;;;;"}
@@ -1,18 +1,18 @@
1
1
  'use strict';
2
2
 
3
- var fp = require('lodash/fp');
3
+ var lodash = require('lodash');
4
4
  var utils = require('@strapi/utils');
5
5
  var errors = require('@apollo/server/errors');
6
6
  var graphql = require('graphql');
7
7
 
8
8
  const { HttpError, ForbiddenError, UnauthorizedError, ApplicationError, ValidationError } = utils.errors;
9
- const formatToCode = (name)=>`STRAPI_${fp.toUpper(fp.snakeCase(name))}`;
9
+ const formatToCode = (name)=>`STRAPI_${lodash.snakeCase(name).toUpperCase()}`;
10
10
  const formatErrorToExtension = (error)=>({
11
- error: fp.pick([
11
+ error: lodash.pick(error, [
12
12
  'name',
13
13
  'message',
14
14
  'details'
15
- ])(error)
15
+ ])
16
16
  });
17
17
  function createFormattedError(formattedError, message, code, originalError) {
18
18
  const options = {
@@ -32,7 +32,7 @@ function createFormattedError(formattedError, message, code, originalError) {
32
32
  */ function formatGraphqlError(formattedError, error) {
33
33
  const originalError = errors.unwrapResolverError(error);
34
34
  // If this error doesn't have an associated originalError, it
35
- if (fp.isEmpty(originalError)) {
35
+ if (lodash.isEmpty(originalError)) {
36
36
  return formattedError;
37
37
  }
38
38
  const { message = '', name = 'UNKNOWN' } = originalError;
@@ -1 +1 @@
1
- {"version":3,"file":"format-graphql-error.js","sources":["../../server/src/format-graphql-error.ts"],"sourcesContent":["import { toUpper, snakeCase, pick, isEmpty } from 'lodash/fp';\nimport { errors } from '@strapi/utils';\nimport { unwrapResolverError } from '@apollo/server/errors';\nimport { GraphQLError, type GraphQLFormattedError } from 'graphql';\n\nconst { HttpError, ForbiddenError, UnauthorizedError, ApplicationError, ValidationError } = errors;\n\nconst formatToCode = (name: string) => `STRAPI_${toUpper(snakeCase(name))}`;\nconst formatErrorToExtension = (error: any) => ({\n error: pick(['name', 'message', 'details'])(error),\n});\n\nfunction createFormattedError(\n formattedError: GraphQLFormattedError,\n message: string,\n code: string,\n originalError: unknown\n) {\n const options = {\n ...formattedError,\n extensions: {\n ...formattedError.extensions,\n ...formatErrorToExtension(originalError),\n code,\n },\n };\n\n return new GraphQLError(message, options);\n}\n\n/**\n * The handler for Apollo Server v4's formatError config option\n *\n * Intercepts specific Strapi error types to send custom error response codes in the GraphQL response\n */\nexport function formatGraphqlError(formattedError: GraphQLFormattedError, error: unknown) {\n const originalError = unwrapResolverError(error);\n\n // If this error doesn't have an associated originalError, it\n if (isEmpty(originalError)) {\n return formattedError;\n }\n\n const { message = '', name = 'UNKNOWN' } = originalError as Error;\n\n if (originalError instanceof ForbiddenError || originalError instanceof UnauthorizedError) {\n return createFormattedError(formattedError, message, 'FORBIDDEN', originalError);\n }\n\n if (originalError instanceof ValidationError) {\n return createFormattedError(formattedError, message, 'BAD_USER_INPUT', originalError);\n }\n\n if (originalError instanceof ApplicationError || originalError instanceof HttpError) {\n const errorName = formatToCode(name);\n return createFormattedError(formattedError, message, errorName, originalError);\n }\n\n if (originalError instanceof GraphQLError) {\n return formattedError;\n }\n\n // else if originalError doesn't appear to be from Strapi or GraphQL..\n\n // Log the error\n strapi.log.error(originalError);\n\n // Create a generic 500 to send so we don't risk leaking any data\n return createFormattedError(\n new GraphQLError('Internal Server Error'),\n 'Internal Server Error',\n 'INTERNAL_SERVER_ERROR',\n originalError\n );\n}\n"],"names":["HttpError","ForbiddenError","UnauthorizedError","ApplicationError","ValidationError","errors","formatToCode","name","toUpper","snakeCase","formatErrorToExtension","error","pick","createFormattedError","formattedError","message","code","originalError","options","extensions","GraphQLError","formatGraphqlError","unwrapResolverError","isEmpty","errorName","strapi","log"],"mappings":";;;;;;;AAKA,MAAM,EAAEA,SAAS,EAAEC,cAAc,EAAEC,iBAAiB,EAAEC,gBAAgB,EAAEC,eAAe,EAAE,GAAGC,YAAAA;AAE5F,MAAMC,YAAAA,GAAe,CAACC,IAAAA,GAAiB,CAAC,OAAO,EAAEC,UAAAA,CAAQC,aAAUF,IAAAA,CAAAA,CAAAA,CAAAA,CAAQ;AAC3E,MAAMG,sBAAAA,GAAyB,CAACC,KAAAA,IAAgB;AAC9CA,QAAAA,KAAAA,EAAOC,OAAAA,CAAK;AAAC,YAAA,MAAA;AAAQ,YAAA,SAAA;AAAW,YAAA;SAAU,CAAA,CAAED,KAAAA;KAC9C,CAAA;AAEA,SAASE,qBACPC,cAAqC,EACrCC,OAAe,EACfC,IAAY,EACZC,aAAsB,EAAA;AAEtB,IAAA,MAAMC,OAAAA,GAAU;AACd,QAAA,GAAGJ,cAAc;QACjBK,UAAAA,EAAY;AACV,YAAA,GAAGL,eAAeK,UAAU;AAC5B,YAAA,GAAGT,uBAAuBO,aAAAA,CAAc;AACxCD,YAAAA;AACF;AACF,KAAA;IAEA,OAAO,IAAII,qBAAaL,OAAAA,EAASG,OAAAA,CAAAA;AACnC;AAEA;;;;AAIC,IACM,SAASG,kBAAAA,CAAmBP,cAAqC,EAAEH,KAAc,EAAA;AACtF,IAAA,MAAMM,gBAAgBK,0BAAAA,CAAoBX,KAAAA,CAAAA;;AAG1C,IAAA,IAAIY,WAAQN,aAAAA,CAAAA,EAAgB;QAC1B,OAAOH,cAAAA;AACT,IAAA;AAEA,IAAA,MAAM,EAAEC,OAAAA,GAAU,EAAE,EAAER,IAAAA,GAAO,SAAS,EAAE,GAAGU,aAAAA;IAE3C,IAAIA,aAAAA,YAAyBhB,cAAAA,IAAkBgB,aAAAA,YAAyBf,iBAAAA,EAAmB;QACzF,OAAOW,oBAAAA,CAAqBC,cAAAA,EAAgBC,OAAAA,EAAS,WAAA,EAAaE,aAAAA,CAAAA;AACpE,IAAA;AAEA,IAAA,IAAIA,yBAAyBb,eAAAA,EAAiB;QAC5C,OAAOS,oBAAAA,CAAqBC,cAAAA,EAAgBC,OAAAA,EAAS,gBAAA,EAAkBE,aAAAA,CAAAA;AACzE,IAAA;IAEA,IAAIA,aAAAA,YAAyBd,gBAAAA,IAAoBc,aAAAA,YAAyBjB,SAAAA,EAAW;AACnF,QAAA,MAAMwB,YAAYlB,YAAAA,CAAaC,IAAAA,CAAAA;QAC/B,OAAOM,oBAAAA,CAAqBC,cAAAA,EAAgBC,OAAAA,EAASS,SAAAA,EAAWP,aAAAA,CAAAA;AAClE,IAAA;AAEA,IAAA,IAAIA,yBAAyBG,oBAAAA,EAAc;QACzC,OAAON,cAAAA;AACT,IAAA;;;IAKAW,MAAAA,CAAOC,GAAG,CAACf,KAAK,CAACM,aAAAA,CAAAA;;AAGjB,IAAA,OAAOJ,oBAAAA,CACL,IAAIO,oBAAAA,CAAa,uBAAA,CAAA,EACjB,yBACA,uBAAA,EACAH,aAAAA,CAAAA;AAEJ;;;;"}
1
+ {"version":3,"file":"format-graphql-error.js","sources":["../../server/src/format-graphql-error.ts"],"sourcesContent":["import { snakeCase, pick, isEmpty } from 'lodash';\nimport { errors } from '@strapi/utils';\nimport { unwrapResolverError } from '@apollo/server/errors';\nimport { GraphQLError, type GraphQLFormattedError } from 'graphql';\n\nconst { HttpError, ForbiddenError, UnauthorizedError, ApplicationError, ValidationError } = errors;\n\nconst formatToCode = (name: string) => `STRAPI_${snakeCase(name).toUpperCase()}`;\nconst formatErrorToExtension = (error: any) => ({\n error: pick(error, ['name', 'message', 'details']),\n});\n\nfunction createFormattedError(\n formattedError: GraphQLFormattedError,\n message: string,\n code: string,\n originalError: unknown\n) {\n const options = {\n ...formattedError,\n extensions: {\n ...formattedError.extensions,\n ...formatErrorToExtension(originalError),\n code,\n },\n };\n\n return new GraphQLError(message, options);\n}\n\n/**\n * The handler for Apollo Server v4's formatError config option\n *\n * Intercepts specific Strapi error types to send custom error response codes in the GraphQL response\n */\nexport function formatGraphqlError(formattedError: GraphQLFormattedError, error: unknown) {\n const originalError = unwrapResolverError(error);\n\n // If this error doesn't have an associated originalError, it\n if (isEmpty(originalError)) {\n return formattedError;\n }\n\n const { message = '', name = 'UNKNOWN' } = originalError as Error;\n\n if (originalError instanceof ForbiddenError || originalError instanceof UnauthorizedError) {\n return createFormattedError(formattedError, message, 'FORBIDDEN', originalError);\n }\n\n if (originalError instanceof ValidationError) {\n return createFormattedError(formattedError, message, 'BAD_USER_INPUT', originalError);\n }\n\n if (originalError instanceof ApplicationError || originalError instanceof HttpError) {\n const errorName = formatToCode(name);\n return createFormattedError(formattedError, message, errorName, originalError);\n }\n\n if (originalError instanceof GraphQLError) {\n return formattedError;\n }\n\n // else if originalError doesn't appear to be from Strapi or GraphQL..\n\n // Log the error\n strapi.log.error(originalError);\n\n // Create a generic 500 to send so we don't risk leaking any data\n return createFormattedError(\n new GraphQLError('Internal Server Error'),\n 'Internal Server Error',\n 'INTERNAL_SERVER_ERROR',\n originalError\n );\n}\n"],"names":["HttpError","ForbiddenError","UnauthorizedError","ApplicationError","ValidationError","errors","formatToCode","name","snakeCase","toUpperCase","formatErrorToExtension","error","pick","createFormattedError","formattedError","message","code","originalError","options","extensions","GraphQLError","formatGraphqlError","unwrapResolverError","isEmpty","errorName","strapi","log"],"mappings":";;;;;;;AAKA,MAAM,EAAEA,SAAS,EAAEC,cAAc,EAAEC,iBAAiB,EAAEC,gBAAgB,EAAEC,eAAe,EAAE,GAAGC,YAAAA;AAE5F,MAAMC,YAAAA,GAAe,CAACC,IAAAA,GAAiB,CAAC,OAAO,EAAEC,gBAAAA,CAAUD,IAAAA,CAAAA,CAAME,WAAW,EAAA,CAAA,CAAI;AAChF,MAAMC,sBAAAA,GAAyB,CAACC,KAAAA,IAAgB;A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AAA,EAAgBC,OAAAA,EAASS,SAAAA,EAAWP,aAAAA,CAAAA;AAClE,IAAA;AAEA,IAAA,IAAIA,yBAAyBG,oBAAAA,EAAc;QACzC,OAAON,cAAAA;AACT,IAAA;;;IAKAW,MAAAA,CAAOC,GAAG,CAACf,KAAK,CAACM,aAAAA,CAAAA;;AAGjB,IAAA,OAAOJ,oBAAAA,CACL,IAAIO,oBAAAA,CAAa,uBAAA,CAAA,EACjB,yBACA,uBAAA,EACAH,aAAAA,CAAAA;AAEJ;;;;"}
@@ -1,16 +1,16 @@
1
- import { isEmpty, toUpper, snakeCase, pick } from 'lodash/fp';
1
+ import { isEmpty, snakeCase, pick } from 'lodash';
2
2
  import { errors } from '@strapi/utils';
3
3
  import { unwrapResolverError } from '@apollo/server/errors';
4
4
  import { GraphQLError } from 'graphql';
5
5
 
6
6
  const { HttpError, ForbiddenError, UnauthorizedError, ApplicationError, ValidationError } = errors;
7
- const formatToCode = (name)=>`STRAPI_${toUpper(snakeCase(name))}`;
7
+ const formatToCode = (name)=>`STRAPI_${snakeCase(name).toUpperCase()}`;
8
8
  const formatErrorToExtension = (error)=>({
9
- error: pick([
9
+ error: pick(error, [
10
10
  'name',
11
11
  'message',
12
12
  'details'
13
- ])(error)
13
+ ])
14
14
  });
15
15
  function createFormattedError(formattedError, message, code, originalError) {
16
16
  const options = {
@@ -1 +1 @@
1
- {"version":3,"file":"format-graphql-error.mjs","sources":["../../server/src/format-graphql-error.ts"],"sourcesContent":["import { toUpper, snakeCase, pick, isEmpty } from 'lodash/fp';\nimport { errors } from '@strapi/utils';\nimport { unwrapResolverError } from '@apollo/server/errors';\nimport { GraphQLError, type GraphQLFormattedError } from 'graphql';\n\nconst { HttpError, ForbiddenError, UnauthorizedError, ApplicationError, ValidationError } = errors;\n\nconst formatToCode = (name: string) => `STRAPI_${toUpper(snakeCase(name))}`;\nconst formatErrorToExtension = (error: any) => ({\n error: pick(['name', 'message', 'details'])(error),\n});\n\nfunction createFormattedError(\n formattedError: GraphQLFormattedError,\n message: string,\n code: string,\n originalError: unknown\n) {\n const options = {\n ...formattedError,\n extensions: {\n ...formattedError.extensions,\n ...formatErrorToExtension(originalError),\n code,\n },\n };\n\n return new GraphQLError(message, options);\n}\n\n/**\n * The handler for Apollo Server v4's formatError config option\n *\n * Intercepts specific Strapi error types to send custom error response codes in the GraphQL response\n */\nexport function formatGraphqlError(formattedError: GraphQLFormattedError, error: unknown) {\n const originalError = unwrapResolverError(error);\n\n // If this error doesn't have an associated originalError, it\n if (isEmpty(originalError)) {\n return formattedError;\n }\n\n const { message = '', name = 'UNKNOWN' } = originalError as Error;\n\n if (originalError instanceof ForbiddenError || originalError instanceof UnauthorizedError) {\n return createFormattedError(formattedError, message, 'FORBIDDEN', originalError);\n }\n\n if (originalError instanceof ValidationError) {\n return createFormattedError(formattedError, message, 'BAD_USER_INPUT', originalError);\n }\n\n if (originalError instanceof ApplicationError || originalError instanceof HttpError) {\n const errorName = formatToCode(name);\n return createFormattedError(formattedError, message, errorName, originalError);\n }\n\n if (originalError instanceof GraphQLError) {\n return formattedError;\n }\n\n // else if originalError doesn't appear to be from Strapi or GraphQL..\n\n // Log the error\n strapi.log.error(originalError);\n\n // Create a generic 500 to send so we don't risk leaking any data\n return createFormattedError(\n new GraphQLError('Internal Server Error'),\n 'Internal Server Error',\n 'INTERNAL_SERVER_ERROR',\n originalError\n );\n}\n"],"names":["HttpError","ForbiddenError","UnauthorizedError","ApplicationError","ValidationError","errors","formatToCode","name","toUpper","snakeCase","formatErrorToExtension","error","pick","createFormattedError","formattedError","message","code","originalError","options","extensions","GraphQLError","formatGraphqlError","unwrapResolverError","isEmpty","errorName","strapi","log"],"mappings":";;;;;AAKA,MAAM,EAAEA,SAAS,EAAEC,cAAc,EAAEC,iBAAiB,EAAEC,gBAAgB,EAAEC,eAAe,EAAE,GAAGC,MAAAA;AAE5F,MAAMC,YAAAA,GAAe,CAACC,IAAAA,GAAiB,CAAC,OAAO,EAAEC,OAAAA,CAAQC,U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A,EAAW;AACnF,QAAA,MAAMwB,YAAYlB,YAAAA,CAAaC,IAAAA,CAAAA;QAC/B,OAAOM,oBAAAA,CAAqBC,cAAAA,EAAgBC,OAAAA,EAASS,SAAAA,EAAWP,aAAAA,CAAAA;AAClE,IAAA;AAEA,IAAA,IAAIA,yBAAyBG,YAAAA,EAAc;QACzC,OAAON,cAAAA;AACT,IAAA;;;IAKAW,MAAAA,CAAOC,GAAG,CAACf,KAAK,CAACM,aAAAA,CAAAA;;AAGjB,IAAA,OAAOJ,oBAAAA,CACL,IAAIO,YAAAA,CAAa,uBAAA,CAAA,EACjB,yBACA,uBAAA,EACAH,aAAAA,CAAAA;AAEJ;;;;"}
1
+ {"version":3,"file":"format-graphql-error.mjs","sources":["../../server/src/format-graphql-error.ts"],"sourcesContent":["import { snakeCase, pick, isEmpty } from 'lodash';\nimport { errors } from '@strapi/utils';\nimport { unwrapResolverError } from '@apollo/server/errors';\nimport { GraphQLError, type GraphQLFormattedError } from 'graphql';\n\nconst { HttpError, ForbiddenError, UnauthorizedError, ApplicationError, ValidationError } = errors;\n\nconst formatToCode = (name: string) => `STRAPI_${snakeCase(name).toUpperCase()}`;\nconst formatErrorToExtension = (error: any) => ({\n error: pick(error, ['name', 'message', 'details']),\n});\n\nfunction createFormattedError(\n formattedError: GraphQLFormattedError,\n message: string,\n code: string,\n originalError: unknown\n) {\n const options = {\n ...formattedError,\n extensions: {\n ...formattedError.extensions,\n ...formatErrorToExtension(originalError),\n code,\n },\n };\n\n return new GraphQLError(message, options);\n}\n\n/**\n * The handler for Apollo Server v4's formatError config option\n *\n * Intercepts specific Strapi error types to send custom error response codes in the GraphQL response\n */\nexport function formatGraphqlError(formattedError: GraphQLFormattedError, error: unknown) {\n const originalError = unwrapResolverError(error);\n\n // If this error doesn't have an associated originalError, it\n if (isEmpty(originalError)) {\n return formattedError;\n }\n\n const { message = '', name = 'UNKNOWN' } = originalError as Error;\n\n if (originalError instanceof ForbiddenError || originalError instanceof UnauthorizedError) {\n return createFormattedError(formattedError, message, 'FORBIDDEN', originalError);\n }\n\n if (originalError instanceof ValidationError) {\n return createFormattedError(formattedError, message, 'BAD_USER_INPUT', originalError);\n }\n\n if (originalError instanceof ApplicationError || originalError instanceof HttpError) {\n const errorName = formatToCode(name);\n return createFormattedError(formattedError, message, errorName, originalError);\n }\n\n if (originalError instanceof GraphQLError) {\n return formattedError;\n }\n\n // else if originalError doesn't appear to be from Strapi or GraphQL..\n\n // Log the error\n strapi.log.error(originalError);\n\n // Create a generic 500 to send so we don't risk leaking any data\n return createFormattedError(\n new GraphQLError('Internal Server Error'),\n 'Internal Server Error',\n 'INTERNAL_SERVER_ERROR',\n originalError\n );\n}\n"],"names":["HttpError","ForbiddenError","UnauthorizedError","ApplicationError","ValidationError","errors","formatToCode","name","snakeCase","toUpperCase","formatErrorToExtension","error","pick","createFormattedError","formattedError","message","code","originalError","options","extensions","GraphQLError","formatGraphqlError","unwrapResolverError","isEmpty","errorName","strapi","log"],"mappings":";;;;;AAKA,MAAM,EAAEA,SAAS,EAAEC,cAAc,EAAEC,iBAAiB,EAAEC,gBAAgB,EAAEC,eAAe,EAAE,GAAGC,MAAAA;AAE5F,MAAMC,YAAAA,GAAe,CAACC,IAAAA,GAAiB,CAAC,OAAO,EAAEC,SAAAA,CAAUD,IAAAA,CAAAA,CAAME,WAAW,EAAA,CAAA,CAAI;AAChF,MAAMC,sBAAAA,GAAyB,CAACC,KAAAA,IAAgB;AAC9CA,QAAAA,KAAAA,EAAOC,KAAKD,KAAAA,EAAO;AAAC,YAAA,MAAA;AAAQ,YAAA,SAAA;AAAW,YAAA;AAAU,SAAA;KACnD,CAAA;AAEA,SAASE,qBACPC,cAAqC,EACrCC,OAAe,EACfC,IAAY,EACZC,aAAsB,EAAA;AAEtB,IAAA,MAAMC,OAAAA,GAAU;AACd,QAAA,GAAGJ,cAAc;QACjBK,UAAAA,EAAY;AACV,YAAA,GAAGL,eAAeK,UAAU;AAC5B,YAAA,GAAGT,uBAAuBO,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+1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var graphql = require('graphql');
4
- var fp = require('lodash/fp');
4
+ var lodash = require('lodash');
5
5
  var nexus = require('nexus');
6
6
  var utils = require('@strapi/utils');
7
7
 
@@ -38,9 +38,9 @@ var dynamicZone = (({ strapi })=>{
38
38
  }
39
39
  return {
40
40
  __component: component.uid,
41
- ...fp.omit([
41
+ ...lodash.omit(value, [
42
42
  '__typename'
43
- ], value)
43
+ ])
44
44
  };
45
45
  };
46
46
  return nexus.scalarType({
@@ -1 +1 @@
1
- {"version":3,"file":"dynamic-zones.js","sources":["../../../../server/src/services/builders/dynamic-zones.ts"],"sourcesContent":["import { Kind, valueFromASTUntyped } from 'graphql';\nimport { omit } from 'lodash/fp';\nimport { unionType, scalarType } from 'nexus';\nimport { errors } from '@strapi/utils';\nimport type { Internal, Schema } from '@strapi/types';\n\nimport type { Context } from '../types';\n\nconst { ApplicationError } = errors;\n\nexport default ({ strapi }: Context) => {\n const buildTypeDefinition = (name: string, components: Internal.UID.Component[]) => {\n const { ERROR_TYPE_NAME } = strapi.plugin('graphql').service('constants');\n const isEmpty = components.length === 0;\n\n const componentsTypeNames = components.map((componentUID) => {\n const component = strapi.components[componentUID];\n\n if (!component) {\n throw new ApplicationError(\n `Trying to create a dynamic zone type with an unknown component: \"${componentUID}\"`\n );\n }\n\n return component.globalId;\n });\n\n return unionType({\n name,\n\n resolveType(obj) {\n if (isEmpty) {\n return ERROR_TYPE_NAME;\n }\n\n return strapi.components[obj.__component].globalId;\n },\n\n definition(t) {\n t.members(...componentsTypeNames, ERROR_TYPE_NAME);\n },\n });\n };\n\n const buildInputDefinition = (name: string, components: Internal.UID.Component[]) => {\n const parseData = (value: any) => {\n const component = Object.values(strapi.components).find(\n (component) => component.globalId === value.__typename\n );\n\n if (!component) {\n throw new ApplicationError(\n `Component not found. expected one of: ${components\n .map((uid) => strapi.components[uid].globalId)\n .join(', ')}`\n );\n }\n\n return {\n __component: component.uid,\n ...omit(['__typename'], value),\n };\n };\n\n return scalarType({\n name,\n\n serialize: (value) => value,\n\n parseValue: (value) => parseData(value),\n\n parseLiteral(ast, variables) {\n if (ast.kind !== Kind.OBJECT) {\n return undefined;\n }\n\n const value = valueFromASTUntyped(ast, variables);\n return parseData(value);\n },\n });\n };\n\n return {\n /**\n * Build a Nexus dynamic zone type from a Strapi dz attribute\n */\n buildDynamicZoneDefinition(\n definition: Schema.Attribute.DynamicZone,\n name: string,\n inputName: string\n ) {\n const { components } = definition;\n\n const typeDefinition = buildTypeDefinition(name, components);\n const inputDefinition = buildInputDefinition(inputName, components);\n\n return [typeDefinition, inputDefinition];\n },\n };\n};\n"],"names":["ApplicationError","errors","strapi","buildTypeDefinition","name","components","ERROR_TYPE_NAME","plugin","service","isEmpty","length","componentsTypeNames","map","componentUID","component","globalId","unionType","resolveType","obj","__component","definition","t","members","buildInputDefinition","parseData","value","Object","values","find","__typename","uid","join","omit","scalarType","serialize","parseValue","parseLiteral","ast","variables","kind","Kind","OBJECT","undefined","valueFromASTUntyped","buildDynamicZoneDefinition","inputName","typeDefinition","inputDefinition"],"mappings":";;;;;;;AAQA,MAAM,EAAEA,gBAAgB,EAAE,GAAGC,YAAAA;AAE7B,kBAAe,CAAA,CAAC,EAAEC,MAAM,EAAW,GAAA;IACjC,MAAMC,mBAAAA,GAAsB,CAACC,IAAAA,EAAcC,UAAAA,GAAAA;QACzC,MAAM,EAAEC,eAAe,EAAE,GAAGJ,OAAOK,MAAM,CAAC,SAAA,CAAA,CAAWC,OAAO,CAAC,WAAA,CAAA;QAC7D,MAAMC,OAAAA,GAAUJ,UAAAA,CAAWK,MAAM,KAAK,CAAA;AAEtC,QAAA,MAAMC,mBAAAA,GAAsBN,UAAAA,CAAWO,GAAG,CAAC,CAACC,YAAAA,GAAAA;AAC1C,YAAA,MAAMC,SAAAA,GAAYZ,MAAAA,CAAOG,UAAU,CAACQ,YAAAA,CAAa;AAEjD,YAAA,IAAI,CAACC,SAAAA,EAAW;AACd,gBAAA,M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AAA,EAAEP,KAAAA;AAC1B,aAAA;AACF,QAAA,CAAA;AAEA,QAAA,OAAOQ,gBAAAA,CAAW;AAChB7B,YAAAA,IAAAA;AAEA8B,YAAAA,SAAAA,EAAW,CAACT,KAAAA,GAAUA,KAAAA;YAEtBU,UAAAA,EAAY,CAACV,QAAUD,SAAAA,CAAUC,KAAAA,CAAAA;YAEjCW,YAAAA,CAAAA,CAAaC,GAAG,EAAEC,SAAS,EAAA;AACzB,gBAAA,IAAID,GAAAA,CAAIE,IAAI,KAAKC,YAAAA,CAAKC,MAAM,EAAE;oBAC5B,OAAOC,SAAAA;AACT,gBAAA;gBAEA,MAAMjB,KAAAA,GAAQkB,4BAAoBN,GAAAA,EAAKC,SAAAA,CAAAA;AACvC,gBAAA,OAAOd,SAAAA,CAAUC,KAAAA,CAAAA;AACnB,YAAA;AACF,SAAA,CAAA;AACF,IAAA,CAAA;IAEA,OAAO;AACL;;AAEC,QACDmB,0BAAAA,CAAAA,CACExB,UAAwC,EACxChB,IAAY,EACZyC,SAAiB,EAAA;YAEjB,MAAM,EAAExC,UAAU,EAAE,GAAGe,UAAAA;YAEvB,MAAM0B,cAAAA,GAAiB3C,oBAAoBC,IAAAA,EAAMC,UAAAA,CAAAA;YACjD,MAAM0C,eAAAA,GAAkBxB,qBAAqBsB,SAAAA,EAAWxC,UAAAA,CAAAA;YAExD,OAAO;AAACyC,gBAAAA,cAAAA;AAAgBC,gBAAAA;AAAgB,aAAA;AAC1C,QAAA;AACF,KAAA;AACF,CAAA;;;;"}
1
+ {"version":3,"file":"dynamic-zones.js","sources":["../../../../server/src/services/builders/dynamic-zones.ts"],"sourcesContent":["import { Kind, valueFromASTUntyped } from 'graphql';\nimport { omit } from 'lodash';\nimport { unionType, scalarType } from 'nexus';\nimport { errors } from '@strapi/utils';\nimport type { Internal, Schema } from '@strapi/types';\n\nimport type { Context } from '../types';\n\nconst { ApplicationError } = errors;\n\nexport default ({ strapi }: Context) => {\n const buildTypeDefinition = (name: string, components: Internal.UID.Component[]) => {\n const { ERROR_TYPE_NAME } = strapi.plugin('graphql').service('constants');\n const isEmpty = components.length === 0;\n\n const componentsTypeNames = components.map((componentUID) => {\n const component = strapi.components[componentUID];\n\n if (!component) {\n throw new ApplicationError(\n `Trying to create a dynamic zone type with an unknown component: \"${componentUID}\"`\n );\n }\n\n return component.globalId;\n });\n\n return unionType({\n name,\n\n resolveType(obj) {\n if (isEmpty) {\n return ERROR_TYPE_NAME;\n }\n\n return strapi.components[obj.__component].globalId;\n },\n\n definition(t) {\n t.members(...componentsTypeNames, ERROR_TYPE_NAME);\n },\n });\n };\n\n const buildInputDefinition = (name: string, components: Internal.UID.Component[]) => {\n const parseData = (value: any) => {\n const component = Object.values(strapi.components).find(\n (component) => component.globalId === value.__typename\n );\n\n if (!component) {\n throw new ApplicationError(\n `Component not found. expected one of: ${components\n .map((uid) => strapi.components[uid].globalId)\n .join(', ')}`\n );\n }\n\n return {\n __component: component.uid,\n ...omit(value, ['__typename']),\n };\n };\n\n return scalarType({\n name,\n\n serialize: (value) => value,\n\n parseValue: (value) => parseData(value),\n\n parseLiteral(ast, variables) {\n if (ast.kind !== Kind.OBJECT) {\n return undefined;\n }\n\n const value = valueFromASTUntyped(ast, variables);\n return parseData(value);\n },\n });\n };\n\n return {\n /**\n * Build a Nexus dynamic zone type from a Strapi dz attribute\n */\n buildDynamicZoneDefinition(\n definition: Schema.Attribute.DynamicZone,\n name: string,\n inputName: string\n ) {\n const { components } = definition;\n\n const typeDefinition = buildTypeDefinition(name, components);\n const inputDefinition = buildInputDefinition(inputName, components);\n\n return [typeDefinition, inputDefinition];\n },\n };\n};\n"],"names":["ApplicationError","errors","strapi","buildTypeDefinition","name","components","ERROR_TYPE_NAME","plugin","service","isEmpty","length","componentsTypeNames","map","componentUID","component","globalId","unionType","resolveType","obj","__component","definition","t","members","buildInputDefinition","parseData","value","Object","values","find","__typename","uid","join","omit","scalarType","serialize","parseValue","parseLiteral","ast","variables","kind","Kind","OBJECT","undefined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,SAAiB,EAAA;YAEjB,MAAM,EAAExC,UAAU,EAAE,GAAGe,UAAAA;YAEvB,MAAM0B,cAAAA,GAAiB3C,oBAAoBC,IAAAA,EAAMC,UAAAA,CAAAA;YACjD,MAAM0C,eAAAA,GAAkBxB,qBAAqBsB,SAAAA,EAAWxC,UAAAA,CAAAA;YAExD,OAAO;AAACyC,gBAAAA,cAAAA;AAAgBC,gBAAAA;AAAgB,aAAA;AAC1C,QAAA;AACF,KAAA;AACF,CAAA;;;;"}
@@ -1,5 +1,5 @@
1
1
  import { Kind, valueFromASTUntyped } from 'graphql';
2
- import { omit } from 'lodash/fp';
2
+ import { omit } from 'lodash';
3
3
  import { unionType, scalarType } from 'nexus';
4
4
  import { errors } from '@strapi/utils';
5
5
 
@@ -36,9 +36,9 @@ var dynamicZone = (({ strapi })=>{
36
36
  }
37
37
  return {
38
38
  __component: component.uid,
39
- ...omit([
39
+ ...omit(value, [
40
40
  '__typename'
41
- ], value)
41
+ ])
42
42
  };
43
43
  };
44
44
  return scalarType({
@@ -1 +1 @@
1
- {"version":3,"file":"dynamic-zones.mjs","sources":["../../../../server/src/services/builders/dynamic-zones.ts"],"sourcesContent":["import { Kind, valueFromASTUntyped } from 'graphql';\nimport { omit } from 'lodash/fp';\nimport { unionType, scalarType } from 'nexus';\nimport { errors } from '@strapi/utils';\nimport type { Internal, Schema } from '@strapi/types';\n\nimport type { Context } from '../types';\n\nconst { ApplicationError } = errors;\n\nexport default ({ strapi }: Context) => {\n const buildTypeDefinition = (name: string, components: Internal.UID.Component[]) => {\n const { ERROR_TYPE_NAME } = strapi.plugin('graphql').service('constants');\n const isEmpty = components.length === 0;\n\n const componentsTypeNames = components.map((componentUID) => {\n const component = strapi.components[componentUID];\n\n if (!component) {\n throw new ApplicationError(\n `Trying to create a dynamic zone type with an unknown component: \"${componentUID}\"`\n );\n }\n\n return component.globalId;\n });\n\n return unionType({\n name,\n\n resolveType(obj) {\n if (isEmpty) {\n return ERROR_TYPE_NAME;\n }\n\n return strapi.components[obj.__component].globalId;\n },\n\n definition(t) {\n t.members(...componentsTypeNames, ERROR_TYPE_NAME);\n },\n });\n };\n\n const buildInputDefinition = (name: string, components: Internal.UID.Component[]) => {\n const parseData = (value: any) => {\n const component = Object.values(strapi.components).find(\n (component) => component.globalId === value.__typename\n );\n\n if (!component) {\n throw new ApplicationError(\n `Component not found. expected one of: ${components\n .map((uid) => strapi.components[uid].globalId)\n .join(', ')}`\n );\n }\n\n return {\n __component: component.uid,\n ...omit(['__typename'], value),\n };\n };\n\n return scalarType({\n name,\n\n serialize: (value) => value,\n\n parseValue: (value) => parseData(value),\n\n parseLiteral(ast, variables) {\n if (ast.kind !== Kind.OBJECT) {\n return undefined;\n }\n\n const value = valueFromASTUntyped(ast, variables);\n return parseData(value);\n },\n });\n };\n\n return {\n /**\n * Build a Nexus dynamic zone type from a Strapi dz attribute\n */\n buildDynamicZoneDefinition(\n definition: Schema.Attribute.DynamicZone,\n name: string,\n inputName: string\n ) {\n const { components } = definition;\n\n const typeDefinition = buildTypeDefinition(name, components);\n const inputDefinition = buildInputDefinition(inputName, components);\n\n return [typeDefinition, inputDefinition];\n },\n };\n};\n"],"names":["ApplicationError","errors","strapi","buildTypeDefinition","name","components","ERROR_TYPE_NAME","plugin","service","isEmpty","length","componentsTypeNames","map","componentUID","component","globalId","unionType","resolveType","obj","__component","definition","t","members","buildInputDefinition","parseData","value","Object","values","find","__typename","uid","join","omit","scalarType","serialize","parseValue","parseLiteral","ast","variables","kind","Kind","OBJECT","undefined","valueFromASTUntyped","buildDynamicZoneDefinition","inputName","typeDefinition","inputDefinition"],"mappings":";;;;;AAQA,MAAM,EAAEA,gBAAgB,EAAE,GAAGC,MAAAA;AAE7B,kBAAe,CAAA,CAAC,EAAEC,MAAM,EAAW,GAAA;IACjC,MAAMC,mBAAAA,GAAsB,CAACC,IAAAA,EAAcC,UAAAA,GAAAA;QACzC,MAAM,EAAEC,eAAe,EAAE,GAAGJ,OAAOK,MAAM,CAAC,SA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;AACF,KAAA;AACF,CAAA;;;;"}
1
+ {"version":3,"file":"dynamic-zones.mjs","sources":["../../../../server/src/services/builders/dynamic-zones.ts"],"sourcesContent":["import { Kind, valueFromASTUntyped } from 'graphql';\nimport { omit } from 'lodash';\nimport { unionType, scalarType } from 'nexus';\nimport { errors } from '@strapi/utils';\nimport type { Internal, Schema } from '@strapi/types';\n\nimport type { Context } from '../types';\n\nconst { ApplicationError } = errors;\n\nexport default ({ strapi }: Context) => {\n const buildTypeDefinition = (name: string, components: Internal.UID.Component[]) => {\n const { ERROR_TYPE_NAME } = strapi.plugin('graphql').service('constants');\n const isEmpty = components.length === 0;\n\n const componentsTypeNames = components.map((componentUID) => {\n const component = strapi.components[componentUID];\n\n if (!component) {\n throw new ApplicationError(\n `Trying to create a dynamic zone type with an unknown component: \"${componentUID}\"`\n );\n }\n\n return component.globalId;\n });\n\n return unionType({\n name,\n\n resolveType(obj) {\n if (isEmpty) {\n return ERROR_TYPE_NAME;\n }\n\n return strapi.components[obj.__component].globalId;\n },\n\n definition(t) {\n t.members(...componentsTypeNames, ERROR_TYPE_NAME);\n },\n });\n };\n\n const buildInputDefinition = (name: string, components: Internal.UID.Component[]) => {\n const parseData = (value: any) => {\n const component = Object.values(strapi.components).find(\n (component) => component.globalId === value.__typename\n );\n\n if (!component) {\n throw new ApplicationError(\n `Component not found. expected one of: ${components\n .map((uid) => strapi.components[uid].globalId)\n .join(', ')}`\n );\n }\n\n return {\n __component: component.uid,\n ...omit(value, ['__typename']),\n };\n };\n\n return scalarType({\n name,\n\n serialize: (value) => value,\n\n parseValue: (value) => parseData(value),\n\n parseLiteral(ast, variables) {\n if (ast.kind !== Kind.OBJECT) {\n return undefined;\n }\n\n const value = valueFromASTUntyped(ast, variables);\n return parseData(value);\n },\n });\n };\n\n return {\n /**\n * Build a Nexus dynamic zone type from a Strapi dz attribute\n */\n buildDynamicZoneDefinition(\n definition: Schema.Attribute.DynamicZone,\n name: string,\n inputName: string\n ) {\n const { components } = definition;\n\n const typeDefinition = buildTypeDefinition(name, components);\n const inputDefinition = buildInputDefinition(inputName, components);\n\n return [typeDefinition, inputDefinition];\n },\n };\n};\n"],"names":["ApplicationError","errors","strapi","buildTypeDefinition","name","components","ERROR_TYPE_NAME","plugin","service","isEmpty","length","componentsTypeNames","map","componentUID","component","globalId","unionType","resolveType","obj","__component","definition","t","members","buildInputDefinition","parseData","value","Object","values","find","__typename","uid","join","omit","scalarType","serialize","parseValue","parseLiteral","ast","variables","kind","Kind","OBJECT","undefined","valueFromASTUntyped","buildDynamicZoneDefinition","inputName","typeDefinition","inputDefinition"],"mappings":";;;;;AAQA,MAAM,EAAEA,gBAAgB,EAAE,GAAGC,MAAAA;AAE7B,kBAAe,CAAA,CAAC,EAAEC,MAAM,EAAW,GAAA;IACjC,MAAMC,mBAAAA,GAAsB,CAACC,IAAAA,EAAcC,UAAAA,GAAAA;QACzC,MAAM,EAAEC,eAAe,EAAE,GAAGJ,OAAOK,MAAM,CAAC,SAAA,CAAA,CAAWC,OAAO,CAAC,WAAA,CAAA;QAC7D,MAAMC,OAAAA,GAAUJ,UAAAA,CAAWK,MAAM,KAAK,CAAA;AAEtC,QAAA,MAAMC,mBAAAA,GAAsBN,UAAAA,CAAWO,GAAG,CAAC,CAACC,YAAAA,GAAAA;AAC1C,YAAA,MAAMC,SAAAA,GAAYZ,MAAAA,CAAOG,UAAU,CAACQ,YAAAA,CAAa;AAEjD,YAAA,IAAI,CAACC,SAAAA,EAAW;AACd,gBAAA,MAAM,IAAId,gBAAAA,CACR,CAAC,iEAAiE,EAAEa,YAAAA,CAAa,CAAC,CAAC,CAAA;AAEvF,YAAA;AAEA,YAAA,OAAOC,UAAUC,QAAQ;AAC3B,QAAA,CAAA,CAAA;AAEA,QAAA,OAAOC,SAAAA,CAAU;AACfZ,YAAAA,IAAAA;AAEAa,YAAAA,WAAAA,CAAAA,CAAYC,GAAG,EAAA;AACb,gBAAA,IAAIT,OAAAA,EAAS;oBACX,OAAOH,eAAAA;AAC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,KAAKC,IAAAA,CAAKC,MAAM,EAAE;oBAC5B,OAAOC,SAAAA;AACT,gBAAA;gBAEA,MAAMjB,KAAAA,GAAQkB,oBAAoBN,GAAAA,EAAKC,SAAAA,CAAAA;AACvC,gBAAA,OAAOd,SAAAA,CAAUC,KAAAA,CAAAA;AACnB,YAAA;AACF,SAAA,CAAA;AACF,IAAA,CAAA;IAEA,OAAO;AACL;;AAEC,QACDmB,0BAAAA,CAAAA,CACExB,UAAwC,EACxChB,IAAY,EACZyC,SAAiB,EAAA;YAEjB,MAAM,EAAExC,UAAU,EAAE,GAAGe,UAAAA;YAEvB,MAAM0B,cAAAA,GAAiB3C,oBAAoBC,IAAAA,EAAMC,UAAAA,CAAAA;YACjD,MAAM0C,eAAAA,GAAkBxB,qBAAqBsB,SAAAA,EAAWxC,UAAAA,CAAAA;YAExD,OAAO;AAACyC,gBAAAA,cAAAA;AAAgBC,gBAAAA;AAAgB,aAAA;AAC1C,QAAA;AACF,KAAA;AACF,CAAA;;;;"}
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var nexus = require('nexus');
4
- var fp = require('lodash/fp');
4
+ var lodash = require('lodash');
5
5
 
6
6
  var entity = (({ strapi })=>{
7
7
  const { naming } = strapi.plugin('graphql').service('utils');
@@ -19,13 +19,13 @@ var entity = (({ strapi })=>{
19
19
  definition (t) {
20
20
  // Keep the ID attribute at the top level
21
21
  t.id('id', {
22
- resolve: fp.prop('id')
22
+ resolve: (parent)=>parent?.id
23
23
  });
24
- if (!fp.isEmpty(attributes)) {
24
+ if (!lodash.isEmpty(attributes)) {
25
25
  // Keep the fetched object into a dedicated `attributes` field
26
26
  t.field('attributes', {
27
27
  type: typeName,
28
- resolve: fp.identity
28
+ resolve: lodash.identity
29
29
  });
30
30
  }
31
31
  }
@@ -1 +1 @@
1
- {"version":3,"file":"entity.js","sources":["../../../../server/src/services/builders/entity.ts"],"sourcesContent":["import { objectType } from 'nexus';\nimport { prop, identity, isEmpty } from 'lodash/fp';\nimport type { Schema } from '@strapi/types';\n\nimport type { Context } from '../types';\n\nexport default ({ strapi }: Context) => {\n const { naming } = strapi.plugin('graphql').service('utils');\n\n return {\n /**\n * Build a higher level type for a content type which contains the attributes, the ID and the metadata\n * @param {object} contentType The content type which will be used to build its entity type\n * @return {NexusObjectTypeDef}\n */\n buildEntityDefinition(contentType: Schema.ContentType) {\n const { attributes } = contentType;\n\n const name = naming.getEntityName(contentType);\n const typeName = naming.getTypeName(contentType);\n\n return objectType({\n name,\n\n definition(t) {\n // Keep the ID attribute at the top level\n t.id('id', { resolve: prop('id') });\n\n if (!isEmpty(attributes)) {\n // Keep the fetched object into a dedicated `attributes` field\n t.field('attributes', {\n type: typeName,\n resolve: identity,\n });\n }\n },\n });\n },\n };\n};\n"],"names":["strapi","naming","plugin","service","buildEntityDefinition","contentType","attributes","name","getEntityName","typeName","getTypeName","objectType","definition","t","id","resolve","prop","isEmpty","field","type","identity"],"mappings":";;;;;AAMA,aAAe,CAAA,CAAC,EAAEA,MAAM,EAAW,GAAA;IACjC,MAAM,EAAEC,MAAM,EAAE,GAAGD,OAAOE,MAAM,CAAC,SAAA,CAAA,CAAWC,OAAO,CAAC,OAAA,CAAA;IAEpD,OAAO;AACL;;;;AAIC,QACDC,uBAAsBC,WAA+B,EAAA;YACnD,MAAM,EAAEC,UAAU,EAAE,GAAGD,WAAAA;YAEvB,MAAME,IAAAA,GAAON,MAAAA,CAAOO,aAAa,CAACH,WAAAA,CAAAA;YAClC,MAAMI,QAAAA,GAAWR,MAAAA,CAAOS,WAAW,CAACL,WAAAA,CAAAA;AAEpC,YAAA,OAAOM,gBAAAA,CAAW;AAChBJ,gBAAAA,IAAAA;AAEAK,gBAAAA,UAAAA,CAAAA,CAAWC,CAAC,EAAA;;oBAEVA,CAAAA,CAAEC,EAAE,CAAC,IAAA,EAAM;AAAEC,wBAAAA,OAAAA,EAASC,OAAAA,CAAK,IAAA;AAAM,qBAAA,CAAA;oBAEjC,IAAI,CAACC,WAAQX,UAAAA,CAAAA,EAAa;;wBAExBO,CAAAA,CAAEK,KAAK,CAAC,YAAA,EAAc;4BACpBC,IAAAA,EAAMV,QAAAA;4BACNM,OAAAA,EAASK;AACX,yBAAA,CAAA;AACF,oBAAA;AACF,gBAAA;AACF,aAAA,CAAA;AACF,QAAA;AACF,KAAA;AACF,CAAA;;;;"}
1
+ {"version":3,"file":"entity.js","sources":["../../../../server/src/services/builders/entity.ts"],"sourcesContent":["import { objectType } from 'nexus';\nimport { isEmpty, identity } from 'lodash';\nimport type { Schema } from '@strapi/types';\n\nimport type { Context } from '../types';\n\nexport default ({ strapi }: Context) => {\n const { naming } = strapi.plugin('graphql').service('utils');\n\n return {\n /**\n * Build a higher level type for a content type which contains the attributes, the ID and the metadata\n * @param {object} contentType The content type which will be used to build its entity type\n * @return {NexusObjectTypeDef}\n */\n buildEntityDefinition(contentType: Schema.ContentType) {\n const { attributes } = contentType;\n\n const name = naming.getEntityName(contentType);\n const typeName = naming.getTypeName(contentType);\n\n return objectType({\n name,\n\n definition(t) {\n // Keep the ID attribute at the top level\n t.id('id', { resolve: (parent) => parent?.id });\n\n if (!isEmpty(attributes)) {\n // Keep the fetched object into a dedicated `attributes` field\n t.field('attributes', {\n type: typeName,\n resolve: identity,\n });\n }\n },\n });\n },\n };\n};\n"],"names":["strapi","naming","plugin","service","buildEntityDefinition","contentType","attributes","name","getEntityName","typeName","getTypeName","objectType","definition","t","id","resolve","parent","isEmpty","field","type","identity"],"mappings":";;;;;AAMA,aAAe,CAAA,CAAC,EAAEA,MAAM,EAAW,GAAA;IACjC,MAAM,EAAEC,MAAM,EAAE,GAAGD,OAAOE,MAAM,CAAC,SAAA,CAAA,CAAWC,OAAO,CAAC,OAAA,CAAA;IAEpD,OAAO;AACL;;;;AAIC,QACDC,uBAAsBC,WAA+B,EAAA;YACnD,MAAM,EAAEC,UAAU,EAAE,GAAGD,WAAAA;YAEvB,MAAME,IAAAA,GAAON,MAAAA,CAAOO,aAAa,CAACH,WAAAA,CAAAA;YAClC,MAAMI,QAAAA,GAAWR,MAAAA,CAAOS,WAAW,CAACL,WAAAA,CAAAA;AAEpC,YAAA,OAAOM,gBAAAA,CAAW;AAChBJ,gBAAAA,IAAAA;AAEAK,gBAAAA,UAAAA,CAAAA,CAAWC,CAAC,EAAA;;oBAEVA,CAAAA,CAAEC,EAAE,CAAC,IAAA,EAAM;wBAAEC,OAAAA,EAAS,CAACC,SAAWA,MAAAA,EAAQF;AAAG,qBAAA,CAAA;oBAE7C,IAAI,CAACG,eAAQX,UAAAA,CAAAA,EAAa;;wBAExBO,CAAAA,CAAEK,KAAK,CAAC,YAAA,EAAc;4BACpBC,IAAAA,EAAMV,QAAAA;4BACNM,OAAAA,EAASK;AACX,yBAAA,CAAA;AACF,oBAAA;AACF,gBAAA;AACF,aAAA,CAAA;AACF,QAAA;AACF,KAAA;AACF,CAAA;;;;"}
@@ -1,5 +1,5 @@
1
1
  import { objectType } from 'nexus';
2
- import { prop, isEmpty, identity } from 'lodash/fp';
2
+ import { isEmpty, identity } from 'lodash';
3
3
 
4
4
  var entity = (({ strapi })=>{
5
5
  const { naming } = strapi.plugin('graphql').service('utils');
@@ -17,7 +17,7 @@ var entity = (({ strapi })=>{
17
17
  definition (t) {
18
18
  // Keep the ID attribute at the top level
19
19
  t.id('id', {
20
- resolve: prop('id')
20
+ resolve: (parent)=>parent?.id
21
21
  });
22
22
  if (!isEmpty(attributes)) {
23
23
  // Keep the fetched object into a dedicated `attributes` field
@@ -1 +1 @@
1
- {"version":3,"file":"entity.mjs","sources":["../../../../server/src/services/builders/entity.ts"],"sourcesContent":["import { objectType } from 'nexus';\nimport { prop, identity, isEmpty } from 'lodash/fp';\nimport type { Schema } from '@strapi/types';\n\nimport type { Context } from '../types';\n\nexport default ({ strapi }: Context) => {\n const { naming } = strapi.plugin('graphql').service('utils');\n\n return {\n /**\n * Build a higher level type for a content type which contains the attributes, the ID and the metadata\n * @param {object} contentType The content type which will be used to build its entity type\n * @return {NexusObjectTypeDef}\n */\n buildEntityDefinition(contentType: Schema.ContentType) {\n const { attributes } = contentType;\n\n const name = naming.getEntityName(contentType);\n const typeName = naming.getTypeName(contentType);\n\n return objectType({\n name,\n\n definition(t) {\n // Keep the ID attribute at the top level\n t.id('id', { resolve: prop('id') });\n\n if (!isEmpty(attributes)) {\n // Keep the fetched object into a dedicated `attributes` field\n t.field('attributes', {\n type: typeName,\n resolve: identity,\n });\n }\n },\n });\n },\n };\n};\n"],"names":["strapi","naming","plugin","service","buildEntityDefinition","contentType","attributes","name","getEntityName","typeName","getTypeName","objectType","definition","t","id","resolve","prop","isEmpty","field","type","identity"],"mappings":";;;AAMA,aAAe,CAAA,CAAC,EAAEA,MAAM,EAAW,GAAA;IACjC,MAAM,EAAEC,MAAM,EAAE,GAAGD,OAAOE,MAAM,CAAC,SAAA,CAAA,CAAWC,OAAO,CAAC,OAAA,CAAA;IAEpD,OAAO;AACL;;;;AAIC,QACDC,uBAAsBC,WAA+B,EAAA;YACnD,MAAM,EAAEC,UAAU,EAAE,GAAGD,WAAAA;YAEvB,MAAME,IAAAA,GAAON,MAAAA,CAAOO,aAAa,CAACH,WAAAA,CAAAA;YAClC,MAAMI,QAAAA,GAAWR,MAAAA,CAAOS,WAAW,CAACL,WAAAA,CAAAA;AAEpC,YAAA,OAAOM,UAAAA,CAAW;AAChBJ,gBAAAA,IAAAA;AAEAK,gBAAAA,UAAAA,CAAAA,CAAWC,CAAC,EAAA;;oBAEVA,CAAAA,CAAEC,EAAE,CAAC,IAAA,EAAM;AAAEC,wBAAAA,OAAAA,EAASC,IAAAA,CAAK,IAAA;AAAM,qBAAA,CAAA;oBAEjC,IAAI,CAACC,QAAQX,UAAAA,CAAAA,EAAa;;wBAExBO,CAAAA,CAAEK,KAAK,CAAC,YAAA,EAAc;4BACpBC,IAAAA,EAAMV,QAAAA;4BACNM,OAAAA,EAASK;AACX,yBAAA,CAAA;AACF,oBAAA;AACF,gBAAA;AACF,aAAA,CAAA;AACF,QAAA;AACF,KAAA;AACF,CAAA;;;;"}
1
+ {"version":3,"file":"entity.mjs","sources":["../../../../server/src/services/builders/entity.ts"],"sourcesContent":["import { objectType } from 'nexus';\nimport { isEmpty, identity } from 'lodash';\nimport type { Schema } from '@strapi/types';\n\nimport type { Context } from '../types';\n\nexport default ({ strapi }: Context) => {\n const { naming } = strapi.plugin('graphql').service('utils');\n\n return {\n /**\n * Build a higher level type for a content type which contains the attributes, the ID and the metadata\n * @param {object} contentType The content type which will be used to build its entity type\n * @return {NexusObjectTypeDef}\n */\n buildEntityDefinition(contentType: Schema.ContentType) {\n const { attributes } = contentType;\n\n const name = naming.getEntityName(contentType);\n const typeName = naming.getTypeName(contentType);\n\n return objectType({\n name,\n\n definition(t) {\n // Keep the ID attribute at the top level\n t.id('id', { resolve: (parent) => parent?.id });\n\n if (!isEmpty(attributes)) {\n // Keep the fetched object into a dedicated `attributes` field\n t.field('attributes', {\n type: typeName,\n resolve: identity,\n });\n }\n },\n });\n },\n };\n};\n"],"names":["strapi","naming","plugin","service","buildEntityDefinition","contentType","attributes","name","getEntityName","typeName","getTypeName","objectType","definition","t","id","resolve","parent","isEmpty","field","type","identity"],"mappings":";;;AAMA,aAAe,CAAA,CAAC,EAAEA,MAAM,EAAW,GAAA;IACjC,MAAM,EAAEC,MAAM,EAAE,GAAGD,OAAOE,MAAM,CAAC,SAAA,CAAA,CAAWC,OAAO,CAAC,OAAA,CAAA;IAEpD,OAAO;AACL;;;;AAIC,QACDC,uBAAsBC,WAA+B,EAAA;YACnD,MAAM,EAAEC,UAAU,EAAE,GAAGD,WAAAA;YAEvB,MAAME,IAAAA,GAAON,MAAAA,CAAOO,aAAa,CAACH,WAAAA,CAAAA;YAClC,MAAMI,QAAAA,GAAWR,MAAAA,CAAOS,WAAW,CAACL,WAAAA,CAAAA;AAEpC,YAAA,OAAOM,UAAAA,CAAW;AAChBJ,gBAAAA,IAAAA;AAEAK,gBAAAA,UAAAA,CAAAA,CAAWC,CAAC,EAAA;;oBAEVA,CAAAA,CAAEC,EAAE,CAAC,IAAA,EAAM;wBAAEC,OAAAA,EAAS,CAACC,SAAWA,MAAAA,EAAQF;AAAG,qBAAA,CAAA;oBAE7C,IAAI,CAACG,QAAQX,UAAAA,CAAAA,EAAa;;wBAExBO,CAAAA,CAAEK,KAAK,CAAC,YAAA,EAAc;4BACpBC,IAAAA,EAAMV,QAAAA;4BACNM,OAAAA,EAASK;AACX,yBAAA,CAAA;AACF,oBAAA;AACF,gBAAA;AACF,aAAA,CAAA;AACF,QAAA;AACF,KAAA;AACF,CAAA;;;;"}
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var nexus = require('nexus');
4
- var fp = require('lodash/fp');
4
+ var lodash = require('lodash');
5
5
  var utils = require('@strapi/utils');
6
6
 
7
7
  /**
@@ -13,7 +13,7 @@ var utils = require('@strapi/utils');
13
13
  */ const buildEnumTypeDefinition = (definition, name)=>{
14
14
  return nexus.enumType({
15
15
  name,
16
- members: definition.enum.reduce((acc, value)=>fp.set(utils.strings.toRegressedEnumValue(value), value, acc), {})
16
+ members: definition.enum.reduce((acc, value)=>lodash.set(acc, utils.strings.toRegressedEnumValue(value), value), {})
17
17
  });
18
18
  };
19
19
  var enums = (()=>({