You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+1-173Lines changed: 1 addition & 173 deletions
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@ This project wraps the Java implementation of GraphQL provided by [GraphQL Java]
9
9
See [GraphQL Java documentation](https://www.graphql-java.com/documentation/latest/) for more in depth details
10
10
regarding GraphQL Java itself.
11
11
12
-
We try to stay up to date with GraphQL Java as much as possible. The current version supports **GraphQL Java 11.0**.
12
+
We try to stay up to date with GraphQL Java as much as possible. The current version supports **GraphQL Java 14.0**.
13
13
14
14
This project requires at least Java 8.
15
15
@@ -103,67 +103,13 @@ The servlet supports the following request formats:
103
103
* POST multipart parts named "query", "operationName" (optional), and "variables" (optional)
104
104
* POST with Content Type "application/graphql" will treat the HTTP POST body contents as the GraphQL query string
105
105
106
-
## Servlet Listeners
107
-
108
-
You can also add [servlet listeners](https://github.com/graphql-java-kickstart/graphql-java-servlet/blob/master/src/main/java/graphql/servlet/GraphQLServletListener.java) to an existing servlet.
109
-
These listeners provide hooks into query execution (before, success, failure, and finally) and servlet execution (before, success, error, and finally):
Relay.js support is provided by the [EnhancedExecutionStrategy](https://github.com/graphql-java/graphql-java-annotations/blob/master/src/main/java/graphql/annotations/EnhancedExecutionStrategy.java) of [graphql-java-annotations](https://github.com/graphql-java/graphql-java-annotations).
159
109
You **MUST** pass this execution strategy to the servlet for Relay.js support.
160
110
161
111
This is the default execution strategy for the `OsgiGraphQLHttpServlet`, and must be added as a dependency when using that servlet.
162
112
163
-
## Apollo support
164
-
165
-
Query batching is supported, no configuration required.
166
-
167
113
## Spring Framework support
168
114
169
115
To use the servlet with Spring Framework, either use the [Spring Boot starter](https://github.com/graphql-java/graphql-spring-boot) or simply define a `ServletRegistrationBean` in a web app:
The [OsgiGraphQLHttpServlet](https://github.com/graphql-java-kickstart/graphql-java-servlet/blob/master/src/main/java/graphql/servlet/OsgiGraphQLHttpServlet.java) uses a "provider" model to supply the servlet with the required objects:
180
-
*[GraphQLQueryProvider](https://github.com/graphql-java-kickstart/graphql-java-servlet/blob/master/src/main/java/graphql/servlet/GraphQLQueryProvider.java): Provides query fields to the GraphQL schema.
181
-
*[GraphQLMutationProvider](https://github.com/graphql-java-kickstart/graphql-java-servlet/blob/master/src/main/java/graphql/servlet/GraphQLMutationProvider.java): Provides mutation fields to the GraphQL schema.
182
-
*[GraphQLTypesProvider](https://github.com/graphql-java-kickstart/graphql-java-servlet/blob/master/src/main/java/graphql/servlet/GraphQLTypesProvider.java): Provides type information to the GraphQL schema.
183
-
*[ExecutionStrategyProvider](https://github.com/graphql-java-kickstart/graphql-java-servlet/blob/master/src/main/java/graphql/servlet/ExecutionStrategyProvider.java): Provides an execution strategy for running each query.
184
-
*[GraphQLContextBuilder](https://github.com/graphql-java-kickstart/graphql-java-servlet/blob/master/src/main/java/graphql/servlet/GraphQLContextBuilder.java): Builds a context for running each query.
185
-
186
-
## Examples
187
-
188
-
You can now find some example on how to use graphql-java-servlet.
189
-
190
-
### OSGi Examples
191
-
192
-
#### Requirements
193
-
194
-
The OSGi examples use Maven as a build tool because it requires plugins that are not (yet) available for Gradle.
195
-
Therefore you will need Maven 3.2+.
196
-
197
-
#### Building & running the OSGi examples
198
-
199
-
You can build the OSGi examples sub-projects by simply executing the following command from the examples/osgi directory:
200
-
201
-
mvn clean install
202
-
203
-
This will generate a complete Apache Karaf distribution in the following files:
It is possible to create context, and consequently dataloaders, in both a request scope and a per query scope by customizing [GraphQLContextBuilder](https://github.com/graphql-java-kickstart/graphql-java-servlet/blob/master/src/main/java/graphql/servlet/context/GraphQLContextBuilder.java) and selecting the appropriate [ContextSetting](https://github.com/graphql-java-kickstart/graphql-java-servlet/blob/master/src/main/java/graphql/servlet/context/ContextSetting.java) with the provided [GraphQLConfiguration](https://github.com/graphql-java-kickstart/graphql-java-servlet/blob/master/src/main/java/graphql/servlet/config/GraphQLConfiguration.java).
239
-
A new [DataLoaderRegistry](https://github.com/graphql-java/java-dataloader/blob/master/src/main/java/org/dataloader/DataLoaderRegistry.java) should be created in each call to the GraphQLContextBuilder, and the servlet will call the builder at the appropriate times.
It is then possible to access the [DataLoader](https://github.com/graphql-java/java-dataloader/blob/master/src/main/java/org/dataloader/DataLoader.java) in the resolvers by accessing the [DataLoaderRegistry] from context. For eg:
281
-
```java
282
-
publicCompletableFuture<String> getEmailAddress(User user, DataFetchingEnvironment dfe) { // User is the graphQL type
If per request is selected this will cause all queries within the http request, if using a batch, to share dataloader caches and batch together load calls as efficently as possible. The dataloaders are dispatched using instrumentation and the correct instrumentation will be selected according to the ContextSetting. The default context setting in GraphQLConfiguration is per query.
292
-
293
-
Two additional context settings are provided, one for each of the previous settings but without the addition of the Dataloader dispatching instrumentation. This is useful for those not using Dataloaders or wanting to supply their own dispatching instrumentation though the instrumentation supplier within the GraphQLQueryInvoker.
0 commit comments