Skip to content

Commit 4a0da77

Browse files
authored
feat: allow services that are not instances of cds.ApplicationService (#72)
* Allow services that are not instances of cds.ApplicationService * Add changelog entry * Improve changelog entry * Improve changelog entry
1 parent c5ae273 commit 4a0da77

File tree

4 files changed

+1
-9
lines changed

4 files changed

+1
-9
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1616
+ Delete mutations return the length of an array that is returned by a `DELETE` custom handler or 1 if a single object is returned
1717
- Don't generate fields for key elements in update input objects
1818
- Update and delete mutations have mandatory `filter` argument
19+
- 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.
1920

2021
### Fixed
2122

lib/resolvers/root.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
const cds = require('@sap/cds/lib')
21
const { gqlName } = require('../utils')
32
const resolveQuery = require('./query')
43
const resolveMutation = require('./mutation')
@@ -50,8 +49,6 @@ module.exports = services => {
5049

5150
for (const key in services) {
5251
const service = services[key]
53-
if (!(service instanceof cds.ApplicationService)) continue
54-
5552
const gqlServiceName = gqlName(service.name)
5653
Query[gqlServiceName] = _wrapResolver(service, resolveQuery, true)
5754
Mutation[gqlServiceName] = _wrapResolver(service, resolveMutation, false)

lib/schema/mutation.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
const cds = require('@sap/cds/lib')
21
const { GraphQLObjectType, GraphQLList, GraphQLInt, GraphQLNonNull } = require('graphql')
32
const { gqlName } = require('../utils')
43
const objectGenerator = require('./types/object')
@@ -12,8 +11,6 @@ module.exports = cache => {
1211

1312
for (const key in services) {
1413
const service = services[key]
15-
if (!(service instanceof cds.ApplicationService)) continue
16-
1714
const serviceName = gqlName(service.name)
1815
const resolve = resolvers[serviceName]
1916
const type = _serviceToObjectType(service)

lib/schema/query.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
const cds = require('@sap/cds/lib')
21
const { GraphQLObjectType } = require('graphql')
32
const { gqlName } = require('../utils')
43
const objectGenerator = require('./types/object')
@@ -10,8 +9,6 @@ module.exports = cache => {
109

1110
for (const key in services) {
1211
const service = services[key]
13-
if (!(service instanceof cds.ApplicationService)) continue
14-
1512
const serviceName = gqlName(service.name)
1613
const resolve = resolvers[serviceName]
1714
fields[serviceName] = { type: _serviceToObjectType(service), resolve }

0 commit comments

Comments
 (0)