Skip to content

Commit

Permalink
Update to SAP CAP 6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jung-thomas committed Jul 5, 2022
1 parent 4bc1f1e commit 91e28be
Show file tree
Hide file tree
Showing 5 changed files with 2,464 additions and 5,931 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
[
{
"date": "2022-07-05",
"version": "3.202207.1",
"Changed": [
"Update to SAP Cloud Application Programming Model 6.0 (including switch to GraphQL GA version as well as other technical optimizations)"
]
},
{
"date": "2022-05-20",
"version": "3.202205.4",
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/).

## [3.202207.1] - 2022-07-05

**Changed**

- Update to SAP Cloud Application Programming Model 6.0 (including switch to GraphQL GA version as well as other technical optimizations)

## [3.202205.4] - 2022-05-20

**Changed**
Expand Down
32 changes: 22 additions & 10 deletions bin/cds.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,13 @@ export async function cdsBuild(prompts) {
//
`service HanaCli { `

let vcap = JSON.parse(process.env.VCAP_SERVICES)
vcap.hana[0].credentials.schema = object[0].SCHEMA_NAME
vcap.hana.splice(1, 100)
process.env.VCAP_SERVICES = JSON.stringify(vcap)
if(process.env.VCAP_SERVICES){
let vcap = JSON.parse(process.env.VCAP_SERVICES)
vcap.hana[0].credentials.schema = object[0].SCHEMA_NAME
vcap.hana.splice(1, 100)
process.env.VCAP_SERVICES = JSON.stringify(vcap)
}

cdsSource +=
`@(Capabilities: {
InsertRestrictions: {Insertable: true},
Expand Down Expand Up @@ -192,12 +195,18 @@ async function cdsServerSetup(prompts, cdsSource) {
var app = express()

//CDS OData Service
let vcap = JSON.parse(process.env.VCAP_SERVICES)
let vcap = ''
let options = {
kind: "hana",
logLevel: "error",
credentials: vcap.hana[0].credentials
logLevel: "error"
}
if(process.env.VCAP_SERVICES){
vcap = JSON.parse(process.env.VCAP_SERVICES)
// @ts-ignore
options.credentials = vcap.hana[0].credentials
}

// @ts-ignore
cds.connect(options)
// @ts-ignore
cds.env.requires.db = {}
Expand All @@ -215,6 +224,7 @@ async function cdsServerSetup(prompts, cdsSource) {
base.debug(`GraphQL Entity After ${graphQLEntity}`)
// entity = entity.replace(/:/g, "")


// @ts-ignore
cds.serve('all').from(await cds.parse(cdsSource), {
crashOnError: false
Expand Down Expand Up @@ -349,9 +359,11 @@ async function cdsServerSetup(prompts, cdsSource) {
let serverAddr = `http://localhost:${server.address().port}`
console.info(`HTTP Server: ${serverAddr}`)

//GraphQL Experimental
const GraphQLAdapter = require('@sap/cds/libx/gql/GraphQLAdapter')
app.use(new GraphQLAdapter(cds.services, { graphiql: true }))
//GraphQL
const GraphQLAdapter = require('@sap/cds-graphql/lib')
const adapter = new GraphQLAdapter (cds.services, { graphiql: true, path: '/graphql' })
app.use('/graphql', adapter)
// app.use(new GraphQLAdapter(cds.services, { graphiql: true }))
console.log("serving GraphQL endpoint for all services { at: '/graphql' }")

open(serverAddr)
Expand Down
Loading

0 comments on commit 91e28be

Please sign in to comment.