From 6c8ab981afabb115113f22485395b121f9057b3f Mon Sep 17 00:00:00 2001 From: Marcel Schwarz Date: Wed, 4 Jan 2023 17:00:09 +0100 Subject: [PATCH 1/9] Fix folder name util.js -> util --- lib/schema/types/custom/GraphQLBinary.js | 2 +- lib/schema/types/custom/GraphQLDate.js | 2 +- lib/schema/types/custom/GraphQLDateTime.js | 2 +- lib/schema/types/custom/GraphQLDecimal.js | 2 +- lib/schema/types/custom/GraphQLInt16.js | 2 +- lib/schema/types/custom/GraphQLInt64.js | 2 +- lib/schema/types/custom/GraphQLTime.js | 2 +- lib/schema/types/custom/GraphQLTimestamp.js | 2 +- lib/schema/types/custom/GraphQLUInt8.js | 2 +- lib/schema/types/custom/{util.js => util}/index.js | 0 10 files changed, 9 insertions(+), 9 deletions(-) rename lib/schema/types/custom/{util.js => util}/index.js (100%) diff --git a/lib/schema/types/custom/GraphQLBinary.js b/lib/schema/types/custom/GraphQLBinary.js index cd45b5e9..dbf87f15 100644 --- a/lib/schema/types/custom/GraphQLBinary.js +++ b/lib/schema/types/custom/GraphQLBinary.js @@ -1,5 +1,5 @@ const { GraphQLScalarType, Kind, GraphQLError } = require('graphql') -const { getGraphQLValueError } = require('./util.js') +const { getGraphQLValueError } = require('./util') const ERROR_NON_STRING_VALUE = 'Binary cannot represent non string value' const ERROR_NON_BASE64_OR_BASE64URL = 'Binary values must be base64 or base64url encoded and normalized strings' diff --git a/lib/schema/types/custom/GraphQLDate.js b/lib/schema/types/custom/GraphQLDate.js index 7f7492d2..b72bec88 100644 --- a/lib/schema/types/custom/GraphQLDate.js +++ b/lib/schema/types/custom/GraphQLDate.js @@ -1,5 +1,5 @@ const { GraphQLScalarType, Kind } = require('graphql') -const { getGraphQLValueError, parseDate } = require('./util.js') +const { getGraphQLValueError, parseDate } = require('./util') const ERROR_NON_STRING_VALUE = 'Date cannot represent non string value' const ERROR_NON_DATE_VALUE = 'Date values must be strings in the ISO 8601 format YYYY-MM-DD' diff --git a/lib/schema/types/custom/GraphQLDateTime.js b/lib/schema/types/custom/GraphQLDateTime.js index 1ceac1fe..601a00cd 100644 --- a/lib/schema/types/custom/GraphQLDateTime.js +++ b/lib/schema/types/custom/GraphQLDateTime.js @@ -1,5 +1,5 @@ const { GraphQLScalarType, Kind } = require('graphql') -const { getGraphQLValueError, parseDate } = require('./util.js') +const { getGraphQLValueError, parseDate } = require('./util') const ERROR_NON_STRING_VALUE = 'DateTime cannot represent non string value' const ERROR_NON_DATE_TIME_VALUE = 'DateTime values must be strings in the ISO 8601 format YYYY-MM-DDThh-mm-ssTZD' diff --git a/lib/schema/types/custom/GraphQLDecimal.js b/lib/schema/types/custom/GraphQLDecimal.js index ffc695fd..8ed02461 100644 --- a/lib/schema/types/custom/GraphQLDecimal.js +++ b/lib/schema/types/custom/GraphQLDecimal.js @@ -1,5 +1,5 @@ const { GraphQLScalarType, Kind } = require('graphql') -const { getValueFromInputValueOrValueNode, getGraphQLValueError } = require('./util.js') +const { getValueFromInputValueOrValueNode, getGraphQLValueError } = require('./util') const ERROR_VARIABLE_NON_STRING_VALUE = 'Decimal variable value must be represented by a string' const ERROR_NON_NUMERIC_VALUE = 'Decimal must be a numeric value' diff --git a/lib/schema/types/custom/GraphQLInt16.js b/lib/schema/types/custom/GraphQLInt16.js index 8409093a..2d76363c 100644 --- a/lib/schema/types/custom/GraphQLInt16.js +++ b/lib/schema/types/custom/GraphQLInt16.js @@ -1,5 +1,5 @@ const { GraphQLScalarType, Kind } = require('graphql') -const { getGraphQLValueError, validateRange } = require('./util.js') +const { getGraphQLValueError, validateRange } = require('./util') const ERROR_NON_INTEGER_VALUE = 'Int16 cannot represent non integer value' const ERROR_NON_16_BIT_INTEGER_VALUE = 'Int16 must be an integer value between -(2^15) and 2^15 - 1' diff --git a/lib/schema/types/custom/GraphQLInt64.js b/lib/schema/types/custom/GraphQLInt64.js index c47a1093..9c23058d 100644 --- a/lib/schema/types/custom/GraphQLInt64.js +++ b/lib/schema/types/custom/GraphQLInt64.js @@ -1,5 +1,5 @@ const { GraphQLScalarType, Kind } = require('graphql') -const { getValueFromInputValueOrValueNode, getGraphQLValueError, validateRange } = require('./util.js') +const { getValueFromInputValueOrValueNode, getGraphQLValueError, validateRange } = require('./util') const ERROR_VARIABLE_NON_STRING_VALUE = 'Int64 variable value must be represented by a string' const ERROR_NON_INTEGER_VALUE = 'Int64 cannot represent non integer value' diff --git a/lib/schema/types/custom/GraphQLTime.js b/lib/schema/types/custom/GraphQLTime.js index 3f8c4fe7..8736b026 100644 --- a/lib/schema/types/custom/GraphQLTime.js +++ b/lib/schema/types/custom/GraphQLTime.js @@ -1,5 +1,5 @@ const { GraphQLScalarType, Kind } = require('graphql') -const { getGraphQLValueError, getValueFromInputValueOrValueNode, ISO_TIME_REGEX } = require('./util.js') +const { getGraphQLValueError, getValueFromInputValueOrValueNode, ISO_TIME_REGEX } = require('./util') const ERROR_NON_STRING_VALUE = 'Time cannot represent non string value' const ERROR_NON_TIME_VALUE = 'Time values must be strings in the ISO 8601 format hh:mm:ss' diff --git a/lib/schema/types/custom/GraphQLTimestamp.js b/lib/schema/types/custom/GraphQLTimestamp.js index e21a1b3a..6a517bdc 100644 --- a/lib/schema/types/custom/GraphQLTimestamp.js +++ b/lib/schema/types/custom/GraphQLTimestamp.js @@ -1,5 +1,5 @@ const { GraphQLScalarType, Kind } = require('graphql') -const { getGraphQLValueError, parseDate } = require('./util.js') +const { getGraphQLValueError, parseDate } = require('./util') const ERROR_NON_STRING_VALUE = 'Timestamp cannot represent non string value' const ERROR_NON_TIMESTAMP_VALUE = diff --git a/lib/schema/types/custom/GraphQLUInt8.js b/lib/schema/types/custom/GraphQLUInt8.js index d6c024f8..27873b1e 100644 --- a/lib/schema/types/custom/GraphQLUInt8.js +++ b/lib/schema/types/custom/GraphQLUInt8.js @@ -1,5 +1,5 @@ const { GraphQLScalarType, Kind } = require('graphql') -const { getGraphQLValueError, validateRange } = require('./util.js') +const { getGraphQLValueError, validateRange } = require('./util') const ERROR_NON_INTEGER_VALUE = 'UInt8 cannot represent non integer value' const ERROR_NON_8_BIT_UNSIGNED_INTEGER_VALUE = 'UInt8 must be an integer value between 0 and 2^8 - 1' diff --git a/lib/schema/types/custom/util.js/index.js b/lib/schema/types/custom/util/index.js similarity index 100% rename from lib/schema/types/custom/util.js/index.js rename to lib/schema/types/custom/util/index.js From d891871d4630005d1d7b26d1b65c7a3bd5a1b5f8 Mon Sep 17 00:00:00 2001 From: Marcel Schwarz Date: Wed, 4 Jan 2023 17:01:31 +0100 Subject: [PATCH 2/9] Fix typo --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a1f912c..0078c429 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,7 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed -- Fixed a server crash that occourred if an entity property is named `localized`. +- Fixed a server crash that occurred if an entity property is named `localized` ### Removed From ae0a035a3ad2d4207e81fa1e08e8c167e4b80a1b Mon Sep 17 00:00:00 2001 From: Marcel Schwarz Date: Wed, 4 Jan 2023 17:02:59 +0100 Subject: [PATCH 3/9] Fix comment --- lib/schema/types/custom/GraphQLUInt8.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/schema/types/custom/GraphQLUInt8.js b/lib/schema/types/custom/GraphQLUInt8.js index 27873b1e..0f1e7076 100644 --- a/lib/schema/types/custom/GraphQLUInt8.js +++ b/lib/schema/types/custom/GraphQLUInt8.js @@ -5,7 +5,7 @@ const ERROR_NON_INTEGER_VALUE = 'UInt8 cannot represent non integer value' const ERROR_NON_8_BIT_UNSIGNED_INTEGER_VALUE = 'UInt8 must be an integer value between 0 and 2^8 - 1' const MAX_UINT8 = 255 // 2^8 - 1 -const MIN_UINT8 = 0 // 2^0 - 1 +const MIN_UINT8 = 0 // 0 const parseValue = inputValue => { if (typeof inputValue !== 'number') throw getGraphQLValueError(ERROR_NON_INTEGER_VALUE, inputValue) From b9ec83e42017b28c9d2853772963446dff97b9e7 Mon Sep 17 00:00:00 2001 From: Marcel Schwarz Date: Wed, 4 Jan 2023 17:05:58 +0100 Subject: [PATCH 4/9] Simplify repository in package.json --- package.json | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index ddeaaf74..c8a9a378 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@ ], "author": "SAP SE (https://www.sap.com)", "license": "SEE LICENSE IN LICENSE", + "repository": "cap-js/cds-adapter-graphql", "homepage": "https://cap.cloud.sap/", "main": "index.js", "files": [ @@ -46,9 +47,5 @@ }, "jest": { "testTimeout": 10000 - }, - "repository": { - "type": "git", - "url": "https://github.com/cap-js/cds-adapter-graphql" } -} \ No newline at end of file +} From ea18d4fffdf211f2626c84584308bc3cb36daf08 Mon Sep 17 00:00:00 2001 From: Marcel Schwarz Date: Wed, 4 Jan 2023 17:10:29 +0100 Subject: [PATCH 5/9] Move jest configuration out of package.json --- jest.config.js | 5 +++++ package.json | 3 --- 2 files changed, 5 insertions(+), 3 deletions(-) create mode 100644 jest.config.js diff --git a/jest.config.js b/jest.config.js new file mode 100644 index 00000000..4c4b200f --- /dev/null +++ b/jest.config.js @@ -0,0 +1,5 @@ +const config = { + testTimeout: 10000 +} + +module.exports = config diff --git a/package.json b/package.json index c8a9a378..16dad48d 100644 --- a/package.json +++ b/package.json @@ -44,8 +44,5 @@ "jest": "^29.3.1", "prettier": "^2.3.0", "sqlite3": "^5.0.2" - }, - "jest": { - "testTimeout": 10000 } } From f253bd89e6dee80f667e6addd9a4571cabda6cf3 Mon Sep 17 00:00:00 2001 From: Marcel Schwarz Date: Wed, 4 Jan 2023 17:12:32 +0100 Subject: [PATCH 6/9] Remove "Release" prefix from release title --- .github/workflows/release.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 03ef8406..672678f0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -26,8 +26,7 @@ jobs: - name: Create a GitHub release uses: ncipollo/release-action@v1 with: - tag: "v${{ steps.package-version.outputs.current-version}}" - name: "Release v${{ steps.package-version.outputs.current-version}}" + tag: "v${{ steps.package-version.outputs.current-version }}" # body: changelog... - run: npm publish --access public env: From 931e36da2536aac2644bf73e01b022aeb9e937cd Mon Sep 17 00:00:00 2001 From: Marcel Schwarz Date: Mon, 9 Jan 2023 17:07:48 +0100 Subject: [PATCH 7/9] Remove unneeded else --- lib/resolvers/parse/ast/result.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/resolvers/parse/ast/result.js b/lib/resolvers/parse/ast/result.js index 7819b85c..c134e09c 100644 --- a/lib/resolvers/parse/ast/result.js +++ b/lib/resolvers/parse/ast/result.js @@ -46,9 +46,8 @@ const formatResult = (field, result, skipTopLevelConnection) => { return _formatArray(field, value, skipTopLevelConnection) } else if (isPlainObject(value)) { return _formatObject(field.selectionSet.selections, value) - } else { - return value } + return value } return _formatByType(field, result, skipTopLevelConnection) From 2b1e3a6adf39ed1aff181bbdcf16245f454c9d00 Mon Sep 17 00:00:00 2001 From: Marcel Schwarz Date: Mon, 23 Jan 2023 13:11:28 +0100 Subject: [PATCH 8/9] Remove managed from localized test --- .../edge-cases/srv/field-named-localized.cds | 4 +- .../edge-cases/field-named-localized.gql | 54 ------------------- 2 files changed, 2 insertions(+), 56 deletions(-) diff --git a/test/resources/edge-cases/srv/field-named-localized.cds b/test/resources/edge-cases/srv/field-named-localized.cds index 9089726d..2cb150ad 100644 --- a/test/resources/edge-cases/srv/field-named-localized.cds +++ b/test/resources/edge-cases/srv/field-named-localized.cds @@ -1,13 +1,13 @@ using {managed} from '@sap/cds/common'; service FieldNamedLocalizedService { - entity localized : managed { + entity localized { key ID : Integer; root : Association to Root; localized : String; // to test that a property only named 'localized' is not confused with localized keyword } - entity Root : managed { + entity Root { key ID : Integer; // The resulting GraphQL schema should contain a field named // "localized" since it is a user modelled association and not an diff --git a/test/schemas/edge-cases/field-named-localized.gql b/test/schemas/edge-cases/field-named-localized.gql index d24b37b6..03908ca5 100644 --- a/test/schemas/edge-cases/field-named-localized.gql +++ b/test/schemas/edge-cases/field-named-localized.gql @@ -15,34 +15,22 @@ type FieldNamedLocalizedService { type FieldNamedLocalizedService_Root { ID: Int - createdAt: Timestamp - createdBy: String localized( filter: [FieldNamedLocalizedService_localized_filter] orderBy: [FieldNamedLocalizedService_localized_orderBy] skip: Int top: Int ): FieldNamedLocalizedService_localized_connection - modifiedAt: Timestamp - modifiedBy: String } input FieldNamedLocalizedService_Root_C { ID: Int - createdAt: Timestamp - createdBy: String localized: [FieldNamedLocalizedService_localized_C] - modifiedAt: Timestamp - modifiedBy: String } input FieldNamedLocalizedService_Root_U { ID: Int - createdAt: Timestamp - createdBy: String localized: [FieldNamedLocalizedService_localized_U] - modifiedAt: Timestamp - modifiedBy: String } type FieldNamedLocalizedService_Root_connection { @@ -52,10 +40,6 @@ type FieldNamedLocalizedService_Root_connection { input FieldNamedLocalizedService_Root_filter { ID: [Int_filter] - createdAt: [Timestamp_filter] - createdBy: [String_filter] - modifiedAt: [Timestamp_filter] - modifiedBy: [String_filter] } type FieldNamedLocalizedService_Root_input { @@ -73,10 +57,6 @@ type FieldNamedLocalizedService_Root_input { input FieldNamedLocalizedService_Root_orderBy { ID: SortDirection - createdAt: SortDirection - createdBy: SortDirection - modifiedAt: SortDirection - modifiedBy: SortDirection } type FieldNamedLocalizedService_input { @@ -86,33 +66,21 @@ type FieldNamedLocalizedService_input { type FieldNamedLocalizedService_localized { ID: Int - createdAt: Timestamp - createdBy: String localized: String - modifiedAt: Timestamp - modifiedBy: String root: FieldNamedLocalizedService_Root root_ID: Int } input FieldNamedLocalizedService_localized_C { ID: Int - createdAt: Timestamp - createdBy: String localized: String - modifiedAt: Timestamp - modifiedBy: String root: FieldNamedLocalizedService_Root_C root_ID: Int } input FieldNamedLocalizedService_localized_U { ID: Int - createdAt: Timestamp - createdBy: String localized: String - modifiedAt: Timestamp - modifiedBy: String root: FieldNamedLocalizedService_Root_U root_ID: Int } @@ -124,11 +92,7 @@ type FieldNamedLocalizedService_localized_connection { input FieldNamedLocalizedService_localized_filter { ID: [Int_filter] - createdAt: [Timestamp_filter] - createdBy: [String_filter] localized: [String_filter] - modifiedAt: [Timestamp_filter] - modifiedBy: [String_filter] root_ID: [Int_filter] } @@ -147,11 +111,7 @@ type FieldNamedLocalizedService_localized_input { input FieldNamedLocalizedService_localized_orderBy { ID: SortDirection - createdAt: SortDirection - createdBy: SortDirection localized: SortDirection - modifiedAt: SortDirection - modifiedBy: SortDirection root_ID: SortDirection } @@ -188,17 +148,3 @@ input String_filter { ne: String startswith: String } - -""" -The `Timestamp` scalar type represents timestamp values as strings in the ISO 8601 format `YYYY-MM-DDThh-mm-ss.sTZD` with up to 7 digits of fractional seconds. -""" -scalar Timestamp - -input Timestamp_filter { - eq: Timestamp - ge: Timestamp - gt: Timestamp - le: Timestamp - lt: Timestamp - ne: Timestamp -} From 0165ff0fb9ad12c3755ef880294a8376a1bc946e Mon Sep 17 00:00:00 2001 From: Marcel Schwarz Date: Mon, 23 Jan 2023 19:50:58 +0100 Subject: [PATCH 9/9] Rm space --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c7e7f798..0094a9e2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Register `aliasFieldResolver` during schema generation instead of passing it to the GraphQL server - The filters `contains`, `startswith`, and `endswith` now generate CQN function calls instead of generating `like` expressions directly -### Fixed +### Fixed - Fixed a server crash that occurred if an entity property is named `localized`