Skip to content

igocoelho/graphql-with-spring-boot

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

graphql-with-spring-boot

A sample application with GraphQL and Spring Boot

Testing the Application

The application is now ready for testing. Run the Spring Boot application, and open this link — http://localhost:8080/graphiql — in the browser. We will see a nice user interface as below.

User interface

On the right side of user interface, we can also explore documentation.

Documentation explorer

Now, run the following query.

mutation {
  createVehicle(type: "car", modelCode: "XYZ0192", brandName: "XYZ", launchDate: "2016-08-16") 
  {
    id
  }
}

This will create a row in the Vehicle table. The result should be:

{
  "data": {
    "createVehicle": {
      "id": "1"
    }
  }
}

Let's now run a query to get the data.

query {
  vehicles(count: 1) 
  {
    id, 
    type, 
    modelCode
  }
}

The output will be:

{
  "data": {
    "vehicles": [
      {
        "id": "1",
        "type": "bus",
        "modelCode": "XYZ123"
      }
    ]
  }
}

Note that we are requesting for only a limited number of fields, we can change our query by adding or removing fields and see the new results.

About

A sample application with GraphQL and Spring Boot

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%