Skip to content
Closed
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
4 changes: 3 additions & 1 deletion lib/resolvers/crud/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ module.exports = async ({ req, res }, service, entity, selection) => {
const entries = entriesStructureToEntityStructure(service, entity, astToEntries(input))
query.entries(entries)

const result = await service.dispatch(new GraphQLRequest({ req, res, query }))
const cdsReq = new GraphQLRequest({ req, res, query })
const cdsRes = await service.dispatch(cdsReq)
const result = cdsRes.affectedRows ? cdsReq.data : cdsRes

return formatResult(entity, selection, result, false)
}
4 changes: 3 additions & 1 deletion lib/resolvers/crud/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ module.exports = async ({ req, res }, service, entity, selection) => {
resultBeforeUpdate = await tx.dispatch(new GraphQLRequest({ req, res, query: queryBeforeUpdate }))
if (resultBeforeUpdate.length === 0) return {}

return await tx.dispatch(new GraphQLRequest({ req, res, query }))
const cdsReq = new GraphQLRequest({ req, res, query })
const cdsRes = await tx.dispatch(cdsReq)
return typeof cdsRes === 'number' ? cdsReq.data : cdsRes
})

let mergedResults = result
Expand Down
8 changes: 1 addition & 7 deletions test/tests/custom-handlers.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ describe('graphql - custom handlers', () => {
const data = {
ReturnTypesService: {
Integer: {
update: null
update: [{ id: null, string: null }]
},
String: {
update: null
Expand All @@ -184,12 +184,6 @@ describe('graphql - custom handlers', () => {
}
}
const errors = [
{
locations: [{ column: 15, line: 5 }],
message: 'Expected Iterable, but did not find one for field "ReturnTypesService_Integer_input.update".',
path: ['ReturnTypesService', 'Integer', 'update'],
extensions: { stacktrace: expect.any(Array) }
},
{
locations: [{ column: 15, line: 11 }],
message: 'Expected Iterable, but did not find one for field "ReturnTypesService_String_input.update".',
Expand Down
Loading