Skip to content

singh523/java-graphql-springboot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

java-graphql-springboot

This project is basic an implementation of java-graphql-springboot microservice.

###TODO: Needs to expose rest controllers.

How to run in local

  1. Clone the project
git clone https://github.com/singh523/java-graphql-springboot.git
  1. Service having an implementation with Liquibase and you just need to create a schema testgraphql in your local mysql database and apply the changes for database username & password in application.yaml file.
spring:
  datasource:
    url: jdbc:mysql://localhost:3306/testgraphql
    username: xxxx
    password: xxxx@xxxx
  1. Build & Run
mvn clean install
mvn spring-boot:run

How to test

Once the service is running, you should be able to run the graphql queries via browser.

Access URL in a browser http://localhost:8080/graphiql Below is an example to fetch employees & departments, you should be able to add required fields in input query and the respective fields will be returned in a response:

{
  employees {
    id
    firstName
    department {
      id
      name
    }
  }
}

Response:

{
  "data": {
    "employees": [
      {
        "id": "1",
        "firstName": "John",
        "department": {
          "id": "1",
          "name": "Test1"
        }
      },
      {
        "id": "2",
        "firstName": "Adam",
        "department": {
          "id": "1",
          "name": "Test1"
        }
      },
      {
        "id": "3",
        "firstName": "Tracy",
        "department": {
          "id": "1",
          "name": "Test1"
        }
      },
      {
        "id": "4",
        "firstName": "Lucy",
        "department": {
          "id": "2",
          "name": "Test2"
        }
      },
      {
        "id": "5",
        "firstName": "Peter",
        "department": {
          "id": "4",
          "name": "Test4"
        }
      },
      {
        "id": "6",
        "firstName": "Alan",
        "department": {
          "id": "4",
          "name": "Test4"
        }
      },
      {
        "id": "7",
        "firstName": "Pamela",
        "department": {
          "id": "4",
          "name": "Test4"
        }
      }
    ]
  }
}

About

java-graphql-springboot

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages