SAP Community Call

This commit is contained in:
sjvans
2022-02-24 08:30:26 +01:00
parent b13ed5cc8d
commit d53d4de105
8 changed files with 62 additions and 2763 deletions

20
graphql/server.js Normal file
View File

@@ -0,0 +1,20 @@
const cds = require('@sap/cds')
// redeploy the db incl. initial data for demo purposes
cds.on('bootstrap', app => {
app.post('/redeploy', async (req, res) => {
await cds.deploy('*')
res.status(204).end()
})
})
// fix cds.context not being set correctly in GraphQL adapter
cds.on('serving', srv => {
const { dispatch } = srv
srv.dispatch = function(req) {
if (!(cds.context instanceof cds.Request)) cds.context = this
return dispatch.call(this, req)
}
})
module.exports = cds.server