Skip to content

Commit fdd9568

Browse files
committed
This adds support for QueryAppliedDirective on operations and documents -added more tests
1 parent 17e7ccd commit fdd9568

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

src/test/groovy/graphql/execution/directives/OperationDirectivesResolverTest.groovy

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package graphql.execution.directives
22

33
import com.google.common.collect.ImmutableList
4+
import graphql.ExecutionInput
45
import graphql.ExecutionResult
56
import graphql.GraphQL
67
import graphql.GraphQLContext
@@ -14,6 +15,7 @@ import graphql.execution.instrumentation.parameters.InstrumentationExecuteOperat
1415
import graphql.language.Document
1516
import graphql.language.OperationDefinition
1617
import graphql.schema.GraphQLScalarType
18+
import graphql.util.FpKit
1719
import spock.lang.Specification
1820

1921
class OperationDirectivesResolverTest extends Specification {
@@ -139,11 +141,17 @@ class OperationDirectivesResolverTest extends Specification {
139141
def graphQL = GraphQL.newGraphQL(schema).instrumentation(instrumentation).build()
140142

141143
when:
142-
graphQL.execute("""
144+
def ei = ExecutionInput.newExecutionInput("""
143145
query q1 @timeout(ms : 100) @foo @bar @baz @baz {
144146
f
145147
}
146-
""")
148+
149+
mutation m1 @timeout(ms : 100) @foo @bar @baz @baz {
150+
f
151+
}
152+
""").operationName("q1").build()
153+
graphQL.execute(ei)
154+
147155

148156
then:
149157
def resolveDirectives = executionContext.getOperationDirectives()
@@ -157,6 +165,15 @@ class OperationDirectivesResolverTest extends Specification {
157165
then:
158166
commonIntegrationAsserts(enoResolveDirectives)
159167

168+
when:
169+
def allOperationDirectives = executionContext.getAllOperationDirectives()
170+
171+
then:
172+
allOperationDirectives.size() == 2
173+
ImmutableList<QueryAppliedDirective> firstList = allOperationDirectives.values().iterator().next()
174+
def firstResolvedDirectives = FpKit.groupingBy(firstList, { it -> it.name })
175+
commonIntegrationAsserts(firstResolvedDirectives)
176+
160177
}
161178

162179
private static boolean commonIntegrationAsserts(Map<String, ImmutableList<QueryAppliedDirective>> resolveDirectives) {

0 commit comments

Comments
 (0)