Skip to content

Commit 1b61688

Browse files
committed
implement requested changes
issue spring-projects#3501
1 parent 9df8468 commit 1b61688

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

spring-integration-graphql/src/main/java/org/springframework/integration/graphql/outbound/GraphQlMessageHandler.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ public GraphQlMessageHandler(final GraphQlService graphQlService) {
6161
* @param query the GraphQL query to use.
6262
*/
6363
public void setQuery(String query) {
64+
Assert.hasText(query, "'query' must not be empty");
6465
setQueryExpression(new LiteralExpression(query));
6566
}
6667

@@ -107,20 +108,23 @@ protected final void doInit() {
107108

108109
@Override
109110
protected Object handleRequestMessage(Message<?> requestMessage) {
111+
RequestInput requestInput = null;
110112

111113
if (requestMessage.getPayload() instanceof RequestInput) {
112114

113-
return this.graphQlService
114-
.execute((RequestInput) requestMessage.getPayload());
115+
requestInput = (RequestInput) requestMessage.getPayload();
115116
}
116117
else {
117118
Assert.notNull(this.queryExpression, "'queryExpression' must not be null");
118119
String query = evaluateQueryExpression(requestMessage);
119120
String operationName = evaluateOperationNameExpression(requestMessage);
120121
Map<String, Object> variables = evaluateVariablesExpression(requestMessage);
121-
return this.graphQlService
122-
.execute(new RequestInput(query, operationName, variables));
122+
requestInput = new RequestInput(query, operationName, variables);
123123
}
124+
125+
return this.graphQlService
126+
.execute(requestInput);
127+
124128
}
125129

126130
private String evaluateQueryExpression(Message<?> message) {
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1+
/**
2+
* Provides classes for outbound channel adapters over GraphQL.
3+
*/
14
package org.springframework.integration.graphql.outbound;

src/reference/asciidoc/graphql.adoc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,17 @@ Spring Integration provides support for GraphQL.
66
You need to include this dependency into your project:
77

88
====
9+
[source, xml, subs="normal", role="primary"]
910
.Maven
10-
[source, xml, subs="normal"]
1111
----
1212
<dependency>
1313
<groupId>org.springframework.integration</groupId>
1414
<artifactId>spring-integration-graphql</artifactId>
1515
<version>{project-version}</version>
1616
</dependency>
1717
----
18-
18+
[source, groovy, subs="normal", role="secondary"]
1919
.Gradle
20-
[source, groovy, subs="normal"]
2120
----
2221
compile "org.springframework.integration:spring-integration-graphql:{project-version}"
2322
----

0 commit comments

Comments
 (0)