@@ -9,6 +9,7 @@ import graphql.introspection.IntrospectionResultToSchema
99import graphql.schema.Coercing
1010import graphql.schema.GraphQLArgument
1111import graphql.schema.GraphQLCodeRegistry
12+ import graphql.schema.GraphQLDirective
1213import graphql.schema.GraphQLEnumType
1314import graphql.schema.GraphQLEnumValueDefinition
1415import graphql.schema.GraphQLFieldDefinition
@@ -1950,4 +1951,53 @@ type Query {
19501951"""
19511952 }
19521953
1954+ def " programmatic object value in an argument is printed" () {
1955+
1956+ GraphQLInputObjectType compoundType = GraphQLInputObjectType . newInputObject(). name(" Compound" )
1957+ .field({ it. name(" a" ). type(GraphQLString ) })
1958+ .field({ it. name(" b" ). type(GraphQLString ) })
1959+ .build()
1960+
1961+ GraphQLObjectType objType = newObject(). name(" obj" )
1962+ .field({
1963+ it. name(" f" ). type(GraphQLString )
1964+ .argument({
1965+ it. name(" arg" ). type(compoundType). defaultValueProgrammatic([" a" : " A" , " b" : " B" ])
1966+ })
1967+ }). build()
1968+
1969+ when :
1970+
1971+ def result = new SchemaPrinter (). print (objType)
1972+
1973+
1974+ then :
1975+ result == ''' type obj {
1976+ f(arg: Compound = {a : "A", b : "B"}): String
1977+ }
1978+
1979+ '''
1980+
1981+ when :
1982+ def newDirective = GraphQLDirective . newDirective(). name(" foo" )
1983+ .argument({
1984+ it. name(" arg" ). type(compoundType). valueProgrammatic([" a" : " A" , " b" : " B" ])
1985+ })
1986+ .build()
1987+
1988+ objType = newObject(). name(" obj" ). field({
1989+ it. name(" f" ). type(GraphQLString ). withDirective(newDirective)
1990+ }). build()
1991+
1992+ result = new SchemaPrinter (). print (objType)
1993+
1994+ then :
1995+
1996+ result == ''' type obj {
1997+ f: String @foo(arg : {a : "A", b : "B"})
1998+ }
1999+
2000+ '''
2001+
2002+ }
19532003}
0 commit comments