@@ -6,6 +6,7 @@ import graphql.language.ObjectTypeDefinition
66import graphql.language.ScalarTypeDefinition
77import graphql.schema.idl.errors.SchemaProblem
88import spock.lang.Specification
9+ import spock.lang.Unroll
910
1011/**
1112 * We don't want to retest the base GraphQL parser since it has its own testing
@@ -188,7 +189,8 @@ class SchemaParserTest extends Specification {
188189 }
189190
190191
191- def "empty types (with and without parentheses ) are allowed" () {
192+ @Unroll
193+ def "empty types (with and without parentheses ) are allowed in ' #schema' " () {
192194 //
193195 // empty parentheses are not quite allowed by the spec but in the name of backwards compatibility
194196 // AND general usefulness we are going to allow them. So in the list below the last two of each section
@@ -218,10 +220,13 @@ class SchemaParserTest extends Specification {
218220 ''' enum Foo @directive ''' | _
219221 ''' enum Foo { } ''' | _
220222 ''' enum Foo @directive { } ''' | _
223+
224+ ''' union Foo ''' | _
221225 }
222226
223227
224- def " extensions are not allowed to be empty" () {
228+ @Unroll
229+ def " extensions are not allowed to be empty without directives in ' #schema' " () {
225230
226231 expect:
227232 assertSchemaProblem(schema)
@@ -236,29 +241,52 @@ class SchemaParserTest extends Specification {
236241 ''' extend input Foo {}''' | _
237242 ''' extend enum Foo ''' | _
238243 ''' extend enum Foo {}''' | _
244+ ''' extend union Foo ''' | _
245+ }
246+
247+ @Unroll
248+ def " extensions are allowed to be empty with directives in ' #schema' " () {
249+
250+ expect:
251+ assertNoSchemaProblem(schema)
252+
253+ where:
254+ schema | _
255+ ''' extend type Foo @d1 @d2 {}''' | _
256+ ''' extend interface Foo @d1 @d2 {}''' | _
257+ ''' extend input Foo @d1 @d2 {}''' | _
258+ ''' extend enum Foo @d1 @d2 {}''' | _
259+ ''' extend union Foo @d1 @d2 ''' | _
239260 }
240261
241- def " extensions must extend with fields or directives" () {
262+ @Unroll
263+ def " extensions must extend with fields or directives in ' #schema' " () {
242264
243265 expect:
244266 assertNoSchemaProblem(schema)
245267
246268 where:
247- schema | _
248- ''' extend type Foo @directive''' | _
249- ''' extend type Foo { f : Int }''' | _
250- ''' extend type Foo @directive { f : Int }''' | _
251-
252- ''' extend interface Foo @directive ''' | _
253- ''' extend interface Foo { f : Int }''' | _
254- ''' extend interface Foo { f : Int }''' | _
255-
256- ''' extend input Foo @directive ''' | _
257- ''' extend input Foo { f : Int }''' | _
258- ''' extend input Foo { f : Int }''' | _
259-
260- ''' extend enum Foo @directive ''' | _
261- ''' extend enum Foo { a,b,c }''' | _
262- ''' extend enum Foo @directive { a,b,c }''' | _
269+ schema | _
270+ ''' extend type Foo @directive''' | _
271+ ''' extend type Foo { f : Int }''' | _
272+ ''' extend type Foo @directive { f : Int }''' | _
273+
274+ ''' extend interface Foo @directive ''' | _
275+ ''' extend interface Foo { f : Int }''' | _
276+ ''' extend interface Foo { f : Int }''' | _
277+
278+ ''' extend input Foo @directive ''' | _
279+ ''' extend input Foo { f : Int }''' | _
280+ ''' extend input Foo { f : Int }''' | _
281+
282+ ''' extend enum Foo @directive ''' | _
283+ ''' extend enum Foo { a,b,c }''' | _
284+ ''' extend enum Foo @directive { a,b,c }''' | _
285+
286+ ''' extend union Foo @directive ''' | _
287+ ''' extend union Foo = | a | b | c''' | _
288+ ''' extend union Foo = a | b | c''' | _
289+ ''' extend union Foo @directive = | a | b | c''' | _
290+ ''' extend union Foo @directive = a | b | c''' | _
263291 }
264292}
0 commit comments