generated from SAP/repository-template
-
Notifications
You must be signed in to change notification settings - Fork 10
feat: improve handling of various return types from custom handlers #69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
448c203
Add tests for handling different return types from custom handlers
schwma 73c5dcf
Fix test description typo
schwma a836929
Return 1 for objects and array.length for arrays set in delete custom…
schwma 26dc385
Only wrap objects in arrays instead of all types in CUD resolvers
schwma 0979766
Use mergedResults instead of result in update
schwma c6a6306
Use isPlainObject helper instead of typeof object
schwma 7b98a2e
Add is not array check to isPlainObject helper
schwma 3aa8900
Improve comment
schwma e898cea
Merge branch 'main' into custom-handlers
schwma 38be8e2
Add changelog entries
schwma f849a3f
Improve changelog entries
schwma 72b1e45
Return {} instead of [] for no update needed guard clause
schwma 5595c70
Changelog entry wording
schwma ba64049
Fix and improve changelog entries
schwma File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| const cds = require('@sap/cds') | ||
| const path = require('path') | ||
|
|
||
| cds.env.protocols = { | ||
| graphql: { path: '/graphql', impl: path.join(__dirname, '../../../index.js') } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| service ReturnTypesService { | ||
| entity Integer { | ||
| key id : UUID; | ||
| string : cds.String; | ||
| } | ||
|
|
||
| entity String { | ||
| key id : UUID; | ||
| string : cds.String; | ||
| } | ||
|
|
||
| entity Object { | ||
| key id : UUID; | ||
| string : cds.String; | ||
| } | ||
|
|
||
| entity Array { | ||
| key id : UUID; | ||
| string : cds.String; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| module.exports = srv => { | ||
| const string = 'foo' | ||
| const id = '0557a188-326e-4dcb-999b-e1acf7979fa3' | ||
|
|
||
| srv.on('*', 'Integer', () => 999) | ||
| srv.on('*', 'String', () => string) | ||
| srv.on('*', 'Object', () => ({ id, string })) | ||
| srv.on('*', 'Array', () => [{ id, string }, { id, string }]) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so strings, numbers, buffers, etc. shall still be returned as provided?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, the GraphQL server framework will return an error such as
'Int cannot represent non-integer value: "foo"', since the return type of delete mutations is an integer