Skip to content

Commit ff08691

Browse files
Merge pull request #247 from qudini/QSERVER-17813_GraphQL_FieldDuplicationEnabled
QSERVER-17813 GraphQL Field Duplication Enabled
2 parents 76e93ae + ef6fd52 commit ff08691

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

qudini-reactive-graphql/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ public DataFetcherExceptionHandler graphqlExceptionHandler(...) {
3838
return ...;
3939
}
4040
```
41+
### Query Depth
42+
43+
Your GraphQL Max Query Depth is expected to be available in the classpath, in `application.properties`. `qudini-reactive.graphql-max-depth` is the property name.
44+
Exception is thrown if Query Depth is exceeded. If Property itself is not present, default value 5 is set.
4145

4246
### Wiring
4347

qudini-reactive-graphql/src/main/java/com/qudini/reactive/graphql/http/GraphQLHandler.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44
import com.qudini.reactive.logging.Log;
55
import graphql.ExecutionResult;
66
import graphql.GraphQL;
7+
import graphql.analysis.MaxQueryDepthInstrumentation;
78
import graphql.execution.DataFetcherExceptionHandler;
8-
import graphql.execution.instrumentation.dataloader.DataLoaderDispatcherInstrumentation;
99
import graphql.schema.GraphQLSchema;
1010
import lombok.RequiredArgsConstructor;
1111
import org.dataloader.DataLoaderRegistry;
12+
import org.springframework.beans.factory.annotation.Value;
1213
import org.springframework.core.ParameterizedTypeReference;
1314
import org.springframework.web.reactive.function.server.ServerRequest;
1415
import org.springframework.web.reactive.function.server.ServerResponse;
@@ -28,6 +29,9 @@ public final class GraphQLHandler {
2829
private final GraphQLSchema schema;
2930
private final DataFetcherExceptionHandler exceptionHandler;
3031

32+
@Value("${qudini-reactive.graphql-max-depth:5}")
33+
private Integer maxDepth;
34+
3135
public Mono<ServerResponse> postJson(ServerRequest request) {
3236
return Mono
3337
.deferContextual(Mono::just)
@@ -42,7 +46,7 @@ private Mono<Map<String, Object>> execute(ContextView context, GraphQLRequest re
4246
var input = request.toExecutionInput(context, registry);
4347
var graphql = GraphQL
4448
.newGraphQL(schema)
45-
.instrumentation(new DataLoaderDispatcherInstrumentation())
49+
.instrumentation(new MaxQueryDepthInstrumentation(maxDepth))
4650
.defaultDataFetcherExceptionHandler(exceptionHandler)
4751
.build();
4852
return Log

0 commit comments

Comments
 (0)