This commit is contained in:
sjvans
2021-11-04 17:31:57 +01:00
parent eaaf0d29a5
commit b13ed5cc8d
9 changed files with 173 additions and 1 deletions

1
graphql/.env Normal file
View File

@@ -0,0 +1 @@
PORT = 4007

View File

@@ -0,0 +1,4 @@
book_ID;number;title
201;1;Chapter 1
201;2;Chapter 2
201;3;Chapter 3
1 book_ID number title
2 201 1 Chapter 1
3 201 2 Chapter 2
4 201 3 Chapter 3

15
graphql/db/schema.cds Normal file
View 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
View File

@@ -0,0 +1 @@
GET http://localhost:4007/graphql?query={AdminService{Books{title,chapters{number,title}}}}

16
graphql/examples.md Normal file
View 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
View 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
}
}
}

View File

@@ -0,0 +1,5 @@
using {sap.capire.graphql} from '../db/schema';
extend service AdminService with {
entity Chapters as projection on graphql.Chapters;
}