diff --git a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/constantsForInputTypes/expected/client/QueryProjection.kt b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/constantsForInputTypes/expected/client/QueryProjection.kt index 1752eceb..56793e0c 100644 --- a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/constantsForInputTypes/expected/client/QueryProjection.kt +++ b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/constantsForInputTypes/expected/client/QueryProjection.kt @@ -9,8 +9,8 @@ public class QueryProjection( inputValueSerializer: InputValueSerializerInterface? = null, ) : GraphQLProjection(inputValueSerializer) { public fun people( - _alias: String? = null, filter: PersonFilter? = default("filter"), + _alias: String? = null, _projection: PersonProjection.() -> PersonProjection, ): QueryProjection { field(_alias, "people", PersonProjection(inputValueSerializer), _projection, "filter" to filter) diff --git a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/constantsWithExtendedInputTypes/expected/client/QueryProjection.kt b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/constantsWithExtendedInputTypes/expected/client/QueryProjection.kt index 729b0023..b2ed7b5e 100644 --- a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/constantsWithExtendedInputTypes/expected/client/QueryProjection.kt +++ b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/constantsWithExtendedInputTypes/expected/client/QueryProjection.kt @@ -9,8 +9,8 @@ public class QueryProjection( inputValueSerializer: InputValueSerializerInterface? = null, ) : GraphQLProjection(inputValueSerializer) { public fun people( - _alias: String? = null, filter: PersonFilter? = default("filter"), + _alias: String? = null, _projection: PersonProjection.() -> PersonProjection, ): QueryProjection { field(_alias, "people", PersonProjection(inputValueSerializer), _projection, "filter" to filter) diff --git a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassDocs/expected/client/QueryProjection.kt b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassDocs/expected/client/QueryProjection.kt index 8a8c2999..09522346 100644 --- a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassDocs/expected/client/QueryProjection.kt +++ b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassDocs/expected/client/QueryProjection.kt @@ -9,8 +9,8 @@ public class QueryProjection( inputValueSerializer: InputValueSerializerInterface? = null, ) : GraphQLProjection(inputValueSerializer) { public fun search( - _alias: String? = null, movieFilter: MovieFilter, + _alias: String? = null, _projection: MovieProjection.() -> MovieProjection, ): QueryProjection { field(_alias, "search", MovieProjection(inputValueSerializer), _projection, "movieFilter" to diff --git a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassFieldDocs/expected/client/QueryProjection.kt b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassFieldDocs/expected/client/QueryProjection.kt index 5a3e8fad..e5afed51 100644 --- a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassFieldDocs/expected/client/QueryProjection.kt +++ b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassFieldDocs/expected/client/QueryProjection.kt @@ -9,8 +9,8 @@ public class QueryProjection( inputValueSerializer: InputValueSerializerInterface? = null, ) : GraphQLProjection(inputValueSerializer) { public fun search( - _alias: String? = null, movieFilter: MovieFilter, + _alias: String? = null, _projection: MovieProjection.() -> MovieProjection, ): QueryProjection { field(_alias, "search", MovieProjection(inputValueSerializer), _projection, "movieFilter" to diff --git a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/projectionWithTypeAndArgs/expected/client/QueryProjection.kt b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/projectionWithTypeAndArgs/expected/client/QueryProjection.kt index ad71ba58..ba9ed9bf 100644 --- a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/projectionWithTypeAndArgs/expected/client/QueryProjection.kt +++ b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/projectionWithTypeAndArgs/expected/client/QueryProjection.kt @@ -9,10 +9,10 @@ public class QueryProjection( inputValueSerializer: InputValueSerializerInterface? = null, ) : GraphQLProjection(inputValueSerializer) { public fun person( - _alias: String? = null, a1: String? = default("a1"), a2: String, a3: I? = default("a3"), + _alias: String? = null, _projection: PersonProjection.() -> PersonProjection, ): QueryProjection { field(_alias, "person", PersonProjection(inputValueSerializer), _projection, "a1" to a1 , "a2" diff --git a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/projectionWithTypeAndArgs/test/QueryTest.kt b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/projectionWithTypeAndArgs/test/QueryTest.kt index a809790c..b60ec316 100644 --- a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/projectionWithTypeAndArgs/test/QueryTest.kt +++ b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/projectionWithTypeAndArgs/test/QueryTest.kt @@ -53,6 +53,28 @@ class QueryTest { ) } + @Test + fun testQueryWithUnnamedArgs() { + val query = DgsClient.buildQuery { + person("a1", "a2") { + firstname + } + } + + assertEquals( + """{ + | __typename + | person(a1: "a1", a2: "a2") { + | __typename + | firstname + | } + |} + | + """.trimMargin(), + query + ) + } + @Test fun testQueryWithAlias() { val query = DgsClient.buildQuery { diff --git a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/unionTypesWithoutInterfaceCanDeserialize/expected/client/QueryProjection.kt b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/unionTypesWithoutInterfaceCanDeserialize/expected/client/QueryProjection.kt index 51296ec7..ff4443ad 100644 --- a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/unionTypesWithoutInterfaceCanDeserialize/expected/client/QueryProjection.kt +++ b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/unionTypesWithoutInterfaceCanDeserialize/expected/client/QueryProjection.kt @@ -8,8 +8,8 @@ public class QueryProjection( inputValueSerializer: InputValueSerializerInterface? = null, ) : GraphQLProjection(inputValueSerializer) { public fun search( - _alias: String? = null, text: String, + _alias: String? = null, _projection: SearchResultPageProjection.() -> SearchResultPageProjection, ): QueryProjection { field(_alias, "search", SearchResultPageProjection(inputValueSerializer), _projection, "text" to diff --git a/graphql-dgs-codegen-core/src/main/kotlin/com/netflix/graphql/dgs/codegen/generators/kotlin2/GenerateKotlin2ClientTypes.kt b/graphql-dgs-codegen-core/src/main/kotlin/com/netflix/graphql/dgs/codegen/generators/kotlin2/GenerateKotlin2ClientTypes.kt index c4b2d5e5..0cb18770 100644 --- a/graphql-dgs-codegen-core/src/main/kotlin/com/netflix/graphql/dgs/codegen/generators/kotlin2/GenerateKotlin2ClientTypes.kt +++ b/graphql-dgs-codegen-core/src/main/kotlin/com/netflix/graphql/dgs/codegen/generators/kotlin2/GenerateKotlin2ClientTypes.kt @@ -121,8 +121,8 @@ fun generateKotlin2ClientTypes( val (projectionType, projection) = projectionType(config.packageNameClient, projectionTypeName) FunSpec.builder(field.name) - .addParameter(ParameterSpec.builder("_alias", String::class.asTypeName().copy(nullable = true)).defaultValue("null").build()) .addInputArgs(config, typeLookup, typeName, field.inputValueDefinitions) + .addParameter(ParameterSpec.builder("_alias", String::class.asTypeName().copy(nullable = true)).defaultValue("null").build()) .addParameter(projection) .returns(typeName) .addStatement(