Skip to content

Latest commit

 

History

History
90 lines (86 loc) · 1.42 KB

README.md

File metadata and controls

90 lines (86 loc) · 1.42 KB

GraphQL API with Spring Boot

This sample application is developed to understand basic concepts of GraphQL. In memory H2 database was used for storage.

Learning Materials:

Queries

Query by employee ID
query {
   employee(employeeId: 1){
     firstName
   }
}
Query by first name
query {
    employeeByFirstName(firstName: "E"){
        employeeId
        firstName
        lastName
    }
}
Query with complex type(Adress)
query{
    employeeByFirstName(firstName: "E"){
        employeeId
        firstName
        lastName
        address{
            city
            state
            country
        }
    }
Query for city
query{
    city(city: "ABC"){
        city
        state
    }
}
Querying multiple types
query{
    employeeByFirstName(firstName: "E"){
        employeeId
        firstName
        lastName
        address{
            city
            state
            country
        }
    }
    
    city(city: "ABC"){
        city
        state
    }
}

Mutations

Add new employee
mutation{
    addEmployee(employeeId: 1, firstName: "G", lastName: "U", department: "WM"){
        firstName
    }
}

Subscriptions

URL: ws://localhost:8080/subscription

subscription NewEmployeeSubscription{
    newEmployee{
        employeeId
    }
}