-
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
Conversation
| if (isPlainObject(result)) return 1 | ||
| if (Array.isArray(result)) return result.length | ||
|
|
||
| return result |
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?
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
sjvans
left a comment
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.
🏂
* update changelog (#65) * fix version for hotfix * Add version 0.5.0 changelog section * Bump version in package.json to 0.5.0 * feat: improve handling of various return types from custom handlers (#69) * Add tests for handling different return types from custom handlers * Fix test description typo * Return 1 for objects and array.length for arrays set in delete custom handlers * Only wrap objects in arrays instead of all types in CUD resolvers * Use mergedResults instead of result in update * Use isPlainObject helper instead of typeof object * Add is not array check to isPlainObject helper * Improve comment * Add changelog entries * Improve changelog entries * Return {} instead of [] for no update needed guard clause * Changelog entry wording * Fix and improve changelog entries * Tests: prepare for changes in sap/cds/common (`minorUnit`) (#70) The persisted test schema for `bookshop-graphql` fails with the upcoming new field `minorUnit` in `sap.common.Currencies. As a fix, allow the schema to specify their min. cds version. Skip them if they fail this test. * Delete LICENSES directory * feat: don't generate keys in update input object (#71) * Don't generate keys in update input object * Regenerate schemas * Add changelog entry * Add todos * Move suffix const into function * Nested input objects in update are create input objects * Omit generation of update input argument if input object has no fields * Regenerate schemas * Don't generate CUD mutation fields when args are missing * Improve changelog entry wording * Improve readability of object creation * Ensure mutation related fields are not generated if subfields are empty * Extract creation of CUD fields to separate functions * Move creation of args input objects into functions since they are cached * Reorder vars and comments * Prettier format * fix: aligned `cds.Request` instantiation with other protocols (#61) * Add test for HTTP header access in custom handlers * Add cds.request custom handler tests for CUD * Use cds.Request and srv.dispatch instead of srv.run * Pass req directly instead of wrapped in context * Add changelog entry * Use `@sap/cds/lib` instead of `@sap/cds` * Rename request test project to cds.Request * Add tests for res in custom handlers * Add res to context and cds.Request initialization * Move changelog entry to latest planned release * Deconstruct context in function args * Improve changelog entry * Filter is mandatory for update und delete mutation * revert * Update CHANGELOG.md Co-authored-by: Marcel Schwarz <marcel.schwarz@sap.com> * fix * 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 * add changelog date (#74) * update changelog date --------- Co-authored-by: Marcel Schwarz <marcel.schwarz@sap.com> Co-authored-by: Christian Georgi <chgeo@users.noreply.github.com> Co-authored-by: Daniel Hutzel <daniel.hutzel@sap.com> Co-authored-by: Mariya Yordanova <mariya.yordanova@sap.com>
No description provided.