└── GraphQLDemo
├── target
├── classes
│ ├── application.properties
│ ├── student.xlsx
│ ├── com
│ │ └── quinnox
│ │ │ └── example
│ │ │ ├── model
│ │ │ ├── Product.class
│ │ │ └── Student.class
│ │ │ ├── util
│ │ │ ├── CSVParser.class
│ │ │ └── ExcelReader.class
│ │ │ ├── client
│ │ │ └── GraphQLClient.class
│ │ │ ├── service
│ │ │ └── GraphQLService.class
│ │ │ ├── datafetcher
│ │ │ ├── StudentDataFetcher.class
│ │ │ └── AllStudentDataFetcher.class
│ │ │ ├── repository
│ │ │ └── StudentRepository.class
│ │ │ ├── SpringBootGrapqlExampleApplication.class
│ │ │ └── controller
│ │ │ └── ManagedStudentController.class
│ ├── student.csv2
│ ├── student.graphql
│ ├── books.graphql
│ └── META-INF
│ │ ├── maven
│ │ └── com.techprimers.graphql
│ │ │ └── GraphQLDemo
│ │ │ ├── pom.properties
│ │ │ └── pom.xml
│ │ └── MANIFEST.MF
├── test-classes
│ └── com
│ │ └── techprimers
│ │ └── graphql
│ │ └── springbootgrapqlexample
│ │ └── SpringBootGrapqlExampleApplicationTests.class
└── maven-status
│ └── maven-compiler-plugin
│ └── compile
│ └── default-compile
│ ├── createdFiles.lst
│ └── inputFiles.lst
├── src
├── main
│ ├── resources
│ │ ├── application.properties
│ │ ├── student.xlsx
│ │ ├── student.csv2
│ │ ├── student.graphql
│ │ └── books.graphql
│ └── java
│ │ └── com
│ │ └── quinnox
│ │ └── example
│ │ ├── repository
│ │ └── StudentRepository.java
│ │ ├── SpringBootGrapqlExampleApplication.java
│ │ ├── datafetcher
│ │ ├── StudentDataFetcher.java
│ │ └── AllStudentDataFetcher.java
│ │ ├── util
│ │ ├── CSVParser.java
│ │ └── ExcelReader.java
│ │ ├── controller
│ │ └── ManagedStudentController.java
│ │ ├── model
│ │ ├── Product.java
│ │ └── Student.java
│ │ ├── client
│ │ └── GraphQLClient.java
│ │ └── service
│ │ └── GraphQLService.java
└── test
│ └── java
│ └── com
│ └── techprimers
│ └── graphql
│ └── springbootgrapqlexample
│ └── SpringBootGrapqlExampleApplicationTests.java
├── .settings
├── org.eclipse.jdt.apt.core.prefs
├── org.eclipse.m2e.core.prefs
├── org.eclipse.wst.common.project.facet.core.xml
├── org.eclipse.core.resources.prefs
└── org.eclipse.jdt.core.prefs
├── .mvn
└── wrapper
│ ├── maven-wrapper.jar
│ └── maven-wrapper.properties
├── README.md
├── .project
├── .classpath
├── pom.xml
├── mvnw.cmd
├── mvnw
└── .factorypath
/GraphQLDemo/target/classes/application.properties:
--------------------------------------------------------------------------------
1 | server.port=2222
--------------------------------------------------------------------------------
/GraphQLDemo/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | server.port=2222
--------------------------------------------------------------------------------
/GraphQLDemo/.settings/org.eclipse.jdt.apt.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.jdt.apt.aptEnabled=true
3 |
--------------------------------------------------------------------------------
/GraphQLDemo/target/classes/student.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mohit6350/graphQlcompleteClient/HEAD/GraphQLDemo/target/classes/student.xlsx
--------------------------------------------------------------------------------
/GraphQLDemo/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mohit6350/graphQlcompleteClient/HEAD/GraphQLDemo/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/GraphQLDemo/src/main/resources/student.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mohit6350/graphQlcompleteClient/HEAD/GraphQLDemo/src/main/resources/student.xlsx
--------------------------------------------------------------------------------
/GraphQLDemo/.settings/org.eclipse.m2e.core.prefs:
--------------------------------------------------------------------------------
1 | activeProfiles=
2 | eclipse.preferences.version=1
3 | resolveWorkspaceProjects=true
4 | version=1
5 |
--------------------------------------------------------------------------------
/GraphQLDemo/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.2/apache-maven-3.5.2-bin.zip
2 |
--------------------------------------------------------------------------------
/GraphQLDemo/target/classes/com/quinnox/example/model/Product.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mohit6350/graphQlcompleteClient/HEAD/GraphQLDemo/target/classes/com/quinnox/example/model/Product.class
--------------------------------------------------------------------------------
/GraphQLDemo/target/classes/com/quinnox/example/model/Student.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mohit6350/graphQlcompleteClient/HEAD/GraphQLDemo/target/classes/com/quinnox/example/model/Student.class
--------------------------------------------------------------------------------
/GraphQLDemo/target/classes/com/quinnox/example/util/CSVParser.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mohit6350/graphQlcompleteClient/HEAD/GraphQLDemo/target/classes/com/quinnox/example/util/CSVParser.class
--------------------------------------------------------------------------------
/GraphQLDemo/target/classes/com/quinnox/example/util/ExcelReader.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mohit6350/graphQlcompleteClient/HEAD/GraphQLDemo/target/classes/com/quinnox/example/util/ExcelReader.class
--------------------------------------------------------------------------------
/GraphQLDemo/target/classes/com/quinnox/example/client/GraphQLClient.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mohit6350/graphQlcompleteClient/HEAD/GraphQLDemo/target/classes/com/quinnox/example/client/GraphQLClient.class
--------------------------------------------------------------------------------
/GraphQLDemo/target/classes/com/quinnox/example/service/GraphQLService.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mohit6350/graphQlcompleteClient/HEAD/GraphQLDemo/target/classes/com/quinnox/example/service/GraphQLService.class
--------------------------------------------------------------------------------
/GraphQLDemo/.settings/org.eclipse.wst.common.project.facet.core.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/GraphQLDemo/.settings/org.eclipse.core.resources.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | encoding//src/main/java=UTF-8
3 | encoding//src/main/resources=UTF-8
4 | encoding//src/test/java=UTF-8
5 | encoding/=UTF-8
6 |
--------------------------------------------------------------------------------
/GraphQLDemo/target/classes/com/quinnox/example/datafetcher/StudentDataFetcher.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mohit6350/graphQlcompleteClient/HEAD/GraphQLDemo/target/classes/com/quinnox/example/datafetcher/StudentDataFetcher.class
--------------------------------------------------------------------------------
/GraphQLDemo/target/classes/com/quinnox/example/repository/StudentRepository.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mohit6350/graphQlcompleteClient/HEAD/GraphQLDemo/target/classes/com/quinnox/example/repository/StudentRepository.class
--------------------------------------------------------------------------------
/GraphQLDemo/target/classes/com/quinnox/example/SpringBootGrapqlExampleApplication.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mohit6350/graphQlcompleteClient/HEAD/GraphQLDemo/target/classes/com/quinnox/example/SpringBootGrapqlExampleApplication.class
--------------------------------------------------------------------------------
/GraphQLDemo/target/classes/com/quinnox/example/controller/ManagedStudentController.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mohit6350/graphQlcompleteClient/HEAD/GraphQLDemo/target/classes/com/quinnox/example/controller/ManagedStudentController.class
--------------------------------------------------------------------------------
/GraphQLDemo/target/classes/com/quinnox/example/datafetcher/AllStudentDataFetcher.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mohit6350/graphQlcompleteClient/HEAD/GraphQLDemo/target/classes/com/quinnox/example/datafetcher/AllStudentDataFetcher.class
--------------------------------------------------------------------------------
/GraphQLDemo/target/classes/student.csv2:
--------------------------------------------------------------------------------
1 | 0607cs131008,mohit khare,mohit@gmail.com,New York
2 | 0607cs131009,poonam,poonam@gmail.com,Boston
3 | 0607cs131010,jake,jake@gmail.com,Dallas
4 | 0607cs131011,katelyn,kate@gmail.com,Ohio
5 | 0607cs131012,ryan,ryan@gmail.com,Wisconsin
--------------------------------------------------------------------------------
/GraphQLDemo/src/main/resources/student.csv2:
--------------------------------------------------------------------------------
1 | 0607cs131008,mohit khare,mohit@gmail.com,New York
2 | 0607cs131009,poonam,poonam@gmail.com,Boston
3 | 0607cs131010,jake,jake@gmail.com,Dallas
4 | 0607cs131011,katelyn,kate@gmail.com,Ohio
5 | 0607cs131012,ryan,ryan@gmail.com,Wisconsin
--------------------------------------------------------------------------------
/GraphQLDemo/target/classes/student.graphql:
--------------------------------------------------------------------------------
1 | schema {
2 | query: Query
3 | }
4 |
5 | type Query {
6 | allStudent: [Student]
7 | student(rollNumber: String): Student
8 | }
9 |
10 | type Student {
11 | rollNumber: String
12 | name: String
13 | email: String
14 | address: String
15 | }
--------------------------------------------------------------------------------
/GraphQLDemo/target/test-classes/com/techprimers/graphql/springbootgrapqlexample/SpringBootGrapqlExampleApplicationTests.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mohit6350/graphQlcompleteClient/HEAD/GraphQLDemo/target/test-classes/com/techprimers/graphql/springbootgrapqlexample/SpringBootGrapqlExampleApplicationTests.class
--------------------------------------------------------------------------------
/GraphQLDemo/src/main/resources/student.graphql:
--------------------------------------------------------------------------------
1 | schema {
2 | query: Query
3 | }
4 |
5 | type Query {
6 | allStudent: [Student]
7 | student(rollNumber: String): Student
8 | }
9 |
10 | type Student {
11 | rollNumber: String
12 | name: String
13 | email: String
14 | address: String
15 | }
--------------------------------------------------------------------------------
/GraphQLDemo/target/classes/books.graphql:
--------------------------------------------------------------------------------
1 | schema {
2 | query: Query
3 | }
4 |
5 | type Query {
6 | allBooks: [Book]
7 | book(id: String): Book
8 | }
9 |
10 | type Book {
11 | isn: String
12 | title: String
13 | publisher: String
14 | authors: [String]
15 | publishedDate: String
16 | }
--------------------------------------------------------------------------------
/GraphQLDemo/src/main/resources/books.graphql:
--------------------------------------------------------------------------------
1 | schema {
2 | query: Query
3 | }
4 |
5 | type Query {
6 | allBooks: [Book]
7 | book(id: String): Book
8 | }
9 |
10 | type Book {
11 | isn: String
12 | title: String
13 | publisher: String
14 | authors: [String]
15 | publishedDate: String
16 | }
--------------------------------------------------------------------------------
/GraphQLDemo/.settings/org.eclipse.jdt.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
3 | org.eclipse.jdt.core.compiler.compliance=1.8
4 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
5 | org.eclipse.jdt.core.compiler.processAnnotations=enabled
6 | org.eclipse.jdt.core.compiler.source=1.8
7 |
--------------------------------------------------------------------------------
/GraphQLDemo/target/classes/META-INF/maven/com.techprimers.graphql/GraphQLDemo/pom.properties:
--------------------------------------------------------------------------------
1 | #Generated by Maven Integration for Eclipse
2 | #Tue Jul 09 12:10:34 IST 2019
3 | version=0.0.1-SNAPSHOT
4 | groupId=com.techprimers.graphql
5 | m2e.projectName=GraphQLDemo
6 | m2e.projectLocation=D\:\\MIKE\\CYC\\fourthIteration\\graphQlcompleteClient\\GraphQLDemo
7 | artifactId=GraphQLDemo
8 |
--------------------------------------------------------------------------------
/GraphQLDemo/src/main/java/com/quinnox/example/repository/StudentRepository.java:
--------------------------------------------------------------------------------
1 | package com.quinnox.example.repository;
2 |
3 | import org.springframework.data.jpa.repository.JpaRepository;
4 | import org.springframework.data.repository.CrudRepository;
5 |
6 | import com.quinnox.example.model.Student;
7 |
8 | public interface StudentRepository extends CrudRepository{
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/GraphQLDemo/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst:
--------------------------------------------------------------------------------
1 | com\quinnox\example\datafetcher\AllStudentDataFetcher.class
2 | com\quinnox\example\service\GraphQLService.class
3 | com\quinnox\example\controller\ManagedStudentController.class
4 | com\quinnox\example\model\Student.class
5 | com\quinnox\example\model\Product.class
6 | com\quinnox\example\repository\StudentRepository.class
7 |
--------------------------------------------------------------------------------
/GraphQLDemo/target/classes/META-INF/MANIFEST.MF:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | Implementation-Title: spring-boot-grapql-example
3 | Implementation-Version: 0.0.1-SNAPSHOT
4 | Built-By: MohitK
5 | Implementation-Vendor-Id: com.techprimers.graphql
6 | Build-Jdk: 1.8.0_201
7 | Implementation-URL: https://projects.spring.io/spring-boot/#/spring-bo
8 | ot-starter-parent/GraphQLDemo
9 | Created-By: Maven Integration for Eclipse
10 |
11 |
--------------------------------------------------------------------------------
/GraphQLDemo/src/main/java/com/quinnox/example/SpringBootGrapqlExampleApplication.java:
--------------------------------------------------------------------------------
1 | package com.quinnox.example;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class SpringBootGrapqlExampleApplication {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(SpringBootGrapqlExampleApplication.class, args);
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/GraphQLDemo/src/test/java/com/techprimers/graphql/springbootgrapqlexample/SpringBootGrapqlExampleApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.techprimers.graphql.springbootgrapqlexample;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class SpringBootGrapqlExampleApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/GraphQLDemo/README.md:
--------------------------------------------------------------------------------
1 | # Spring Boot with GraphQL Query Example
2 |
3 | ## Book Store
4 | - `/rest/books` is the REST resource which can fetch Books information
5 | - DataFetchers are Interfaces for RuntimeWiring of GraphQL with JpaRepository
6 |
7 | ## Sample GraphQL Scalar Queries
8 | - Accessible under `http://localhost:8091/rest/books`
9 | - Usage for `allBooks`
10 | `{
11 | allBooks {
12 | isn
13 | title
14 | authors
15 | publisher
16 | }
17 | }`
18 | - Usage for `book`
19 | `{
20 | book(id: "123") {
21 | title
22 | authors
23 | publisher
24 | }`
25 | - Combination of both `allBooks` and `book`
26 | `{
27 | allBooks {
28 | title
29 | authors
30 | }
31 | book(id: "124") {
32 | title
33 | authors
34 | publisher
35 | }
36 | }`
--------------------------------------------------------------------------------
/GraphQLDemo/src/main/java/com/quinnox/example/datafetcher/StudentDataFetcher.java:
--------------------------------------------------------------------------------
1 | package com.quinnox.example.datafetcher;
2 |
3 | import com.quinnox.example.model.Student;
4 | import com.quinnox.example.repository.StudentRepository;
5 |
6 | import graphql.schema.DataFetcher;
7 | import graphql.schema.DataFetchingEnvironment;
8 |
9 | import org.hibernate.criterion.Example;
10 | import org.springframework.beans.factory.annotation.Autowired;
11 | import org.springframework.stereotype.Component;
12 |
13 | @Component
14 | public class StudentDataFetcher implements DataFetcher {
15 |
16 | @Autowired
17 | StudentRepository studentRepository;
18 |
19 | @Override
20 | public Student get(DataFetchingEnvironment dataFetchingEnvironment) {
21 |
22 | String roll = dataFetchingEnvironment.getArgument("rollNumber");
23 | return studentRepository.findById(roll).get();
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/GraphQLDemo/src/main/java/com/quinnox/example/datafetcher/AllStudentDataFetcher.java:
--------------------------------------------------------------------------------
1 | package com.quinnox.example.datafetcher;
2 |
3 |
4 | import com.quinnox.example.model.Student;
5 | import com.quinnox.example.repository.StudentRepository;
6 |
7 | import graphql.schema.DataFetcher;
8 | import graphql.schema.DataFetchingEnvironment;
9 | import org.springframework.beans.factory.annotation.Autowired;
10 | import org.springframework.stereotype.Component;
11 |
12 | import java.util.ArrayList;
13 | import java.util.List;
14 |
15 | @Component
16 | public class AllStudentDataFetcher implements DataFetcher>{
17 |
18 | @Autowired
19 | StudentRepository studentRepository;
20 |
21 | @Override
22 | public List get(DataFetchingEnvironment dataFetchingEnvironment) {
23 | List list = new ArrayList<>();
24 | studentRepository.findAll().forEach(student ->{
25 | list.add(student);
26 | });
27 | return list;
28 | }
29 | }
--------------------------------------------------------------------------------
/GraphQLDemo/src/main/java/com/quinnox/example/util/CSVParser.java:
--------------------------------------------------------------------------------
1 | package com.quinnox.example.util;
2 |
3 | import java.io.BufferedReader;
4 | import java.io.File;
5 | import java.io.FileReader;
6 | import java.util.ArrayList;
7 | import java.util.List;
8 |
9 | import com.quinnox.example.model.Student;
10 |
11 | public class CSVParser {
12 |
13 | public static List parseCSV(File file) throws Exception{
14 | BufferedReader br = new BufferedReader(new FileReader(file));
15 | String line = br.readLine();
16 | List studentList = new ArrayList();
17 | while(line != null){
18 | String[] token = line.split(",");
19 | Student s = mapStudent(new Student(), token);
20 | studentList.add(s);
21 | line = br.readLine();
22 | }
23 | return studentList;
24 | }
25 |
26 | public static Student mapStudent(Student s , String[] token){
27 | s.setRollNumber(token[0]);
28 | s.setName(token[1]);
29 | s.setEmail(token[2]);
30 | s.setAddress(token[3]);
31 | return s;
32 |
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/GraphQLDemo/src/main/java/com/quinnox/example/controller/ManagedStudentController.java:
--------------------------------------------------------------------------------
1 | package com.quinnox.example.controller;
2 |
3 | import graphql.ExecutionResult;
4 | import org.springframework.beans.factory.annotation.Autowired;
5 | import org.springframework.http.HttpStatus;
6 | import org.springframework.http.ResponseEntity;
7 | import org.springframework.web.bind.annotation.PostMapping;
8 | import org.springframework.web.bind.annotation.RequestBody;
9 | import org.springframework.web.bind.annotation.RequestMapping;
10 | import org.springframework.web.bind.annotation.RestController;
11 |
12 | import com.quinnox.example.service.GraphQLService;
13 |
14 | @RequestMapping("/rest/student")
15 | @RestController
16 | public class ManagedStudentController {
17 |
18 | @Autowired
19 | GraphQLService graphQLService;
20 |
21 | @PostMapping(value="/getAllStudent")
22 | public ResponseEntity