@@ -16,6 +16,8 @@ class QueryDirectivesImplTest extends Specification {
1616 directive @cached(forMillis : Int = 99) on FIELD | QUERY
1717
1818 directive @upper(place : String) on FIELD
19+
20+ directive @rep(place : String) repeatable on FIELD
1921
2022 type Query {
2123 f : String
@@ -24,9 +26,7 @@ class QueryDirectivesImplTest extends Specification {
2426
2527 def schema = TestUtil . schema(sdl)
2628
27-
2829 def " can get immediate directives" () {
29-
3030 def f1 = TestUtil . parseField(" f1 @cached @upper" )
3131 def f2 = TestUtil . parseField(" f2 @cached(forMillis : \$ var) @timeout" )
3232
@@ -68,7 +68,6 @@ class QueryDirectivesImplTest extends Specification {
6868 }
6969
7070 def " builder works as expected" () {
71-
7271 def f1 = TestUtil . parseField(" f1 @cached @upper" )
7372 def f2 = TestUtil . parseField(" f2 @cached(forMillis : \$ var) @timeout" )
7473
@@ -87,6 +86,28 @@ class QueryDirectivesImplTest extends Specification {
8786
8887 then :
8988 appliedDirectivesByName. keySet(). sort() == [" cached" , " timeout" , " upper" ]
89+ }
90+
91+ def " gets repeated definitions" () {
92+ def f1 = TestUtil . parseField(" f1 @rep(place: \$ var) @rep(place: \" HELLO\" )" )
9093
94+ def mergedField = MergedField . newMergedField([f1]). build()
95+
96+ def queryDirectives = QueryDirectives . newQueryDirectives()
97+ .mergedField(mergedField)
98+ .schema(schema)
99+ .coercedVariables(CoercedVariables . of([var : " ABC" ]))
100+ .graphQLContext(GraphQLContext . getDefault())
101+ .locale(Locale . getDefault())
102+ .build()
103+
104+ when :
105+ def appliedDirectivesByName = queryDirectives. getImmediateAppliedDirectivesByName()
106+
107+ then :
108+ appliedDirectivesByName. keySet() == [" rep" ] as Set
109+ appliedDirectivesByName[" rep" ]. size() == 2
110+ // Groovy is a pathway to many abilities some consider to be unnatural
111+ appliedDirectivesByName[" rep" ]. arguments. value. flatten(). sort() == [" ABC" , " HELLO" ]
91112 }
92113}
0 commit comments