|
1 | 1 | package graphql.execution; |
2 | 2 |
|
3 | 3 |
|
| 4 | +import java.util.Collections; |
| 5 | +import java.util.List; |
| 6 | +import java.util.Map; |
| 7 | +import java.util.concurrent.CompletableFuture; |
| 8 | +import org.slf4j.Logger; |
| 9 | +import org.slf4j.LoggerFactory; |
| 10 | + |
4 | 11 | import graphql.ExecutionInput; |
5 | 12 | import graphql.ExecutionResult; |
6 | 13 | import graphql.ExecutionResultImpl; |
7 | 14 | import graphql.GraphQLError; |
8 | 15 | import graphql.Internal; |
9 | | -import graphql.MutationNotSupportedError; |
| 16 | +import graphql.OperationNotSupportedError; |
10 | 17 | import graphql.execution.instrumentation.Instrumentation; |
11 | 18 | import graphql.execution.instrumentation.InstrumentationContext; |
12 | 19 | import graphql.execution.instrumentation.InstrumentationState; |
|
20 | 27 | import graphql.language.VariableDefinition; |
21 | 28 | import graphql.schema.GraphQLObjectType; |
22 | 29 | import graphql.schema.GraphQLSchema; |
23 | | -import org.slf4j.Logger; |
24 | | -import org.slf4j.LoggerFactory; |
25 | | - |
26 | | -import java.util.Collections; |
27 | | -import java.util.List; |
28 | | -import java.util.Map; |
29 | | -import java.util.concurrent.CompletableFuture; |
30 | 30 |
|
31 | 31 | import static graphql.Assert.assertShouldNeverHappen; |
32 | 32 | import static graphql.execution.ExecutionContextBuilder.newExecutionContextBuilder; |
@@ -114,7 +114,14 @@ private CompletableFuture<ExecutionResult> executeOperation(ExecutionContext exe |
114 | 114 | // for the record earlier code has asserted that we have a query type in the schema since the spec says this is |
115 | 115 | // ALWAYS required |
116 | 116 | if (operation == MUTATION && operationRootType == null) { |
117 | | - CompletableFuture<ExecutionResult> resultCompletableFuture = completedFuture(new ExecutionResultImpl(Collections.singletonList(new MutationNotSupportedError()))); |
| 117 | + OperationNotSupportedError mutationNotSupportedError = new OperationNotSupportedError("Schema is not configured for mutations.", operationDefinition.getSourceLocation()); |
| 118 | + CompletableFuture<ExecutionResult> resultCompletableFuture = completedFuture( |
| 119 | + new ExecutionResultImpl(Collections.singletonList(mutationNotSupportedError))); |
| 120 | + executionDispatchCtx.onEnd(resultCompletableFuture, null); |
| 121 | + return resultCompletableFuture; |
| 122 | + } else if (operation == SUBSCRIPTION && operationRootType == null) { |
| 123 | + OperationNotSupportedError subscriptionNotSupportedError = new OperationNotSupportedError("Schema is not configured for subscriptions.", operationDefinition.getSourceLocation()); |
| 124 | + CompletableFuture<ExecutionResult> resultCompletableFuture = completedFuture(new ExecutionResultImpl(Collections.singletonList(subscriptionNotSupportedError))); |
118 | 125 | executionDispatchCtx.onEnd(resultCompletableFuture, null); |
119 | 126 | return resultCompletableFuture; |
120 | 127 | } |
|
0 commit comments