|
1 | 1 | # This project is archived in favor of the offical [Spring GraphQL](https://github.com/spring-projects/spring-graphql) integration. |
2 | 2 |
|
3 | | -# GraphQL Java Spring |
4 | | - |
5 | | -## Status |
6 | | - |
7 | | - |
8 | | -Version 2.0 is released. |
9 | | - |
10 | | -We have a [spectrum chat](https://spectrum.chat/graphql-java) for general questions. |
11 | | - |
12 | | - |
13 | | -## Overview |
14 | | - |
15 | | -This project integrates [GraphQL Java](https://github.com/graphql-java/graphql-java) into Spring/Spring Boot, by enabling query execution via HTTP. |
16 | | - |
17 | | -While the GraphQL Specification itself doesn't specify any transport protocol there is a quasi standard how to do it described |
18 | | -[here](https://graphql.org/learn/serving-over-http/) and this project follows this quasi standard. |
19 | | - |
20 | | -Goals / Design: |
21 | | - |
22 | | -- Just HTTP JSON: the current focus is on HTTP execution via JSON. |
23 | | -- Minimal Dependencies: the only dependencies are GraphQL Java and Spring projects (including Jackson for JSON handling). |
24 | | -- No additional abstraction layer on top of GraphQL Java: GraphQL Java is meant to be used directly. |
25 | | - |
26 | | - |
27 | | -## Supported HTTP Requests |
28 | | - |
29 | | -As outlined in https://graphql.org/learn/serving-over-http this project supports: |
30 | | - |
31 | | -1. GET request with `query`, `operationName` and `variables` parameters. The variable parameters are json encoded |
32 | | -2. POST request with body `application/json` and keys `query` (string), `operationName` (string) and `variables` (map). |
33 | | - |
34 | | -Both produce `application/json`. |
35 | | - |
36 | | -## Support for webmvc and webflux |
37 | | - |
38 | | -We support both spring web types: the fully non-blocking `webflux` and the traditional servlet based `webmvc`. |
39 | | - |
40 | | -Please see [here](https://docs.spring.io/spring/docs/current/spring-framework-reference/web-reactive.html#webflux-framework-choice) in |
41 | | -the spring documentation itself about the differences. |
42 | | - |
43 | | - |
44 | | - |
45 | | -## Artifacts |
46 | | - |
47 | | -There are four different artifacts: (all with group id `com.graphql-java`) |
48 | | - |
49 | | -1. `graphql-java-spring-webflux` |
50 | | -2. `graphql-java-spring-boot-starter-webflux` |
51 | | -3. `graphql-java-spring-webmvc` |
52 | | -4. `graphql-java-spring-boot-starter-webmvc` |
53 | | - |
54 | | - |
55 | | - |
56 | | -## Getting started with Spring Boot (webflux and webmvc) |
57 | | - |
58 | | -The Spring Boot Starter artifact provides a HTTP endpoint on `${graphql.url}` with the default value `"/graphql"` just by being on the classpath. |
59 | | - |
60 | | -The only requirement is to have a Bean of type `graphql.GraphQL` available. |
61 | | - |
62 | | -Add the following dependency to your `build.gradle` (make sure `mavenCentral()` is among your repos) |
63 | | - |
64 | | -for webflux: |
65 | | -```groovy |
66 | | -dependencies { |
67 | | - implementation "com.graphql-java:graphql-java-spring-boot-starter-webflux:2.0" |
68 | | -} |
69 | | -``` |
70 | | - |
71 | | -for webmvc: |
72 | | -```groovy |
73 | | -dependencies { |
74 | | - implementation "com.graphql-java:graphql-java-spring-boot-starter-webmvc:2.0" |
75 | | -} |
76 | | -``` |
77 | | - |
78 | | -or to your `pom.xml` |
79 | | - |
80 | | -for webflux |
81 | | -```xml |
82 | | -<dependency> |
83 | | - <groupId>com.graphql-java</groupId> |
84 | | - <artifactId>graphql-java-spring-boot-starter-webflux</artifactId> |
85 | | - <version>2.0</version> |
86 | | -</dependency> |
87 | | - |
88 | | -``` |
89 | | - |
90 | | -for webmvc: |
91 | | -```xml |
92 | | -<dependency> |
93 | | - <groupId>com.graphql-java</groupId> |
94 | | - <artifactId>graphql-java-spring-boot-starter-webmvc</artifactId> |
95 | | - <version>2.0</version> |
96 | | -</dependency> |
97 | | - |
98 | | -``` |
99 | | - |
100 | | -## Ways to customize |
101 | | - |
102 | | - |
103 | | -### Properties |
104 | | - |
105 | | -The following properties are currently available: |
106 | | - |
107 | | -| Property | Description | Default Value | |
108 | | -| --- | --- | --- | |
109 | | -| graphql.url | the endpoint url | graphql | |
110 | | - |
111 | | - |
112 | | -### Beans |
113 | | - |
114 | | -The following Beans can be overridden by providing a different implementation. |
115 | | - |
116 | | -| Interface | Description | |
117 | | -| --- | --- | |
118 | | -| GraphQLInvocation | Executes one request. The default impl just calls the provided `GraphQL` bean.| |
119 | | -| ExecutionResultHandler | Takes a `ExecutionResult` and sends the result back to the client. The default impl returns `ExecutionResult.toSpecification()` as json. | |
120 | | - |
121 | | - |
122 | | - |
123 | 3 |
|
0 commit comments