For further reference, please consider the following sections:
- Official Apache Maven documentation
- Spring Boot Maven Plugin Reference Guide
- Create an OCI image
- Spring Web
- Spring Data JPA
The following guides illustrate how to use some features concretely:
- Building a RESTful Web Service
- Serving Web Content with Spring MVC
- Building REST services with Spring
- Accessing Data with JPA
- GraphQL - Getting started with Spring Boot
Demo application with H2 database to test some GraphQL features.
- GraphQL Query - GET data
- GraphQL Mutation - Create, Update, Delete data
- GraphQL Schema - Define which attributes are there in your class data type.
- GraphQL Vs REST API:
- REST is having fixed response while GraphQL provides flexibility;
- REST has different http methods and separate endpoints to each API, while in GraphQL whe have Query and Mutation and there is only one endpoint;
- GraphQL needs Schema file while REST does not need that.
- Node and Edge in GraphQL:
- Node(Table - PK) ---->(Edge) Node(Table - PK; FK)
-
Plugin for Google Chrome to run querys: Altair GraphQL Client
-
Query's:
query { fullName(sampleRequest: { firstName: "Tiago", lastName: "Jesus" }) }
Get Student By Id (dynamic fields, can add or remove fields):
query { student(id: 1){ id firstName lastName email street city } }
Query with list:
query{ student(id: 2){ id firstName lastName learningSubjects { subjectName marksObtained } } }
query{ student(id: 2){ id firstName lastName learningSubjects { subjectName marksObtained } fullName } }
Query with filtered data:
- subjectNameFilter (Enum): All, Java, MySQL, MongoDB
query{ student(id: 2){ id firstName lastName learningSubjects(subjectNameFilter: Java) { subjectName marksObtained } fullName } }
Query to create (Mutation - POST):
mutation{ createStudent(createStudentDTO:{ firstName: "TM" lastName: "91" email: "tm91@test.com" street: "test" city: "test" subjectsLearning: [ { subjectName: "Java" marksObtained: 100.00 } { subjectName: "Ruby" marksObtained: 60.00 } ] }) { id firstName lastName email street city learningSubjects(subjectNameFilter: All) { id subjectName marksObtained } fullName } } }