File tree Expand file tree Collapse file tree
src/test/groovy/graphql/schema/validation Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import graphql.TestUtil
44import graphql.schema.GraphQLInterfaceType
55import graphql.schema.GraphQLObjectType
66import spock.lang.Specification
7+ import spock.lang.Unroll
78
89import static SchemaValidationErrorType.ObjectDoesNotImplementItsInterfaces
910import static graphql.Scalars.GraphQLBoolean
@@ -312,28 +313,51 @@ class TypesImplementInterfacesTest extends Specification {
312313 ! badErrorCollector. getErrors(). isEmpty()
313314 }
314315
315- def " non-null union field implements nullable union interface field" () {
316+ @Unroll
317+ def " implementing field can strengthen #kind nullability from #interfaceFieldType to #implementingFieldType" () {
316318 when :
317- TestUtil . schema('''
319+ TestUtil . schema("""
318320 schema { query: B }
319321
320- union U = A
322+ enum E {
323+ VALUE
324+ }
321325
322- interface I {
323- i: U
326+ interface J {
327+ value: String
324328 }
325329
326- type A {
327- a: String
330+ type A implements J {
331+ value: String
332+ }
333+
334+ union U = A
335+
336+ interface I {
337+ value: $interfaceFieldType
328338 }
329339
330340 type B implements I {
331- i: U!
341+ value: $i mplementingFieldType
332342 }
333- ''' )
343+ """ )
334344
335345 then :
336346 noExceptionThrown()
347+
348+ where :
349+ kind | interfaceFieldType | implementingFieldType
350+ " scalar" | " String" | " String!"
351+ " enum" | " E" | " E!"
352+ " object" | " A" | " A!"
353+ " interface" | " J" | " J!"
354+ " union" | " U" | " U!"
355+ " list" | " [String]" | " [String]!"
356+ " list item" | " [String]" | " [String!]"
357+ " list and item" | " [String]" | " [String!]!"
358+ " nested list" | " [[String]]" | " [[String!]!]!"
359+ " list of unions" | " [U]" | " [U!]!"
360+ " list of interfaces" | " [J]" | " [J!]!"
337361 }
338362
339363 def " field is a non null object" () {
You can’t perform that action at this time.
0 commit comments