From d8be8c2ca4714624e11ed6ddc9b82a289df2b351 Mon Sep 17 00:00:00 2001 From: Marcel Schwarz Date: Mon, 15 Jul 2024 18:53:47 +0200 Subject: [PATCH 01/15] Allow payload limit to be configured --- lib/GraphQLAdapter.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/GraphQLAdapter.js b/lib/GraphQLAdapter.js index edcab379..4c4fe5e0 100644 --- a/lib/GraphQLAdapter.js +++ b/lib/GraphQLAdapter.js @@ -19,8 +19,12 @@ function GraphQLAdapter(options) { ? require(path.join(cds.root, options.errorFormatter)) : defaultErrorFormatter + const bodyParserOptions = {} + const { max_content_length } = options + if (max_content_length) bodyParserOptions.limit = max_content_length + router - .use(express.json()) //> required by logger below + .use(express.json(bodyParserOptions)) //> required by logger below .use(queryLogger) if (options.graphiql) router.use(graphiql) From 9e03b52a786924243aeb9b43831657127393d95c Mon Sep 17 00:00:00 2001 From: Marcel Schwarz Date: Mon, 15 Jul 2024 18:55:08 +0200 Subject: [PATCH 02/15] Add dependency to self to `cds.test` projects --- test/resources/bookshop/package.json | 1 + test/resources/custom-handlers/package.json | 3 +++ test/resources/types/package.json | 3 +++ 3 files changed, 7 insertions(+) diff --git a/test/resources/bookshop/package.json b/test/resources/bookshop/package.json index 5e7113e1..3f604834 100644 --- a/test/resources/bookshop/package.json +++ b/test/resources/bookshop/package.json @@ -10,6 +10,7 @@ "index.js" ], "dependencies": { + "@cap-js/graphql": "*", "@sap/cds": ">=5.9", "express": "^4.17.1" }, diff --git a/test/resources/custom-handlers/package.json b/test/resources/custom-handlers/package.json index 580c138c..7e7fb79e 100644 --- a/test/resources/custom-handlers/package.json +++ b/test/resources/custom-handlers/package.json @@ -1,4 +1,7 @@ { + "dependencies": { + "@cap-js/graphql": "*" + }, "devDependencies": { "@cap-js/sqlite": "*" } diff --git a/test/resources/types/package.json b/test/resources/types/package.json index 717be87e..7e7fb79e 100644 --- a/test/resources/types/package.json +++ b/test/resources/types/package.json @@ -1,5 +1,8 @@ { "dependencies": { + "@cap-js/graphql": "*" + }, + "devDependencies": { "@cap-js/sqlite": "*" } } \ No newline at end of file From ca50111ab74290c5b7c7a1d63e4337b7d8b40f6c Mon Sep 17 00:00:00 2001 From: Marcel Schwarz Date: Mon, 15 Jul 2024 18:56:01 +0200 Subject: [PATCH 03/15] Enable large binary and large string tests --- test/resources/types/package.json | 7 +++++ test/tests/types.test.js | 44 ++++++++++++++++--------------- 2 files changed, 30 insertions(+), 21 deletions(-) diff --git a/test/resources/types/package.json b/test/resources/types/package.json index 7e7fb79e..96281a74 100644 --- a/test/resources/types/package.json +++ b/test/resources/types/package.json @@ -4,5 +4,12 @@ }, "devDependencies": { "@cap-js/sqlite": "*" + }, + "cds": { + "protocols": { + "graphql": { + "max_content_length": "110KB" + } + } } } \ No newline at end of file diff --git a/test/tests/types.test.js b/test/tests/types.test.js index 5efd5c0b..478c032f 100644 --- a/test/tests/types.test.js +++ b/test/tests/types.test.js @@ -1,13 +1,19 @@ +const consumers = require('node:stream/consumers') + const { gql } = require('../util') const _toBase64Url = value => value.replace(/\//g, '_').replace(/\+/g, '-') -const _getTestBuffer = length => { - const testString = 'Test String! ' - let string = testString.repeat(Math.ceil(length / testString.length)).slice(0, length) - return Buffer.from(string) +const _getTestString = length => { + const testString = 'This is a test string! ' + return testString.repeat(Math.ceil(length / testString.length)).slice(0, length) } +const _getTestBuffer = length => Buffer.from(_getTestString(length)) + +// e.g. base64 string with length 96 -> requires buffer with length 72 +const _neededBufferLengthForBase64StringWithLength = length => Math.ceil((length * 6) / 8) + const _getMutationForFieldWithLiteralValue = (field, value, quoted) => ({ query: gql` mutation { @@ -48,9 +54,7 @@ describe('graphql - types parsing and validation', () => { // Prevent axios from throwing errors for non 2xx status codes axios.defaults.validateStatus = false - beforeEach(async () => { - await data.reset() - }) + beforeEach(data.reset) describe('cds.Binary', () => { const field = 'myBinary' @@ -1002,12 +1006,9 @@ describe('graphql - types parsing and validation', () => { }) // Note: maps to same type as cds.Binary - // REVISIT: express-graphql limits request body size to 100kb by default: - // - https://github.com/graphql/express-graphql/issues/346 - // - https://github.com/graphql/express-graphql/blob/28e4c2924ea6984bf918465cefdadae340d8780e/src/parseBody.ts#L96 - describe.skip('cds.LargeBinary', () => { + describe('cds.LargeBinary', () => { const field = 'myLargeBinary' - const buffer = _getTestBuffer(500000) // 500 KB + const buffer = _getTestBuffer(_neededBufferLengthForBase64StringWithLength(105000)) // 105 KB as base64 string describe('input literal', () => { test('cds.LargeBinary is correctly parsed from large input literal base64 encoded string value', async () => { @@ -1018,7 +1019,8 @@ describe('graphql - types parsing and validation', () => { expect(response.data).toEqual({ data }) const result = await SELECT.one.from('sap.cds.graphql.types.MyEntity').columns(field) - expect(result[field]).toEqual(buffer) + const bufferFromDB = await consumers.buffer(result[field]) + expect(bufferFromDB).toEqual(buffer) }) test('cds.LargeBinary is correctly parsed from large input literal base64url encoded string value', async () => { @@ -1029,7 +1031,8 @@ describe('graphql - types parsing and validation', () => { expect(response.data).toEqual({ data }) const result = await SELECT.one.from('sap.cds.graphql.types.MyEntity').columns(field) - expect(result[field]).toEqual(buffer) + const bufferFromDB = await consumers.buffer(result[field]) + expect(bufferFromDB).toEqual(buffer) }) }) @@ -1042,7 +1045,8 @@ describe('graphql - types parsing and validation', () => { expect(response.data).toEqual({ data }) const result = await SELECT.one.from('sap.cds.graphql.types.MyEntity').columns(field) - expect(result[field]).toEqual(buffer) + const bufferFromDB = await consumers.buffer(result[field]) + expect(bufferFromDB).toEqual(buffer) }) test('cds.LargeBinary is correctly parsed from large variable base64url encoded string value', async () => { @@ -1053,18 +1057,16 @@ describe('graphql - types parsing and validation', () => { expect(response.data).toEqual({ data }) const result = await SELECT.one.from('sap.cds.graphql.types.MyEntity').columns(field) - expect(result[field]).toEqual(buffer) + const bufferFromDB = await consumers.buffer(result[field]) + expect(bufferFromDB).toEqual(buffer) }) }) }) // Note: maps to same type as cds.String - // REVISIT: express-graphql limits request body size to 100kb by default: - // - https://github.com/graphql/express-graphql/issues/346 - // - https://github.com/graphql/express-graphql/blob/28e4c2924ea6984bf918465cefdadae340d8780e/src/parseBody.ts#L96 - describe.skip('cds.LargeString', () => { + describe('cds.LargeString', () => { const field = 'myLargeString' - const value = 'This is a test string! '.repeat(100000) + const value = _getTestString(105000) // 105 KB test('cds.LargeString is correctly parsed from input literal', async () => { const body = _getMutationForFieldWithLiteralValue(field, value, true) From aa59822d1ea46c064f3a673a0a98e33375b26279 Mon Sep 17 00:00:00 2001 From: Marcel Schwarz Date: Mon, 15 Jul 2024 18:56:22 +0200 Subject: [PATCH 04/15] Dependency formatting in `package.json` --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index dfcd9db3..dd1629f5 100644 --- a/package.json +++ b/package.json @@ -40,10 +40,10 @@ }, "devDependencies": { "@cap-js/graphql": "file:.", + "@cap-js/sqlite": "^1", "axios": "^1", "express": "^4.17.1", "jest": "^29.3.1", - "semver": "^7.4.0", - "@cap-js/sqlite": "^1" + "semver": "^7.4.0" } } From d723539e2c19966514cecf137e0a2a73d06df2fc Mon Sep 17 00:00:00 2001 From: Marcel Schwarz Date: Mon, 15 Jul 2024 18:58:18 +0200 Subject: [PATCH 05/15] Add changelog entry --- CHANGELOG.md | 39 ++++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f85f12ba..4a04fdc7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added +- Allow maximum POST body size to be configured using the `max_content_length` option. This value is passed to the Express JSON body parser middleware `limit` option. For example: + ```json + { + "cds": { + "protocols": { + "graphql": { + "max_content_length": "500KB" + } + } + } + } + ``` + ### Changed - To improve performance, binary payloads are no longer validated to check if they are properly base64 or base64url encoded @@ -99,10 +112,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Improved query logging: - + Don't log queries that are `undefined` - + Log `operationName` - + Log `variables` when not in production - + Sanitize arguments and their values in queries when in production + - Don't log queries that are `undefined` + - Log `operationName` + - Log `variables` when not in production + - Sanitize arguments and their values in queries when in production ### Fixed @@ -121,21 +134,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Moved the `GraphQLAdapter` module to `lib/GraphQLAdapter.js` and merged it with `CDSGraphQLAdapter` previously found in `index.js` in the root directory - Don't generate fields that represent compositions of aspects within mutation types that represent services - Disabled conjunction on the same field for the following operators: - + `eq` (Equal) - + `gt` (Greater Than) - + `ge` (Greater Than or Equal) - + `le` (Less Than or Equal) - + `lt` (Less Than) - + `startswith` - + `endswith` + - `eq` (Equal) + - `gt` (Greater Than) + - `ge` (Greater Than or Equal) + - `le` (Less Than or Equal) + - `lt` (Less Than) + - `startswith` + - `endswith` ## Version 0.5.0 - 2023-05-04 ### Changed - Improved consistency of handling results of different types returned by custom handlers in CRUD resolvers: - + Wrap only objects (i.e. not primitive types or arrays) returned by custom handlers in arrays in create, read, and update resolvers - + Delete mutations return the length of an array that is returned by a `DELETE` custom handler or 1 if a single object is returned + - Wrap only objects (i.e. not primitive types or arrays) returned by custom handlers in arrays in create, read, and update resolvers + - Delete mutations return the length of an array that is returned by a `DELETE` custom handler or 1 if a single object is returned - Don't generate fields for key elements in update input objects - Update and delete mutations have mandatory `filter` argument - Allow services that are not instances of `cds.ApplicationService`. It is expected that the invoker provides the correct set of service providers when directly using the GraphQL protocol adapter API. From d01363968eec3adcfc2620b71995f5ee59a130ba Mon Sep 17 00:00:00 2001 From: Marcel Schwarz Date: Mon, 15 Jul 2024 18:58:36 +0200 Subject: [PATCH 06/15] Fallback to global `cds.env.features.max_content_length` flag --- lib/GraphQLAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/GraphQLAdapter.js b/lib/GraphQLAdapter.js index 4c4fe5e0..75b75647 100644 --- a/lib/GraphQLAdapter.js +++ b/lib/GraphQLAdapter.js @@ -20,7 +20,7 @@ function GraphQLAdapter(options) { : defaultErrorFormatter const bodyParserOptions = {} - const { max_content_length } = options + const { max_content_length } = options || cds.env.features if (max_content_length) bodyParserOptions.limit = max_content_length router From 08005c7fa0360cafa9605528b622769b97b9a80e Mon Sep 17 00:00:00 2001 From: Marcel Schwarz Date: Wed, 17 Jul 2024 17:17:31 +0200 Subject: [PATCH 07/15] Undo changelog formatting of indented lists --- CHANGELOG.md | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a04fdc7..9b1dfcd7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -112,10 +112,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Improved query logging: - - Don't log queries that are `undefined` - - Log `operationName` - - Log `variables` when not in production - - Sanitize arguments and their values in queries when in production + + Don't log queries that are `undefined` + + Log `operationName` + + Log `variables` when not in production + + Sanitize arguments and their values in queries when in production ### Fixed @@ -134,21 +134,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Moved the `GraphQLAdapter` module to `lib/GraphQLAdapter.js` and merged it with `CDSGraphQLAdapter` previously found in `index.js` in the root directory - Don't generate fields that represent compositions of aspects within mutation types that represent services - Disabled conjunction on the same field for the following operators: - - `eq` (Equal) - - `gt` (Greater Than) - - `ge` (Greater Than or Equal) - - `le` (Less Than or Equal) - - `lt` (Less Than) - - `startswith` - - `endswith` + + `eq` (Equal) + + `gt` (Greater Than) + + `ge` (Greater Than or Equal) + + `le` (Less Than or Equal) + + `lt` (Less Than) + + `startswith` + + `endswith` ## Version 0.5.0 - 2023-05-04 ### Changed - Improved consistency of handling results of different types returned by custom handlers in CRUD resolvers: - - Wrap only objects (i.e. not primitive types or arrays) returned by custom handlers in arrays in create, read, and update resolvers - - Delete mutations return the length of an array that is returned by a `DELETE` custom handler or 1 if a single object is returned + + Wrap only objects (i.e. not primitive types or arrays) returned by custom handlers in arrays in create, read, and update resolvers + + Delete mutations return the length of an array that is returned by a `DELETE` custom handler or 1 if a single object is returned - Don't generate fields for key elements in update input objects - Update and delete mutations have mandatory `filter` argument - Allow services that are not instances of `cds.ApplicationService`. It is expected that the invoker provides the correct set of service providers when directly using the GraphQL protocol adapter API. From 064bb44656f710bd5d1fa7cb7d56afd53ef9f236 Mon Sep 17 00:00:00 2001 From: Marcel Schwarz Date: Wed, 24 Jul 2024 13:39:26 +0200 Subject: [PATCH 08/15] Replace protocol specific payload limit config with programmatic override --- lib/GraphQLAdapter.js | 6 +----- test/resources/types/package.json | 7 ------- test/resources/types/server.js | 9 +++------ 3 files changed, 4 insertions(+), 18 deletions(-) diff --git a/lib/GraphQLAdapter.js b/lib/GraphQLAdapter.js index 75b75647..edcab379 100644 --- a/lib/GraphQLAdapter.js +++ b/lib/GraphQLAdapter.js @@ -19,12 +19,8 @@ function GraphQLAdapter(options) { ? require(path.join(cds.root, options.errorFormatter)) : defaultErrorFormatter - const bodyParserOptions = {} - const { max_content_length } = options || cds.env.features - if (max_content_length) bodyParserOptions.limit = max_content_length - router - .use(express.json(bodyParserOptions)) //> required by logger below + .use(express.json()) //> required by logger below .use(queryLogger) if (options.graphiql) router.use(graphiql) diff --git a/test/resources/types/package.json b/test/resources/types/package.json index 96281a74..7e7fb79e 100644 --- a/test/resources/types/package.json +++ b/test/resources/types/package.json @@ -4,12 +4,5 @@ }, "devDependencies": { "@cap-js/sqlite": "*" - }, - "cds": { - "protocols": { - "graphql": { - "max_content_length": "110KB" - } - } } } \ No newline at end of file diff --git a/test/resources/types/server.js b/test/resources/types/server.js index 6939c6d6..6757ca5c 100644 --- a/test/resources/types/server.js +++ b/test/resources/types/server.js @@ -1,6 +1,3 @@ -const cds = require('@sap/cds') -const path = require('path') -const protocols = cds.env.protocols ??= {} -if (!protocols.graphql) protocols.graphql = { - path: '/graphql', impl: path.join(__dirname, '../../../index.js') -} \ No newline at end of file +cds.on('bootstrap', app => { + app.use(cds.env.protocols.graphql.path, require('express').json({ limit: '110KB' })) +}) \ No newline at end of file From 074b2552cb0d45be6b263441f8639a14d82193b7 Mon Sep 17 00:00:00 2001 From: Marcel Schwarz Date: Wed, 24 Jul 2024 13:40:54 +0200 Subject: [PATCH 09/15] Restore test with programmatic registration of protocol adapter --- test/resources/custom-handlers/package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/resources/custom-handlers/package.json b/test/resources/custom-handlers/package.json index 7e7fb79e..e31f286b 100644 --- a/test/resources/custom-handlers/package.json +++ b/test/resources/custom-handlers/package.json @@ -1,5 +1,6 @@ { - "dependencies": { + "Note: Programmatic configuration of GraphQL protocol adapter in server.js": "", + "__dependencies": { "@cap-js/graphql": "*" }, "devDependencies": { From 4f16f44eb0c76a885239511b5959c6659adcd670 Mon Sep 17 00:00:00 2001 From: Marcel Schwarz Date: Wed, 24 Jul 2024 13:41:47 +0200 Subject: [PATCH 10/15] Remove changelog entry --- CHANGELOG.md | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b1dfcd7..f85f12ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,19 +9,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added -- Allow maximum POST body size to be configured using the `max_content_length` option. This value is passed to the Express JSON body parser middleware `limit` option. For example: - ```json - { - "cds": { - "protocols": { - "graphql": { - "max_content_length": "500KB" - } - } - } - } - ``` - ### Changed - To improve performance, binary payloads are no longer validated to check if they are properly base64 or base64url encoded From a28d788499927c0937e3f17940e06d50ae2c4516 Mon Sep 17 00:00:00 2001 From: Marcel Schwarz Date: Wed, 24 Jul 2024 13:44:28 +0200 Subject: [PATCH 11/15] Add comment about programmatic body limit override --- test/resources/types/server.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/resources/types/server.js b/test/resources/types/server.js index 6757ca5c..f2144881 100644 --- a/test/resources/types/server.js +++ b/test/resources/types/server.js @@ -1,3 +1,4 @@ cds.on('bootstrap', app => { + // Programmatic override of maximum request body size for requests to GraphQL endpoint app.use(cds.env.protocols.graphql.path, require('express').json({ limit: '110KB' })) -}) \ No newline at end of file +}) From b8377fe3f7e4f303dff670dc82f17909652996ca Mon Sep 17 00:00:00 2001 From: Marcel Schwarz Date: Wed, 24 Jul 2024 15:55:49 +0200 Subject: [PATCH 12/15] Replace programmatic body parser limit override with global config --- lib/GraphQLAdapter.js | 6 +++++- test/resources/types/package.json | 5 +++++ test/resources/types/server.js | 4 ---- 3 files changed, 10 insertions(+), 5 deletions(-) delete mode 100644 test/resources/types/server.js diff --git a/lib/GraphQLAdapter.js b/lib/GraphQLAdapter.js index edcab379..7f0ece9e 100644 --- a/lib/GraphQLAdapter.js +++ b/lib/GraphQLAdapter.js @@ -19,8 +19,12 @@ function GraphQLAdapter(options) { ? require(path.join(cds.root, options.errorFormatter)) : defaultErrorFormatter + const bodyParserOptions = {} + const { max_request_body_size } = cds.env.server + if (max_request_body_size) bodyParserOptions.limit = max_request_body_size + router - .use(express.json()) //> required by logger below + .use(express.json(bodyParserOptions)) //> required by logger below .use(queryLogger) if (options.graphiql) router.use(graphiql) diff --git a/test/resources/types/package.json b/test/resources/types/package.json index 7e7fb79e..37aee2d7 100644 --- a/test/resources/types/package.json +++ b/test/resources/types/package.json @@ -4,5 +4,10 @@ }, "devDependencies": { "@cap-js/sqlite": "*" + }, + "cds": { + "server": { + "max_request_body_size": "110KB" + } } } \ No newline at end of file diff --git a/test/resources/types/server.js b/test/resources/types/server.js deleted file mode 100644 index f2144881..00000000 --- a/test/resources/types/server.js +++ /dev/null @@ -1,4 +0,0 @@ -cds.on('bootstrap', app => { - // Programmatic override of maximum request body size for requests to GraphQL endpoint - app.use(cds.env.protocols.graphql.path, require('express').json({ limit: '110KB' })) -}) From f0b2886d47402aa3360a89124d9bbc717800c4b5 Mon Sep 17 00:00:00 2001 From: Marcel Schwarz Date: Wed, 24 Jul 2024 15:59:44 +0200 Subject: [PATCH 13/15] Add changelog entry --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f85f12ba..0b5db1fc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added +- Support for configuring request payload limit using global feature flag `cds.server.max_request_body_size` + ### Changed - To improve performance, binary payloads are no longer validated to check if they are properly base64 or base64url encoded From e0dd7c70e997cf41afa70c9055743946149d78d0 Mon Sep 17 00:00:00 2001 From: Marcel Schwarz Date: Wed, 24 Jul 2024 16:01:00 +0200 Subject: [PATCH 14/15] Adjust changelog entry wording --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b5db1fc..fb3a7b0b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added -- Support for configuring request payload limit using global feature flag `cds.server.max_request_body_size` +- Support for configuring request payload limit using global flag `cds.server.max_request_body_size` ### Changed From b82e7ef1e1b7ad3431db64b984200bbc4915fdef Mon Sep 17 00:00:00 2001 From: Marcel Schwarz Date: Fri, 26 Jul 2024 14:08:58 +0200 Subject: [PATCH 15/15] Rename flag `cds.server.max_request_body_size` -> `cds.server.body_parser.limit` --- CHANGELOG.md | 2 +- lib/GraphQLAdapter.js | 6 +----- test/resources/types/package.json | 4 +++- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fb3a7b0b..f5bd5c99 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added -- Support for configuring request payload limit using global flag `cds.server.max_request_body_size` +- Support for configuring request payload limit using global flag `cds.server.body_parser.limit` ### Changed diff --git a/lib/GraphQLAdapter.js b/lib/GraphQLAdapter.js index 7f0ece9e..80182cdc 100644 --- a/lib/GraphQLAdapter.js +++ b/lib/GraphQLAdapter.js @@ -19,12 +19,8 @@ function GraphQLAdapter(options) { ? require(path.join(cds.root, options.errorFormatter)) : defaultErrorFormatter - const bodyParserOptions = {} - const { max_request_body_size } = cds.env.server - if (max_request_body_size) bodyParserOptions.limit = max_request_body_size - router - .use(express.json(bodyParserOptions)) //> required by logger below + .use(express.json({ ...cds.env.server.body_parser })) //> required by logger below .use(queryLogger) if (options.graphiql) router.use(graphiql) diff --git a/test/resources/types/package.json b/test/resources/types/package.json index 37aee2d7..5a74c9a2 100644 --- a/test/resources/types/package.json +++ b/test/resources/types/package.json @@ -7,7 +7,9 @@ }, "cds": { "server": { - "max_request_body_size": "110KB" + "body_parser": { + "limit": "110KB" + } } } } \ No newline at end of file