graphql
This commit is contained in:
1
graphql/.env
Normal file
1
graphql/.env
Normal file
@@ -0,0 +1 @@
|
||||
PORT = 4007
|
||||
4
graphql/db/data/sap.capire.graphql-Chapters.csv
Normal file
4
graphql/db/data/sap.capire.graphql-Chapters.csv
Normal file
@@ -0,0 +1,4 @@
|
||||
book_ID;number;title
|
||||
201;1;Chapter 1
|
||||
201;2;Chapter 2
|
||||
201;3;Chapter 3
|
||||
|
15
graphql/db/schema.cds
Normal file
15
graphql/db/schema.cds
Normal file
@@ -0,0 +1,15 @@
|
||||
using {managed} from '@sap/cds/common';
|
||||
using {sap.capire.bookshop} from '@capire/bookshop';
|
||||
|
||||
namespace sap.capire.graphql;
|
||||
|
||||
extend bookshop.Books with {
|
||||
chapters : Composition of many Chapters
|
||||
on chapters.book = $self;
|
||||
}
|
||||
|
||||
entity Chapters : managed {
|
||||
key book : Association to bookshop.Books;
|
||||
key number : Integer;
|
||||
title : String;
|
||||
}
|
||||
1
graphql/examples.http
Normal file
1
graphql/examples.http
Normal file
@@ -0,0 +1 @@
|
||||
GET http://localhost:4007/graphql?query={AdminService{Books{title,chapters{number,title}}}}
|
||||
16
graphql/examples.md
Normal file
16
graphql/examples.md
Normal file
@@ -0,0 +1,16 @@
|
||||
1. open `http://localhost:4007/graphql`
|
||||
2. paste into left field:
|
||||
```graphql
|
||||
{
|
||||
AdminService {
|
||||
Books {
|
||||
title
|
||||
chapters {
|
||||
number
|
||||
title
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
3. press play button
|
||||
16
graphql/package.json
Normal file
16
graphql/package.json
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"name": "@capire/graphql",
|
||||
"version": "1.0.0",
|
||||
"dependencies": {
|
||||
"@capire/bookshop": "*",
|
||||
"@graphql-tools/schema": "^8.3.1",
|
||||
"@sap/cds": "^5.6",
|
||||
"express-graphql": "^0.12.0",
|
||||
"graphql": "^16.0.1"
|
||||
},
|
||||
"cds": {
|
||||
"features": {
|
||||
"graphql": true
|
||||
}
|
||||
}
|
||||
}
|
||||
5
graphql/srv/admin-service.cds
Normal file
5
graphql/srv/admin-service.cds
Normal file
@@ -0,0 +1,5 @@
|
||||
using {sap.capire.graphql} from '../db/schema';
|
||||
|
||||
extend service AdminService with {
|
||||
entity Chapters as projection on graphql.Chapters;
|
||||
}
|
||||
Reference in New Issue
Block a user