From e3f12c9858d491d6bdcf29a5ad9428e622e78831 Mon Sep 17 00:00:00 2001 From: Marcel Schwarz Date: Fri, 14 Apr 2023 15:10:48 +0200 Subject: [PATCH 1/4] Allow services that are not instances of cds.ApplicationService --- lib/resolvers/root.js | 3 --- lib/schema/mutation.js | 3 --- lib/schema/query.js | 3 --- 3 files changed, 9 deletions(-) diff --git a/lib/resolvers/root.js b/lib/resolvers/root.js index 35d4bfe9..f6f72982 100644 --- a/lib/resolvers/root.js +++ b/lib/resolvers/root.js @@ -1,4 +1,3 @@ -const cds = require('@sap/cds/lib') const { gqlName } = require('../utils') const resolveQuery = require('./query') const resolveMutation = require('./mutation') @@ -50,8 +49,6 @@ module.exports = services => { for (const key in services) { const service = services[key] - if (!(service instanceof cds.ApplicationService)) continue - const gqlServiceName = gqlName(service.name) Query[gqlServiceName] = _wrapResolver(service, resolveQuery, true) Mutation[gqlServiceName] = _wrapResolver(service, resolveMutation, false) diff --git a/lib/schema/mutation.js b/lib/schema/mutation.js index f62f2aa3..8cd330f3 100644 --- a/lib/schema/mutation.js +++ b/lib/schema/mutation.js @@ -1,4 +1,3 @@ -const cds = require('@sap/cds/lib') const { GraphQLObjectType, GraphQLList, GraphQLInt, GraphQLNonNull } = require('graphql') const { gqlName } = require('../utils') const objectGenerator = require('./types/object') @@ -12,8 +11,6 @@ module.exports = cache => { for (const key in services) { const service = services[key] - if (!(service instanceof cds.ApplicationService)) continue - const serviceName = gqlName(service.name) const resolve = resolvers[serviceName] fields[serviceName] = { type: _serviceToObjectType(service), resolve } diff --git a/lib/schema/query.js b/lib/schema/query.js index 43e07cdd..cef914f6 100644 --- a/lib/schema/query.js +++ b/lib/schema/query.js @@ -1,4 +1,3 @@ -const cds = require('@sap/cds/lib') const { GraphQLObjectType } = require('graphql') const { gqlName } = require('../utils') const objectGenerator = require('./types/object') @@ -10,8 +9,6 @@ module.exports = cache => { for (const key in services) { const service = services[key] - if (!(service instanceof cds.ApplicationService)) continue - const serviceName = gqlName(service.name) const resolve = resolvers[serviceName] fields[serviceName] = { type: _serviceToObjectType(service), resolve } From 35034b559691f77f886be728c37f5149e8a8227d Mon Sep 17 00:00:00 2001 From: Marcel Schwarz Date: Fri, 14 Apr 2023 15:11:42 +0200 Subject: [PATCH 2/4] Add changelog entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 824578d3..03efd165 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - 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 +- Allow services that are not instances of `cds.ApplicationService` ### Fixed From c525ecb3b917c46b9d69897174a89382693b7f72 Mon Sep 17 00:00:00 2001 From: Marcel Schwarz Date: Tue, 25 Apr 2023 12:10:55 +0200 Subject: [PATCH 3/4] Improve changelog entry --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6edf7a96..198fe7ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,7 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 + 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 -- Allow services that are not instances of `cds.ApplicationService` +- Allow services that are not instances of `cds.ApplicationService`. It is expected that the invoker provides the correct set of service providers. ### Fixed From 0b6d254af81710c7339c85c12f8d7d051a316005 Mon Sep 17 00:00:00 2001 From: Marcel Schwarz Date: Tue, 25 Apr 2023 12:21:47 +0200 Subject: [PATCH 4/4] Improve changelog entry --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3cf3833b..048f84bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,7 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 + 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 -- Allow services that are not instances of `cds.ApplicationService`. It is expected that the invoker provides the correct set of service providers. +- 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 adpater API. ### Fixed