8000 GitHub - under-control-software/graphql-java-http-example: An example of graphql-java in a HTTP application customized for our use · GitHub
[go: up one dir, main page]

Skip to content

under-control-software/graphql-java-http-example

 
 

Repository files navigation

graphql-java-http-example

About

An example of using graphql-java in a HTTP application.

Features

  • It demonstrates the use of graphql IDL to define a schema in a textual way.
  • It also shows how to use data loader to ensure that most efficient way to load inside a graphql query.
  • Connects and retrieves data from a local MongoDB database, with connection pooling implemented.
  • Caches the results using Google Guava package, thus reducing response times.
  • Supports GraphQL query and mutation types for creation and updation operations. Check out the schema file.
  • Also provides individual mongodb query execution times in the response.

Quick Start

  • Make sure you have mongodb and Java JDK 8 installed.
  • Start up the mongod service and create a database called 'starwardb'. Insert data into collections 'humans' and 'droids' following the schema provided.
  • The test data is provided in the files human.json and droid.json. Upload them using the following commands:
$ mongoimport --db starwardb --collection humans --file human.json --jsonArray
$ mongoimport --db starwardb --collection droids --file droid.json --jsonArray
  • Run the following in the root directory of this project:
$ ./gradlew build
$ ./gradlew run

Example query:

query{
  human(id: "50002"){
    id
    name
    appearsIn
    queryTime
  }
}

Server Endpoints

  1. /graphql: For retrieving, creating and updating data.
  2. /clearcache: For invalidating the cache.

Virtual Machine Setup

Head over to docker-2 branch for the read-write VM setup.

About

An example of graphql-java in a HTTP application customized for our use

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Java 86.0%
  • HTML 14.0%
0