Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ 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 occourred if an entity property is named `localized`.
- Fixed a server crash that occurred if an entity property is named `localized`
- A bug where the field `totalCount` could not be queried on its own

### Removed
Expand Down
5 changes: 5 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const config = {
testTimeout: 10000
}

module.exports = config
3 changes: 1 addition & 2 deletions lib/resolvers/parse/ast/result.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion lib/schema/types/custom/GraphQLBinary.js
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
2 changes: 1 addition & 1 deletion lib/schema/types/custom/GraphQLDate.js
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
2 changes: 1 addition & 1 deletion lib/schema/types/custom/GraphQLDateTime.js
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
2 changes: 1 addition & 1 deletion lib/schema/types/custom/GraphQLDecimal.js
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
2 changes: 1 addition & 1 deletion lib/schema/types/custom/GraphQLInt16.js
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
2 changes: 1 addition & 1 deletion lib/schema/types/custom/GraphQLInt64.js
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
2 changes: 1 addition & 1 deletion lib/schema/types/custom/GraphQLTime.js
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
2 changes: 1 addition & 1 deletion lib/schema/types/custom/GraphQLTimestamp.js
Original file line number Diff line number Diff line change
@@ -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 =
Expand Down
4 changes: 2 additions & 2 deletions lib/schema/types/custom/GraphQLUInt8.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
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'

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)
Expand Down
10 changes: 2 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down Expand Up @@ -43,12 +44,5 @@
"jest": "^29.3.1",
"prettier": "^2.3.0",
"sqlite3": "^5.0.2"
},
"jest": {
"testTimeout": 10000
},
"repository": {
"type": "git",
"url": "https://github.com/cap-js/cds-adapter-graphql"
}
}
}
4 changes: 2 additions & 2 deletions test/resources/edge-cases/srv/field-named-localized.cds
Original file line number Diff line number Diff line change
@@ -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
Expand Down
54 changes: 0 additions & 54 deletions test/schemas/edge-cases/field-named-localized.gql
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand All @@ -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 {
Expand All @@ -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
}
Expand All @@ -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]
}

Expand All @@ -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
}

Expand Down Expand Up @@ -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
}