@@ -241,18 +241,18 @@ union UnionName @d1 @d2 = Type1 | Type2
241241"""
242242
243243 and : " expected schema"
244- def schema = new UnionTypeDefinition (" UnionName" )
245- schema. getDirectives() . add (new Directive (" d1" ))
246- schema. getDirectives() . add (new Directive (" d2" ))
247- schema. getMemberTypes() . add (new TypeName (" Type1" ))
248- schema. getMemberTypes() . add (new TypeName (" Type2" ))
244+ def schema = UnionTypeDefinition . newUnionTypeDefinition() . name (" UnionName" )
245+ schema. directive (new Directive (" d1" ))
246+ schema. directive (new Directive (" d2" ))
247+ schema. memberType (new TypeName (" Type1" ))
248+ schema. memberType (new TypeName (" Type2" ))
249249
250250 when :
251251 def document = new Parser (). parseDocument(input)
252252
253253 then :
254254 document. definitions. size() == 1
255- isEqual(document. definitions[0 ], schema)
255+ isEqual(document. definitions[0 ], schema. build() )
256256 }
257257
258258 def " input object schema" () {
@@ -311,7 +311,7 @@ schema @d1 @d2 {
311311
312312 then :
313313 document. definitions. size() == 1
314- isEqual(document. definitions[0 ], schema)
314+ isEqual(document. definitions[0 ], schema. build() )
315315 }
316316
317317 def " extend schema" () {
@@ -325,33 +325,31 @@ withArgs(arg1:[Number]=[1] arg2:String @secondArg(cool:true)): Function
325325"""
326326
327327 and : " expected schema"
328- def schema = new ObjectTypeExtensionDefinition (" ExtendType" )
329- schema. getImplements(). add(new TypeName (" Impl3" ))
330- schema. getDirectives()
331- .add(new Directive (" extendDirective" , [new Argument (" a1" , new VariableReference (" v1" ))]))
332- schema. getFieldDefinitions()
333- .add(new FieldDefinition (" one" , new TypeName (" Int" )))
334- def two = new FieldDefinition (" two" , new TypeName (" Int" ))
335- two. getDirectives(). add(new Directive (" second" ))
336- schema. getFieldDefinitions(). add(two)
337-
338- def withArgs = new FieldDefinition (" withArgs" , new TypeName (" Function" ))
339- withArgs. getInputValueDefinitions()
340- .add(new InputValueDefinition (" arg1" ,
328+ def schema = ObjectTypeExtensionDefinition . newObjectTypeExtensionDefinition(). name(" ExtendType" )
329+ schema. implementz(new TypeName (" Impl3" ))
330+ schema. directive(new Directive (" extendDirective" , [new Argument (" a1" , new VariableReference (" v1" ))]))
331+ schema. fieldDefinition(new FieldDefinition (" one" , new TypeName (" Int" )))
332+
333+ def two = FieldDefinition . newFieldDefintion(). name(" two" ). type(new TypeName (" Int" ))
334+ two. directive(new Directive (" second" ))
335+ schema. fieldDefinition(two. build())
336+
337+ def withArgs = FieldDefinition . newFieldDefintion(). name(" withArgs" ). type(new TypeName (" Function" ))
338+ withArgs. inputValueDefinition(new InputValueDefinition (" arg1" ,
341339 new ListType (new TypeName (" Number" )),
342340 new ArrayValue ([new IntValue (1 )])))
343- def arg2 = new InputValueDefinition ( " arg2 " , new TypeName ( " String " ))
344- arg2. getDirectives( )
345- .add (new Directive (" secondArg" , [new Argument (" cool" , new BooleanValue (true ))]))
346- withArgs. getInputValueDefinitions() . add(arg2 )
347- schema. getFieldDefinitions() . add(withArgs )
341+
342+ def arg2 = InputValueDefinition . newInputValueDefinition() . name( " arg2 " ) . type( new TypeName ( " String " ) )
343+ arg2 . directive (new Directive (" secondArg" , [new Argument (" cool" , new BooleanValue (true ))]))
344+ withArgs. inputValueDefinition(arg2 . build() )
345+ schema. fieldDefinition(withArgs . build() )
348346
349347 when :
350348 def document = new Parser (). parseDocument(input)
351349
352350 then :
353351 document. definitions. size() == 1
354- isEqual(document. definitions[0 ], schema)
352+ isEqual(document. definitions[0 ], schema. build() )
355353 }
356354
357355 def " directive schema" () {
@@ -361,22 +359,18 @@ directive @DirectiveName(arg1:String arg2:Int=23) on FIELD | QUERY
361359"""
362360
363361 and : " expected schema"
364- def schema = new DirectiveDefinition (" DirectiveName" )
365- schema. getInputValueDefinitions()
366- .add(new InputValueDefinition (" arg1" , new TypeName (" String" )))
367- schema. getInputValueDefinitions()
368- .add(new InputValueDefinition (" arg2" , new TypeName (" Int" ), new IntValue (23 )))
369- schema. getDirectiveLocations()
370- .add(new DirectiveLocation (" FIELD" ))
371- schema. getDirectiveLocations()
372- .add(new DirectiveLocation (" QUERY" ))
362+ def schema = DirectiveDefinition . newDirectiveDefinition(). name(" DirectiveName" )
363+ schema. inputValueDefinition(new InputValueDefinition (" arg1" , new TypeName (" String" )))
364+ schema. inputValueDefinition(new InputValueDefinition (" arg2" , new TypeName (" Int" ), new IntValue (23 )))
365+ schema. directiveLocation(new DirectiveLocation (" FIELD" ))
366+ schema. directiveLocation(new DirectiveLocation (" QUERY" ))
373367
374368 when :
375369 def document = new Parser (). parseDocument(input)
376370
377371 then :
378372 document. definitions. size() == 1
379- isEqual(document. definitions[0 ], schema)
373+ isEqual(document. definitions[0 ], schema. build() )
380374 }
381375
382376
0 commit comments