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 187df02b3..1752eceb9 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 @@ -3,13 +3,17 @@ package com.netflix.graphql.dgs.codegen.cases.constantsForInputTypes.expected.cl import com.netflix.graphql.dgs.client.codegen.InputValueSerializerInterface import com.netflix.graphql.dgs.codegen.GraphQLProjection import com.netflix.graphql.dgs.codegen.cases.constantsForInputTypes.expected.types.PersonFilter +import kotlin.String public class QueryProjection( inputValueSerializer: InputValueSerializerInterface? = null, ) : GraphQLProjection(inputValueSerializer) { - public fun people(filter: PersonFilter? = default("filter"), - _projection: PersonProjection.() -> PersonProjection): QueryProjection { - field("people", PersonProjection(inputValueSerializer), _projection, "filter" to filter) + public fun people( + _alias: String? = null, + filter: PersonFilter? = default("filter"), + _projection: PersonProjection.() -> PersonProjection, + ): QueryProjection { + field(_alias, "people", PersonProjection(inputValueSerializer), _projection, "filter" to filter) return this } } 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 ad3c11f36..729b00234 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 @@ -3,13 +3,17 @@ package com.netflix.graphql.dgs.codegen.cases.constantsWithExtendedInputTypes.ex import com.netflix.graphql.dgs.client.codegen.InputValueSerializerInterface import com.netflix.graphql.dgs.codegen.GraphQLProjection import com.netflix.graphql.dgs.codegen.cases.constantsWithExtendedInputTypes.expected.types.PersonFilter +import kotlin.String public class QueryProjection( inputValueSerializer: InputValueSerializerInterface? = null, ) : GraphQLProjection(inputValueSerializer) { - public fun people(filter: PersonFilter? = default("filter"), - _projection: PersonProjection.() -> PersonProjection): QueryProjection { - field("people", PersonProjection(inputValueSerializer), _projection, "filter" to filter) + public fun people( + _alias: String? = null, + filter: PersonFilter? = default("filter"), + _projection: PersonProjection.() -> PersonProjection, + ): QueryProjection { + field(_alias, "people", PersonProjection(inputValueSerializer), _projection, "filter" to filter) return this } } diff --git a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/constantsWithExtendedInterface/expected/client/QueryProjection.kt b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/constantsWithExtendedInterface/expected/client/QueryProjection.kt index 5ea7f2f30..326b24d03 100644 --- a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/constantsWithExtendedInterface/expected/client/QueryProjection.kt +++ b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/constantsWithExtendedInterface/expected/client/QueryProjection.kt @@ -2,12 +2,14 @@ package com.netflix.graphql.dgs.codegen.cases.constantsWithExtendedInterface.exp import com.netflix.graphql.dgs.client.codegen.InputValueSerializerInterface import com.netflix.graphql.dgs.codegen.GraphQLProjection +import kotlin.String public class QueryProjection( inputValueSerializer: InputValueSerializerInterface? = null, ) : GraphQLProjection(inputValueSerializer) { - public fun people(_projection: PersonProjection.() -> PersonProjection): QueryProjection { - field("people", PersonProjection(inputValueSerializer), _projection) + public fun people(_alias: String? = null, _projection: PersonProjection.() -> PersonProjection): + QueryProjection { + field(_alias, "people", PersonProjection(inputValueSerializer), _projection) return this } } diff --git a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/constantsWithExtendedQuery/expected/client/QueryProjection.kt b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/constantsWithExtendedQuery/expected/client/QueryProjection.kt index 6959b89e0..222b76194 100644 --- a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/constantsWithExtendedQuery/expected/client/QueryProjection.kt +++ b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/constantsWithExtendedQuery/expected/client/QueryProjection.kt @@ -2,17 +2,20 @@ package com.netflix.graphql.dgs.codegen.cases.constantsWithExtendedQuery.expecte import com.netflix.graphql.dgs.client.codegen.InputValueSerializerInterface import com.netflix.graphql.dgs.codegen.GraphQLProjection +import kotlin.String public class QueryProjection( inputValueSerializer: InputValueSerializerInterface? = null, ) : GraphQLProjection(inputValueSerializer) { - public fun people(_projection: PersonProjection.() -> PersonProjection): QueryProjection { - field("people", PersonProjection(inputValueSerializer), _projection) + public fun people(_alias: String? = null, _projection: PersonProjection.() -> PersonProjection): + QueryProjection { + field(_alias, "people", PersonProjection(inputValueSerializer), _projection) return this } - public fun friends(_projection: PersonProjection.() -> PersonProjection): QueryProjection { - field("friends", PersonProjection(inputValueSerializer), _projection) + public fun friends(_alias: String? = null, _projection: PersonProjection.() -> PersonProjection): + QueryProjection { + field(_alias, "friends", PersonProjection(inputValueSerializer), _projection) return this } } diff --git a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/constantsWithExtendedTypes/expected/client/QueryProjection.kt b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/constantsWithExtendedTypes/expected/client/QueryProjection.kt index aec0334f3..9e9e79f41 100644 --- a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/constantsWithExtendedTypes/expected/client/QueryProjection.kt +++ b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/constantsWithExtendedTypes/expected/client/QueryProjection.kt @@ -2,12 +2,14 @@ package com.netflix.graphql.dgs.codegen.cases.constantsWithExtendedTypes.expecte import com.netflix.graphql.dgs.client.codegen.InputValueSerializerInterface import com.netflix.graphql.dgs.codegen.GraphQLProjection +import kotlin.String public class QueryProjection( inputValueSerializer: InputValueSerializerInterface? = null, ) : GraphQLProjection(inputValueSerializer) { - public fun people(_projection: PersonProjection.() -> PersonProjection): QueryProjection { - field("people", PersonProjection(inputValueSerializer), _projection) + public fun people(_alias: String? = null, _projection: PersonProjection.() -> PersonProjection): + QueryProjection { + field(_alias, "people", PersonProjection(inputValueSerializer), _projection) return this } } 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 45982df2d..8a8c29993 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 @@ -3,13 +3,17 @@ package com.netflix.graphql.dgs.codegen.cases.dataClassDocs.expected.client import com.netflix.graphql.dgs.client.codegen.InputValueSerializerInterface import com.netflix.graphql.dgs.codegen.GraphQLProjection import com.netflix.graphql.dgs.codegen.cases.dataClassDocs.expected.types.MovieFilter +import kotlin.String public class QueryProjection( inputValueSerializer: InputValueSerializerInterface? = null, ) : GraphQLProjection(inputValueSerializer) { - public fun search(movieFilter: MovieFilter, _projection: MovieProjection.() -> MovieProjection): - QueryProjection { - field("search", MovieProjection(inputValueSerializer), _projection, "movieFilter" to + public fun search( + _alias: String? = null, + movieFilter: MovieFilter, + _projection: MovieProjection.() -> MovieProjection, + ): QueryProjection { + field(_alias, "search", MovieProjection(inputValueSerializer), _projection, "movieFilter" to movieFilter) return this } 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 bdcb099bc..5a3e8fad0 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 @@ -3,13 +3,17 @@ package com.netflix.graphql.dgs.codegen.cases.dataClassFieldDocs.expected.client import com.netflix.graphql.dgs.client.codegen.InputValueSerializerInterface import com.netflix.graphql.dgs.codegen.GraphQLProjection import com.netflix.graphql.dgs.codegen.cases.dataClassFieldDocs.expected.types.MovieFilter +import kotlin.String public class QueryProjection( inputValueSerializer: InputValueSerializerInterface? = null, ) : GraphQLProjection(inputValueSerializer) { - public fun search(movieFilter: MovieFilter, _projection: MovieProjection.() -> MovieProjection): - QueryProjection { - field("search", MovieProjection(inputValueSerializer), _projection, "movieFilter" to + public fun search( + _alias: String? = null, + movieFilter: MovieFilter, + _projection: MovieProjection.() -> MovieProjection, + ): QueryProjection { + field(_alias, "search", MovieProjection(inputValueSerializer), _projection, "movieFilter" to movieFilter) return this } diff --git a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWIthNoFields/expected/client/QueryProjection.kt b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWIthNoFields/expected/client/QueryProjection.kt index 8e7943aa1..c1b9249f3 100644 --- a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWIthNoFields/expected/client/QueryProjection.kt +++ b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWIthNoFields/expected/client/QueryProjection.kt @@ -2,12 +2,14 @@ package com.netflix.graphql.dgs.codegen.cases.dataClassWIthNoFields.expected.cli import com.netflix.graphql.dgs.client.codegen.InputValueSerializerInterface import com.netflix.graphql.dgs.codegen.GraphQLProjection +import kotlin.String public class QueryProjection( inputValueSerializer: InputValueSerializerInterface? = null, ) : GraphQLProjection(inputValueSerializer) { - public fun me(_projection: PersonProjection.() -> PersonProjection): QueryProjection { - field("me", PersonProjection(inputValueSerializer), _projection) + public fun me(_alias: String? = null, _projection: PersonProjection.() -> PersonProjection): + QueryProjection { + field(_alias, "me", PersonProjection(inputValueSerializer), _projection) return this } } diff --git a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithBooleanField/expected/client/QueryProjection.kt b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithBooleanField/expected/client/QueryProjection.kt index 2a5ae0203..d338b748d 100644 --- a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithBooleanField/expected/client/QueryProjection.kt +++ b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithBooleanField/expected/client/QueryProjection.kt @@ -2,13 +2,14 @@ package com.netflix.graphql.dgs.codegen.cases.dataClassWithBooleanField.expected import com.netflix.graphql.dgs.client.codegen.InputValueSerializerInterface import com.netflix.graphql.dgs.codegen.GraphQLProjection +import kotlin.String public class QueryProjection( inputValueSerializer: InputValueSerializerInterface? = null, ) : GraphQLProjection(inputValueSerializer) { - public fun test(_projection: RequiredTestTypeProjection.() -> RequiredTestTypeProjection): - QueryProjection { - field("test", RequiredTestTypeProjection(inputValueSerializer), _projection) + public fun test(_alias: String? = null, + _projection: RequiredTestTypeProjection.() -> RequiredTestTypeProjection): QueryProjection { + field(_alias, "test", RequiredTestTypeProjection(inputValueSerializer), _projection) return this } } diff --git a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithDeclaredScalars/expected/client/EntityConnectionProjection.kt b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithDeclaredScalars/expected/client/EntityConnectionProjection.kt index 742172045..1d4e1fae2 100644 --- a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithDeclaredScalars/expected/client/EntityConnectionProjection.kt +++ b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithDeclaredScalars/expected/client/EntityConnectionProjection.kt @@ -2,19 +2,20 @@ package com.netflix.graphql.dgs.codegen.cases.dataClassWithDeclaredScalars.expec import com.netflix.graphql.dgs.client.codegen.InputValueSerializerInterface import com.netflix.graphql.dgs.codegen.GraphQLProjection +import kotlin.String public class EntityConnectionProjection( inputValueSerializer: InputValueSerializerInterface? = null, ) : GraphQLProjection(inputValueSerializer) { - public fun pageInfo(_projection: PageInfoProjection.() -> PageInfoProjection): - EntityConnectionProjection { - field("pageInfo", PageInfoProjection(inputValueSerializer), _projection) + public fun pageInfo(_alias: String? = null, + _projection: PageInfoProjection.() -> PageInfoProjection): EntityConnectionProjection { + field(_alias, "pageInfo", PageInfoProjection(inputValueSerializer), _projection) return this } - public fun edges(_projection: EntityEdgeProjection.() -> EntityEdgeProjection): - EntityConnectionProjection { - field("edges", EntityEdgeProjection(inputValueSerializer), _projection) + public fun edges(_alias: String? = null, + _projection: EntityEdgeProjection.() -> EntityEdgeProjection): EntityConnectionProjection { + field(_alias, "edges", EntityEdgeProjection(inputValueSerializer), _projection) return this } } diff --git a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithDeclaredScalars/expected/client/EntityEdgeProjection.kt b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithDeclaredScalars/expected/client/EntityEdgeProjection.kt index 7bddc9b93..be311c5af 100644 --- a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithDeclaredScalars/expected/client/EntityEdgeProjection.kt +++ b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithDeclaredScalars/expected/client/EntityEdgeProjection.kt @@ -2,6 +2,7 @@ package com.netflix.graphql.dgs.codegen.cases.dataClassWithDeclaredScalars.expec import com.netflix.graphql.dgs.client.codegen.InputValueSerializerInterface import com.netflix.graphql.dgs.codegen.GraphQLProjection +import kotlin.String public class EntityEdgeProjection( inputValueSerializer: InputValueSerializerInterface? = null, @@ -12,8 +13,9 @@ public class EntityEdgeProjection( return this } - public fun node(_projection: EntityProjection.() -> EntityProjection): EntityEdgeProjection { - field("node", EntityProjection(inputValueSerializer), _projection) + public fun node(_alias: String? = null, _projection: EntityProjection.() -> EntityProjection): + EntityEdgeProjection { + field(_alias, "node", EntityProjection(inputValueSerializer), _projection) return this } } diff --git a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithDeclaredScalars/expected/client/QueryProjection.kt b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithDeclaredScalars/expected/client/QueryProjection.kt index d7790b373..b0cba58a8 100644 --- a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithDeclaredScalars/expected/client/QueryProjection.kt +++ b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithDeclaredScalars/expected/client/QueryProjection.kt @@ -2,19 +2,20 @@ package com.netflix.graphql.dgs.codegen.cases.dataClassWithDeclaredScalars.expec import com.netflix.graphql.dgs.client.codegen.InputValueSerializerInterface import com.netflix.graphql.dgs.codegen.GraphQLProjection +import kotlin.String public class QueryProjection( inputValueSerializer: InputValueSerializerInterface? = null, ) : GraphQLProjection(inputValueSerializer) { - public fun entity(_projection: EntityProjection.() -> EntityProjection): QueryProjection { - field("entity", EntityProjection(inputValueSerializer), _projection) + public fun entity(_alias: String? = null, _projection: EntityProjection.() -> EntityProjection): + QueryProjection { + field(_alias, "entity", EntityProjection(inputValueSerializer), _projection) return this } - public - fun entityConnection(_projection: EntityConnectionProjection.() -> EntityConnectionProjection): - QueryProjection { - field("entityConnection", EntityConnectionProjection(inputValueSerializer), _projection) + public fun entityConnection(_alias: String? = null, + _projection: EntityConnectionProjection.() -> EntityConnectionProjection): QueryProjection { + field(_alias, "entityConnection", EntityConnectionProjection(inputValueSerializer), _projection) return this } } diff --git a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithDeeplyNestedComplexField/expected/client/CarProjection.kt b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithDeeplyNestedComplexField/expected/client/CarProjection.kt index 621c9d4f9..67b022e37 100644 --- a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithDeeplyNestedComplexField/expected/client/CarProjection.kt +++ b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithDeeplyNestedComplexField/expected/client/CarProjection.kt @@ -2,6 +2,7 @@ package com.netflix.graphql.dgs.codegen.cases.dataClassWithDeeplyNestedComplexFi import com.netflix.graphql.dgs.client.codegen.InputValueSerializerInterface import com.netflix.graphql.dgs.codegen.GraphQLProjection +import kotlin.String public class CarProjection( inputValueSerializer: InputValueSerializerInterface? = null, @@ -18,8 +19,9 @@ public class CarProjection( return this } - public fun engine(_projection: EngineProjection.() -> EngineProjection): CarProjection { - field("engine", EngineProjection(inputValueSerializer), _projection) + public fun engine(_alias: String? = null, _projection: EngineProjection.() -> EngineProjection): + CarProjection { + field(_alias, "engine", EngineProjection(inputValueSerializer), _projection) return this } } diff --git a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithDeeplyNestedComplexField/expected/client/EngineProjection.kt b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithDeeplyNestedComplexField/expected/client/EngineProjection.kt index 167b06785..d236cf8b9 100644 --- a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithDeeplyNestedComplexField/expected/client/EngineProjection.kt +++ b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithDeeplyNestedComplexField/expected/client/EngineProjection.kt @@ -2,6 +2,7 @@ package com.netflix.graphql.dgs.codegen.cases.dataClassWithDeeplyNestedComplexFi import com.netflix.graphql.dgs.client.codegen.InputValueSerializerInterface import com.netflix.graphql.dgs.codegen.GraphQLProjection +import kotlin.String public class EngineProjection( inputValueSerializer: InputValueSerializerInterface? = null, @@ -24,9 +25,9 @@ public class EngineProjection( return this } - public fun performance(_projection: PerformanceProjection.() -> PerformanceProjection): - EngineProjection { - field("performance", PerformanceProjection(inputValueSerializer), _projection) + public fun performance(_alias: String? = null, + _projection: PerformanceProjection.() -> PerformanceProjection): EngineProjection { + field(_alias, "performance", PerformanceProjection(inputValueSerializer), _projection) return this } } diff --git a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithDeeplyNestedComplexField/expected/client/QueryProjection.kt b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithDeeplyNestedComplexField/expected/client/QueryProjection.kt index 4e6c69819..7694bb472 100644 --- a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithDeeplyNestedComplexField/expected/client/QueryProjection.kt +++ b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithDeeplyNestedComplexField/expected/client/QueryProjection.kt @@ -2,12 +2,14 @@ package com.netflix.graphql.dgs.codegen.cases.dataClassWithDeeplyNestedComplexFi import com.netflix.graphql.dgs.client.codegen.InputValueSerializerInterface import com.netflix.graphql.dgs.codegen.GraphQLProjection +import kotlin.String public class QueryProjection( inputValueSerializer: InputValueSerializerInterface? = null, ) : GraphQLProjection(inputValueSerializer) { - public fun cars(_projection: CarProjection.() -> CarProjection): QueryProjection { - field("cars", CarProjection(inputValueSerializer), _projection) + public fun cars(_alias: String? = null, _projection: CarProjection.() -> CarProjection): + QueryProjection { + field(_alias, "cars", CarProjection(inputValueSerializer), _projection) return this } } diff --git a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithExtendedInterface/expected/client/QueryProjection.kt b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithExtendedInterface/expected/client/QueryProjection.kt index f24b32705..39e5eca4d 100644 --- a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithExtendedInterface/expected/client/QueryProjection.kt +++ b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithExtendedInterface/expected/client/QueryProjection.kt @@ -2,12 +2,14 @@ package com.netflix.graphql.dgs.codegen.cases.dataClassWithExtendedInterface.exp import com.netflix.graphql.dgs.client.codegen.InputValueSerializerInterface import com.netflix.graphql.dgs.codegen.GraphQLProjection +import kotlin.String public class QueryProjection( inputValueSerializer: InputValueSerializerInterface? = null, ) : GraphQLProjection(inputValueSerializer) { - public fun people(_projection: PersonProjection.() -> PersonProjection): QueryProjection { - field("people", PersonProjection(inputValueSerializer), _projection) + public fun people(_alias: String? = null, _projection: PersonProjection.() -> PersonProjection): + QueryProjection { + field(_alias, "people", PersonProjection(inputValueSerializer), _projection) return this } } diff --git a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithInterface/expected/client/QueryProjection.kt b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithInterface/expected/client/QueryProjection.kt index 06e970caf..af8df4fed 100644 --- a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithInterface/expected/client/QueryProjection.kt +++ b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithInterface/expected/client/QueryProjection.kt @@ -2,12 +2,14 @@ package com.netflix.graphql.dgs.codegen.cases.dataClassWithInterface.expected.cl import com.netflix.graphql.dgs.client.codegen.InputValueSerializerInterface import com.netflix.graphql.dgs.codegen.GraphQLProjection +import kotlin.String public class QueryProjection( inputValueSerializer: InputValueSerializerInterface? = null, ) : GraphQLProjection(inputValueSerializer) { - public fun people(_projection: PersonProjection.() -> PersonProjection): QueryProjection { - field("people", PersonProjection(inputValueSerializer), _projection) + public fun people(_alias: String? = null, _projection: PersonProjection.() -> PersonProjection): + QueryProjection { + field(_alias, "people", PersonProjection(inputValueSerializer), _projection) return this } } diff --git a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithInterfaceInheritance/expected/client/QueryProjection.kt b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithInterfaceInheritance/expected/client/QueryProjection.kt index aa9c44767..b2dec68dd 100644 --- a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithInterfaceInheritance/expected/client/QueryProjection.kt +++ b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithInterfaceInheritance/expected/client/QueryProjection.kt @@ -2,12 +2,14 @@ package com.netflix.graphql.dgs.codegen.cases.dataClassWithInterfaceInheritance. import com.netflix.graphql.dgs.client.codegen.InputValueSerializerInterface import com.netflix.graphql.dgs.codegen.GraphQLProjection +import kotlin.String public class QueryProjection( inputValueSerializer: InputValueSerializerInterface? = null, ) : GraphQLProjection(inputValueSerializer) { - public fun people(_projection: PersonProjection.() -> PersonProjection): QueryProjection { - field("people", PersonProjection(inputValueSerializer), _projection) + public fun people(_alias: String? = null, _projection: PersonProjection.() -> PersonProjection): + QueryProjection { + field(_alias, "people", PersonProjection(inputValueSerializer), _projection) return this } } diff --git a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithListProperties/expected/client/QueryProjection.kt b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithListProperties/expected/client/QueryProjection.kt index 27fc58908..94c556c08 100644 --- a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithListProperties/expected/client/QueryProjection.kt +++ b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithListProperties/expected/client/QueryProjection.kt @@ -2,12 +2,14 @@ package com.netflix.graphql.dgs.codegen.cases.dataClassWithListProperties.expect import com.netflix.graphql.dgs.client.codegen.InputValueSerializerInterface import com.netflix.graphql.dgs.codegen.GraphQLProjection +import kotlin.String public class QueryProjection( inputValueSerializer: InputValueSerializerInterface? = null, ) : GraphQLProjection(inputValueSerializer) { - public fun people(_projection: PersonProjection.() -> PersonProjection): QueryProjection { - field("people", PersonProjection(inputValueSerializer), _projection) + public fun people(_alias: String? = null, _projection: PersonProjection.() -> PersonProjection): + QueryProjection { + field(_alias, "people", PersonProjection(inputValueSerializer), _projection) return this } } diff --git a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithMappedInterfaces/expected/client/QueryProjection.kt b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithMappedInterfaces/expected/client/QueryProjection.kt index 315e070cf..2fe3581d1 100644 --- a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithMappedInterfaces/expected/client/QueryProjection.kt +++ b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithMappedInterfaces/expected/client/QueryProjection.kt @@ -2,12 +2,14 @@ package com.netflix.graphql.dgs.codegen.cases.dataClassWithMappedInterfaces.expe import com.netflix.graphql.dgs.client.codegen.InputValueSerializerInterface import com.netflix.graphql.dgs.codegen.GraphQLProjection +import kotlin.String public class QueryProjection( inputValueSerializer: InputValueSerializerInterface? = null, ) : GraphQLProjection(inputValueSerializer) { - public fun products(_projection: ProductProjection.() -> ProductProjection): QueryProjection { - field("products", ProductProjection(inputValueSerializer), _projection) + public fun products(_alias: String? = null, + _projection: ProductProjection.() -> ProductProjection): QueryProjection { + field(_alias, "products", ProductProjection(inputValueSerializer), _projection) return this } } diff --git a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithMappedTypes/expected/client/EntityConnectionProjection.kt b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithMappedTypes/expected/client/EntityConnectionProjection.kt index 167ab5166..77ba0aacc 100644 --- a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithMappedTypes/expected/client/EntityConnectionProjection.kt +++ b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithMappedTypes/expected/client/EntityConnectionProjection.kt @@ -2,19 +2,20 @@ package com.netflix.graphql.dgs.codegen.cases.dataClassWithMappedTypes.expected. import com.netflix.graphql.dgs.client.codegen.InputValueSerializerInterface import com.netflix.graphql.dgs.codegen.GraphQLProjection +import kotlin.String public class EntityConnectionProjection( inputValueSerializer: InputValueSerializerInterface? = null, ) : GraphQLProjection(inputValueSerializer) { - public fun pageInfo(_projection: PageInfoProjection.() -> PageInfoProjection): - EntityConnectionProjection { - field("pageInfo", PageInfoProjection(inputValueSerializer), _projection) + public fun pageInfo(_alias: String? = null, + _projection: PageInfoProjection.() -> PageInfoProjection): EntityConnectionProjection { + field(_alias, "pageInfo", PageInfoProjection(inputValueSerializer), _projection) return this } - public fun edges(_projection: EntityEdgeProjection.() -> EntityEdgeProjection): - EntityConnectionProjection { - field("edges", EntityEdgeProjection(inputValueSerializer), _projection) + public fun edges(_alias: String? = null, + _projection: EntityEdgeProjection.() -> EntityEdgeProjection): EntityConnectionProjection { + field(_alias, "edges", EntityEdgeProjection(inputValueSerializer), _projection) return this } } diff --git a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithMappedTypes/expected/client/EntityEdgeProjection.kt b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithMappedTypes/expected/client/EntityEdgeProjection.kt index 9fd88ab0a..bcedfad22 100644 --- a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithMappedTypes/expected/client/EntityEdgeProjection.kt +++ b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithMappedTypes/expected/client/EntityEdgeProjection.kt @@ -2,6 +2,7 @@ package com.netflix.graphql.dgs.codegen.cases.dataClassWithMappedTypes.expected. import com.netflix.graphql.dgs.client.codegen.InputValueSerializerInterface import com.netflix.graphql.dgs.codegen.GraphQLProjection +import kotlin.String public class EntityEdgeProjection( inputValueSerializer: InputValueSerializerInterface? = null, @@ -12,8 +13,9 @@ public class EntityEdgeProjection( return this } - public fun node(_projection: EntityProjection.() -> EntityProjection): EntityEdgeProjection { - field("node", EntityProjection(inputValueSerializer), _projection) + public fun node(_alias: String? = null, _projection: EntityProjection.() -> EntityProjection): + EntityEdgeProjection { + field(_alias, "node", EntityProjection(inputValueSerializer), _projection) return this } } diff --git a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithMappedTypes/expected/client/QueryProjection.kt b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithMappedTypes/expected/client/QueryProjection.kt index f7b98244d..789d1d023 100644 --- a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithMappedTypes/expected/client/QueryProjection.kt +++ b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithMappedTypes/expected/client/QueryProjection.kt @@ -2,19 +2,20 @@ package com.netflix.graphql.dgs.codegen.cases.dataClassWithMappedTypes.expected. import com.netflix.graphql.dgs.client.codegen.InputValueSerializerInterface import com.netflix.graphql.dgs.codegen.GraphQLProjection +import kotlin.String public class QueryProjection( inputValueSerializer: InputValueSerializerInterface? = null, ) : GraphQLProjection(inputValueSerializer) { - public fun entity(_projection: EntityProjection.() -> EntityProjection): QueryProjection { - field("entity", EntityProjection(inputValueSerializer), _projection) + public fun entity(_alias: String? = null, _projection: EntityProjection.() -> EntityProjection): + QueryProjection { + field(_alias, "entity", EntityProjection(inputValueSerializer), _projection) return this } - public - fun entityConnection(_projection: EntityConnectionProjection.() -> EntityConnectionProjection): - QueryProjection { - field("entityConnection", EntityConnectionProjection(inputValueSerializer), _projection) + public fun entityConnection(_alias: String? = null, + _projection: EntityConnectionProjection.() -> EntityConnectionProjection): QueryProjection { + field(_alias, "entityConnection", EntityConnectionProjection(inputValueSerializer), _projection) return this } } diff --git a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithNonNullableAndInterface/expected/client/QueryProjection.kt b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithNonNullableAndInterface/expected/client/QueryProjection.kt index 59a38410d..b53a88b19 100644 --- a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithNonNullableAndInterface/expected/client/QueryProjection.kt +++ b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithNonNullableAndInterface/expected/client/QueryProjection.kt @@ -2,12 +2,14 @@ package com.netflix.graphql.dgs.codegen.cases.dataClassWithNonNullableAndInterfa import com.netflix.graphql.dgs.client.codegen.InputValueSerializerInterface import com.netflix.graphql.dgs.codegen.GraphQLProjection +import kotlin.String public class QueryProjection( inputValueSerializer: InputValueSerializerInterface? = null, ) : GraphQLProjection(inputValueSerializer) { - public fun people(_projection: PersonProjection.() -> PersonProjection): QueryProjection { - field("people", PersonProjection(inputValueSerializer), _projection) + public fun people(_alias: String? = null, _projection: PersonProjection.() -> PersonProjection): + QueryProjection { + field(_alias, "people", PersonProjection(inputValueSerializer), _projection) return this } } diff --git a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithNonNullableComplexType/expected/client/MyTypeProjection.kt b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithNonNullableComplexType/expected/client/MyTypeProjection.kt index e8b7abf07..a5d9473b4 100644 --- a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithNonNullableComplexType/expected/client/MyTypeProjection.kt +++ b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithNonNullableComplexType/expected/client/MyTypeProjection.kt @@ -2,12 +2,14 @@ package com.netflix.graphql.dgs.codegen.cases.dataClassWithNonNullableComplexTyp import com.netflix.graphql.dgs.client.codegen.InputValueSerializerInterface import com.netflix.graphql.dgs.codegen.GraphQLProjection +import kotlin.String public class MyTypeProjection( inputValueSerializer: InputValueSerializerInterface? = null, ) : GraphQLProjection(inputValueSerializer) { - public fun other(_projection: OtherTypeProjection.() -> OtherTypeProjection): MyTypeProjection { - field("other", OtherTypeProjection(inputValueSerializer), _projection) + public fun other(_alias: String? = null, + _projection: OtherTypeProjection.() -> OtherTypeProjection): MyTypeProjection { + field(_alias, "other", OtherTypeProjection(inputValueSerializer), _projection) return this } } diff --git a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithNonNullableListOfNullableValues/expected/client/QueryProjection.kt b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithNonNullableListOfNullableValues/expected/client/QueryProjection.kt index 5a92edce7..6db6bfc60 100644 --- a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithNonNullableListOfNullableValues/expected/client/QueryProjection.kt +++ b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithNonNullableListOfNullableValues/expected/client/QueryProjection.kt @@ -2,12 +2,14 @@ package com.netflix.graphql.dgs.codegen.cases.dataClassWithNonNullableListOfNull import com.netflix.graphql.dgs.client.codegen.InputValueSerializerInterface import com.netflix.graphql.dgs.codegen.GraphQLProjection +import kotlin.String public class QueryProjection( inputValueSerializer: InputValueSerializerInterface? = null, ) : GraphQLProjection(inputValueSerializer) { - public fun people(_projection: PersonProjection.() -> PersonProjection): QueryProjection { - field("people", PersonProjection(inputValueSerializer), _projection) + public fun people(_alias: String? = null, _projection: PersonProjection.() -> PersonProjection): + QueryProjection { + field(_alias, "people", PersonProjection(inputValueSerializer), _projection) return this } } diff --git a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithNonNullableProperties/expected/client/QueryProjection.kt b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithNonNullableProperties/expected/client/QueryProjection.kt index 6c66b2526..1e85991f5 100644 --- a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithNonNullableProperties/expected/client/QueryProjection.kt +++ b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithNonNullableProperties/expected/client/QueryProjection.kt @@ -2,12 +2,14 @@ package com.netflix.graphql.dgs.codegen.cases.dataClassWithNonNullableProperties import com.netflix.graphql.dgs.client.codegen.InputValueSerializerInterface import com.netflix.graphql.dgs.codegen.GraphQLProjection +import kotlin.String public class QueryProjection( inputValueSerializer: InputValueSerializerInterface? = null, ) : GraphQLProjection(inputValueSerializer) { - public fun people(_projection: PersonProjection.() -> PersonProjection): QueryProjection { - field("people", PersonProjection(inputValueSerializer), _projection) + public fun people(_alias: String? = null, _projection: PersonProjection.() -> PersonProjection): + QueryProjection { + field(_alias, "people", PersonProjection(inputValueSerializer), _projection) return this } } diff --git a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithRecursiveField/expected/client/PersonProjection.kt b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithRecursiveField/expected/client/PersonProjection.kt index daa6b0f04..07a41033a 100644 --- a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithRecursiveField/expected/client/PersonProjection.kt +++ b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithRecursiveField/expected/client/PersonProjection.kt @@ -2,6 +2,7 @@ package com.netflix.graphql.dgs.codegen.cases.dataClassWithRecursiveField.expect import com.netflix.graphql.dgs.client.codegen.InputValueSerializerInterface import com.netflix.graphql.dgs.codegen.GraphQLProjection +import kotlin.String public class PersonProjection( inputValueSerializer: InputValueSerializerInterface? = null, @@ -18,8 +19,9 @@ public class PersonProjection( return this } - public fun friends(_projection: PersonProjection.() -> PersonProjection): PersonProjection { - field("friends", PersonProjection(inputValueSerializer), _projection) + public fun friends(_alias: String? = null, _projection: PersonProjection.() -> PersonProjection): + PersonProjection { + field(_alias, "friends", PersonProjection(inputValueSerializer), _projection) return this } } diff --git a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithRecursiveField/expected/client/QueryProjection.kt b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithRecursiveField/expected/client/QueryProjection.kt index 01a74e4f7..6bc9c817f 100644 --- a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithRecursiveField/expected/client/QueryProjection.kt +++ b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithRecursiveField/expected/client/QueryProjection.kt @@ -2,12 +2,14 @@ package com.netflix.graphql.dgs.codegen.cases.dataClassWithRecursiveField.expect import com.netflix.graphql.dgs.client.codegen.InputValueSerializerInterface import com.netflix.graphql.dgs.codegen.GraphQLProjection +import kotlin.String public class QueryProjection( inputValueSerializer: InputValueSerializerInterface? = null, ) : GraphQLProjection(inputValueSerializer) { - public fun people(_projection: PersonProjection.() -> PersonProjection): QueryProjection { - field("people", PersonProjection(inputValueSerializer), _projection) + public fun people(_alias: String? = null, _projection: PersonProjection.() -> PersonProjection): + QueryProjection { + field(_alias, "people", PersonProjection(inputValueSerializer), _projection) return this } } diff --git a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithStringProperties/expected/client/QueryProjection.kt b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithStringProperties/expected/client/QueryProjection.kt index e5ddabb05..8fb93136d 100644 --- a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithStringProperties/expected/client/QueryProjection.kt +++ b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithStringProperties/expected/client/QueryProjection.kt @@ -2,12 +2,14 @@ package com.netflix.graphql.dgs.codegen.cases.dataClassWithStringProperties.expe import com.netflix.graphql.dgs.client.codegen.InputValueSerializerInterface import com.netflix.graphql.dgs.codegen.GraphQLProjection +import kotlin.String public class QueryProjection( inputValueSerializer: InputValueSerializerInterface? = null, ) : GraphQLProjection(inputValueSerializer) { - public fun people(_projection: PersonProjection.() -> PersonProjection): QueryProjection { - field("people", PersonProjection(inputValueSerializer), _projection) + public fun people(_alias: String? = null, _projection: PersonProjection.() -> PersonProjection): + QueryProjection { + field(_alias, "people", PersonProjection(inputValueSerializer), _projection) return this } } diff --git a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/input/test/QueryTest.kt b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/input/test/QueryTest.kt index 9788b2839..dcc4d9e2c 100644 --- a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/input/test/QueryTest.kt +++ b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/input/test/QueryTest.kt @@ -18,33 +18,12 @@ package com.netflix.graphql.dgs.codegen.cases.input.test -import com.netflix.graphql.dgs.client.codegen.InputValueSerializer import com.netflix.graphql.dgs.codegen.cases.input.expected.DgsClient import com.netflix.graphql.dgs.codegen.cases.input.expected.types.MovieFilter -import graphql.language.StringValue -import graphql.language.Value -import graphql.schema.Coercing import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test class QueryTest { - private val movieCoercing = object : Coercing { - override fun serialize(filter: Any): String { - return (filter as? MovieFilter)?.genre ?: "" - } - - override fun parseValue(input: Any): MovieFilter { - return MovieFilter(input.toString()) - } - - override fun parseLiteral(input: Any): MovieFilter { - return MovieFilter(input.toString()) - } - - override fun valueToLiteral(input: Any): Value<*> { - return StringValue.of(serialize(input)) - } - } @Test fun testQueryWithNoFilter() { @@ -130,25 +109,4 @@ class QueryTest { query ) } - - @Test - fun testQueryWithFilterAndCustomCoercing() { - - val serializer = InputValueSerializer( - mapOf(MovieFilter::class.java to movieCoercing) - ) - val query = DgsClient.buildQuery(serializer) { - movies(filter = MovieFilter(genre = "horror")) - } - - Assertions.assertEquals( - """{ - | __typename - | movies(filter: "horror") - |} - | - """.trimMargin(), - query - ) - } } diff --git a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/interfaceClassWithInterfaceFields/expected/client/BirdProjection.kt b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/interfaceClassWithInterfaceFields/expected/client/BirdProjection.kt index d7903679f..1a8ca612f 100644 --- a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/interfaceClassWithInterfaceFields/expected/client/BirdProjection.kt +++ b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/interfaceClassWithInterfaceFields/expected/client/BirdProjection.kt @@ -2,6 +2,7 @@ package com.netflix.graphql.dgs.codegen.cases.interfaceClassWithInterfaceFields. import com.netflix.graphql.dgs.client.codegen.InputValueSerializerInterface import com.netflix.graphql.dgs.codegen.GraphQLProjection +import kotlin.String public class BirdProjection( inputValueSerializer: InputValueSerializerInterface? = null, @@ -24,18 +25,21 @@ public class BirdProjection( return this } - public fun mother(_projection: BirdProjection.() -> BirdProjection): BirdProjection { - field("mother", BirdProjection(inputValueSerializer), _projection) + public fun mother(_alias: String? = null, _projection: BirdProjection.() -> BirdProjection): + BirdProjection { + field(_alias, "mother", BirdProjection(inputValueSerializer), _projection) return this } - public fun father(_projection: BirdProjection.() -> BirdProjection): BirdProjection { - field("father", BirdProjection(inputValueSerializer), _projection) + public fun father(_alias: String? = null, _projection: BirdProjection.() -> BirdProjection): + BirdProjection { + field(_alias, "father", BirdProjection(inputValueSerializer), _projection) return this } - public fun parents(_projection: BirdProjection.() -> BirdProjection): BirdProjection { - field("parents", BirdProjection(inputValueSerializer), _projection) + public fun parents(_alias: String? = null, _projection: BirdProjection.() -> BirdProjection): + BirdProjection { + field(_alias, "parents", BirdProjection(inputValueSerializer), _projection) return this } } diff --git a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/interfaceClassWithInterfaceFields/expected/client/DogProjection.kt b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/interfaceClassWithInterfaceFields/expected/client/DogProjection.kt index 4719cc9d7..209cce175 100644 --- a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/interfaceClassWithInterfaceFields/expected/client/DogProjection.kt +++ b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/interfaceClassWithInterfaceFields/expected/client/DogProjection.kt @@ -2,6 +2,7 @@ package com.netflix.graphql.dgs.codegen.cases.interfaceClassWithInterfaceFields. import com.netflix.graphql.dgs.client.codegen.InputValueSerializerInterface import com.netflix.graphql.dgs.codegen.GraphQLProjection +import kotlin.String public class DogProjection( inputValueSerializer: InputValueSerializerInterface? = null, @@ -24,18 +25,21 @@ public class DogProjection( return this } - public fun mother(_projection: DogProjection.() -> DogProjection): DogProjection { - field("mother", DogProjection(inputValueSerializer), _projection) + public fun mother(_alias: String? = null, _projection: DogProjection.() -> DogProjection): + DogProjection { + field(_alias, "mother", DogProjection(inputValueSerializer), _projection) return this } - public fun father(_projection: DogProjection.() -> DogProjection): DogProjection { - field("father", DogProjection(inputValueSerializer), _projection) + public fun father(_alias: String? = null, _projection: DogProjection.() -> DogProjection): + DogProjection { + field(_alias, "father", DogProjection(inputValueSerializer), _projection) return this } - public fun parents(_projection: DogProjection.() -> DogProjection): DogProjection { - field("parents", DogProjection(inputValueSerializer), _projection) + public fun parents(_alias: String? = null, _projection: DogProjection.() -> DogProjection): + DogProjection { + field(_alias, "parents", DogProjection(inputValueSerializer), _projection) return this } } diff --git a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/interfaceClassWithInterfaceFields/expected/client/PetProjection.kt b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/interfaceClassWithInterfaceFields/expected/client/PetProjection.kt index 476271195..0563bdb4c 100644 --- a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/interfaceClassWithInterfaceFields/expected/client/PetProjection.kt +++ b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/interfaceClassWithInterfaceFields/expected/client/PetProjection.kt @@ -2,6 +2,7 @@ package com.netflix.graphql.dgs.codegen.cases.interfaceClassWithInterfaceFields. import com.netflix.graphql.dgs.client.codegen.InputValueSerializerInterface import com.netflix.graphql.dgs.codegen.GraphQLProjection +import kotlin.String public class PetProjection( inputValueSerializer: InputValueSerializerInterface? = null, @@ -24,18 +25,21 @@ public class PetProjection( return this } - public fun mother(_projection: PetProjection.() -> PetProjection): PetProjection { - field("mother", PetProjection(inputValueSerializer), _projection) + public fun mother(_alias: String? = null, _projection: PetProjection.() -> PetProjection): + PetProjection { + field(_alias, "mother", PetProjection(inputValueSerializer), _projection) return this } - public fun father(_projection: PetProjection.() -> PetProjection): PetProjection { - field("father", PetProjection(inputValueSerializer), _projection) + public fun father(_alias: String? = null, _projection: PetProjection.() -> PetProjection): + PetProjection { + field(_alias, "father", PetProjection(inputValueSerializer), _projection) return this } - public fun parents(_projection: PetProjection.() -> PetProjection): PetProjection { - field("parents", PetProjection(inputValueSerializer), _projection) + public fun parents(_alias: String? = null, _projection: PetProjection.() -> PetProjection): + PetProjection { + field(_alias, "parents", PetProjection(inputValueSerializer), _projection) return this } diff --git a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/interfaceClassWithInterfaceFieldsOfDifferentType/expected/client/DogProjection.kt b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/interfaceClassWithInterfaceFieldsOfDifferentType/expected/client/DogProjection.kt index 2ef26199b..637f33ab8 100644 --- a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/interfaceClassWithInterfaceFieldsOfDifferentType/expected/client/DogProjection.kt +++ b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/interfaceClassWithInterfaceFieldsOfDifferentType/expected/client/DogProjection.kt @@ -2,6 +2,7 @@ package com.netflix.graphql.dgs.codegen.cases.interfaceClassWithInterfaceFieldsO import com.netflix.graphql.dgs.client.codegen.InputValueSerializerInterface import com.netflix.graphql.dgs.codegen.GraphQLProjection +import kotlin.String public class DogProjection( inputValueSerializer: InputValueSerializerInterface? = null, @@ -12,8 +13,9 @@ public class DogProjection( return this } - public fun diet(_projection: VegetarianProjection.() -> VegetarianProjection): DogProjection { - field("diet", VegetarianProjection(inputValueSerializer), _projection) + public fun diet(_alias: String? = null, + _projection: VegetarianProjection.() -> VegetarianProjection): DogProjection { + field(_alias, "diet", VegetarianProjection(inputValueSerializer), _projection) return this } } diff --git a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/interfaceClassWithInterfaceFieldsOfDifferentType/expected/client/PetProjection.kt b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/interfaceClassWithInterfaceFieldsOfDifferentType/expected/client/PetProjection.kt index 4b13eafa1..53625ba2a 100644 --- a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/interfaceClassWithInterfaceFieldsOfDifferentType/expected/client/PetProjection.kt +++ b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/interfaceClassWithInterfaceFieldsOfDifferentType/expected/client/PetProjection.kt @@ -2,6 +2,7 @@ package com.netflix.graphql.dgs.codegen.cases.interfaceClassWithInterfaceFieldsO import com.netflix.graphql.dgs.client.codegen.InputValueSerializerInterface import com.netflix.graphql.dgs.codegen.GraphQLProjection +import kotlin.String public class PetProjection( inputValueSerializer: InputValueSerializerInterface? = null, @@ -12,8 +13,9 @@ public class PetProjection( return this } - public fun diet(_projection: DietProjection.() -> DietProjection): PetProjection { - field("diet", DietProjection(inputValueSerializer), _projection) + public fun diet(_alias: String? = null, _projection: DietProjection.() -> DietProjection): + PetProjection { + field(_alias, "diet", DietProjection(inputValueSerializer), _projection) return this } diff --git a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/interfaceClassWithNonNullableFields/expected/client/QueryProjection.kt b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/interfaceClassWithNonNullableFields/expected/client/QueryProjection.kt index 25f98faa8..2589235f5 100644 --- a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/interfaceClassWithNonNullableFields/expected/client/QueryProjection.kt +++ b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/interfaceClassWithNonNullableFields/expected/client/QueryProjection.kt @@ -2,12 +2,14 @@ package com.netflix.graphql.dgs.codegen.cases.interfaceClassWithNonNullableField import com.netflix.graphql.dgs.client.codegen.InputValueSerializerInterface import com.netflix.graphql.dgs.codegen.GraphQLProjection +import kotlin.String public class QueryProjection( inputValueSerializer: InputValueSerializerInterface? = null, ) : GraphQLProjection(inputValueSerializer) { - public fun people(_projection: PersonProjection.() -> PersonProjection): QueryProjection { - field("people", PersonProjection(inputValueSerializer), _projection) + public fun people(_alias: String? = null, _projection: PersonProjection.() -> PersonProjection): + QueryProjection { + field(_alias, "people", PersonProjection(inputValueSerializer), _projection) return this } } diff --git a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/interfaceWithInterfaceInheritance/expected/client/FruitProjection.kt b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/interfaceWithInterfaceInheritance/expected/client/FruitProjection.kt index 81f67918a..9b9201b66 100644 --- a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/interfaceWithInterfaceInheritance/expected/client/FruitProjection.kt +++ b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/interfaceWithInterfaceInheritance/expected/client/FruitProjection.kt @@ -2,12 +2,14 @@ package com.netflix.graphql.dgs.codegen.cases.interfaceWithInterfaceInheritance. import com.netflix.graphql.dgs.client.codegen.InputValueSerializerInterface import com.netflix.graphql.dgs.codegen.GraphQLProjection +import kotlin.String public class FruitProjection( inputValueSerializer: InputValueSerializerInterface? = null, ) : GraphQLProjection(inputValueSerializer) { - public fun seeds(_projection: SeedProjection.() -> SeedProjection): FruitProjection { - field("seeds", SeedProjection(inputValueSerializer), _projection) + public fun seeds(_alias: String? = null, _projection: SeedProjection.() -> SeedProjection): + FruitProjection { + field(_alias, "seeds", SeedProjection(inputValueSerializer), _projection) return this } diff --git a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/interfaceWithInterfaceInheritance/expected/client/QueryProjection.kt b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/interfaceWithInterfaceInheritance/expected/client/QueryProjection.kt index 8c8900e6e..102203ef0 100644 --- a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/interfaceWithInterfaceInheritance/expected/client/QueryProjection.kt +++ b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/interfaceWithInterfaceInheritance/expected/client/QueryProjection.kt @@ -2,12 +2,14 @@ package com.netflix.graphql.dgs.codegen.cases.interfaceWithInterfaceInheritance. import com.netflix.graphql.dgs.client.codegen.InputValueSerializerInterface import com.netflix.graphql.dgs.codegen.GraphQLProjection +import kotlin.String public class QueryProjection( inputValueSerializer: InputValueSerializerInterface? = null, ) : GraphQLProjection(inputValueSerializer) { - public fun fruits(_projection: FruitProjection.() -> FruitProjection): QueryProjection { - field("fruits", FruitProjection(inputValueSerializer), _projection) + public fun fruits(_alias: String? = null, _projection: FruitProjection.() -> FruitProjection): + QueryProjection { + field(_alias, "fruits", FruitProjection(inputValueSerializer), _projection) return this } } diff --git a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/interfaceWithInterfaceInheritance/expected/client/StoneFruitProjection.kt b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/interfaceWithInterfaceInheritance/expected/client/StoneFruitProjection.kt index 8164992af..68b786b68 100644 --- a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/interfaceWithInterfaceInheritance/expected/client/StoneFruitProjection.kt +++ b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/interfaceWithInterfaceInheritance/expected/client/StoneFruitProjection.kt @@ -2,6 +2,7 @@ package com.netflix.graphql.dgs.codegen.cases.interfaceWithInterfaceInheritance. import com.netflix.graphql.dgs.client.codegen.InputValueSerializerInterface import com.netflix.graphql.dgs.codegen.GraphQLProjection +import kotlin.String public class StoneFruitProjection( inputValueSerializer: InputValueSerializerInterface? = null, @@ -12,8 +13,9 @@ public class StoneFruitProjection( return this } - public fun seeds(_projection: SeedProjection.() -> SeedProjection): StoneFruitProjection { - field("seeds", SeedProjection(inputValueSerializer), _projection) + public fun seeds(_alias: String? = null, _projection: SeedProjection.() -> SeedProjection): + StoneFruitProjection { + field(_alias, "seeds", SeedProjection(inputValueSerializer), _projection) return this } } diff --git a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/interfaceWithUnderscoreFields/expected/DgsClient.kt b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/interfaceWithUnderscoreFields/expected/DgsClient.kt index 237761fd7..95979d83e 100644 --- a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/interfaceWithUnderscoreFields/expected/DgsClient.kt +++ b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/interfaceWithUnderscoreFields/expected/DgsClient.kt @@ -1,11 +1,14 @@ package com.netflix.graphql.dgs.codegen.cases.interfaceWithUnderscoreFields.expected +import com.netflix.graphql.dgs.client.codegen.InputValueSerializerInterface import com.netflix.graphql.dgs.codegen.GraphQLProjection import com.netflix.graphql.dgs.codegen.cases.interfaceWithUnderscoreFields.expected.client.QueryProjection import graphql.language.OperationDefinition import kotlin.String public object DgsClient { - public fun buildQuery(_projection: QueryProjection.() -> QueryProjection): String = - GraphQLProjection.asQuery(OperationDefinition.Operation.QUERY, QueryProjection(), _projection) + public fun buildQuery(inputValueSerializer: InputValueSerializerInterface? = null, + _projection: QueryProjection.() -> QueryProjection): String = + GraphQLProjection.asQuery(OperationDefinition.Operation.QUERY, + QueryProjection(inputValueSerializer), _projection) } diff --git a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/interfaceWithUnderscoreFields/expected/client/IProjection.kt b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/interfaceWithUnderscoreFields/expected/client/IProjection.kt index 011980c69..96585c3c8 100644 --- a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/interfaceWithUnderscoreFields/expected/client/IProjection.kt +++ b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/interfaceWithUnderscoreFields/expected/client/IProjection.kt @@ -1,8 +1,11 @@ package com.netflix.graphql.dgs.codegen.cases.interfaceWithUnderscoreFields.expected.client +import com.netflix.graphql.dgs.client.codegen.InputValueSerializerInterface import com.netflix.graphql.dgs.codegen.GraphQLProjection -public class IProjection : GraphQLProjection() { +public class IProjection( + inputValueSerializer: InputValueSerializerInterface? = null, +) : GraphQLProjection(inputValueSerializer) { public val _id: IProjection get() { field("_id") diff --git a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/interfaceWithUnderscoreFields/expected/client/QueryProjection.kt b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/interfaceWithUnderscoreFields/expected/client/QueryProjection.kt index d76763edc..1d5e52431 100644 --- a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/interfaceWithUnderscoreFields/expected/client/QueryProjection.kt +++ b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/interfaceWithUnderscoreFields/expected/client/QueryProjection.kt @@ -1,10 +1,15 @@ package com.netflix.graphql.dgs.codegen.cases.interfaceWithUnderscoreFields.expected.client +import com.netflix.graphql.dgs.client.codegen.InputValueSerializerInterface import com.netflix.graphql.dgs.codegen.GraphQLProjection +import kotlin.String -public class QueryProjection : GraphQLProjection() { - public fun `is`(_projection: IProjection.() -> IProjection): QueryProjection { - field("is", IProjection(), _projection) +public class QueryProjection( + inputValueSerializer: InputValueSerializerInterface? = null, +) : GraphQLProjection(inputValueSerializer) { + public fun `is`(_alias: String? = null, _projection: IProjection.() -> IProjection): + QueryProjection { + field(_alias, "is", IProjection(inputValueSerializer), _projection) return this } } diff --git a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/interfaceWithUnderscoreFields/expected/client/TProjection.kt b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/interfaceWithUnderscoreFields/expected/client/TProjection.kt index 32bc8579e..fb1d2a260 100644 --- a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/interfaceWithUnderscoreFields/expected/client/TProjection.kt +++ b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/interfaceWithUnderscoreFields/expected/client/TProjection.kt @@ -1,8 +1,11 @@ package com.netflix.graphql.dgs.codegen.cases.interfaceWithUnderscoreFields.expected.client +import com.netflix.graphql.dgs.client.codegen.InputValueSerializerInterface import com.netflix.graphql.dgs.codegen.GraphQLProjection -public class TProjection : GraphQLProjection() { +public class TProjection( + inputValueSerializer: InputValueSerializerInterface? = null, +) : GraphQLProjection(inputValueSerializer) { public val _id: TProjection get() { field("_id") diff --git a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/projectionWithType/expected/client/QueryProjection.kt b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/projectionWithType/expected/client/QueryProjection.kt index 6bec1be5a..e1101afae 100644 --- a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/projectionWithType/expected/client/QueryProjection.kt +++ b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/projectionWithType/expected/client/QueryProjection.kt @@ -2,17 +2,20 @@ package com.netflix.graphql.dgs.codegen.cases.projectionWithType.expected.client import com.netflix.graphql.dgs.client.codegen.InputValueSerializerInterface import com.netflix.graphql.dgs.codegen.GraphQLProjection +import kotlin.String public class QueryProjection( inputValueSerializer: InputValueSerializerInterface? = null, ) : GraphQLProjection(inputValueSerializer) { - public fun person(_projection: PersonProjection.() -> PersonProjection): QueryProjection { - field("person", PersonProjection(inputValueSerializer), _projection) + public fun person(_alias: String? = null, _projection: PersonProjection.() -> PersonProjection): + QueryProjection { + field(_alias, "person", PersonProjection(inputValueSerializer), _projection) return this } - public fun people(_projection: PersonProjection.() -> PersonProjection): QueryProjection { - field("people", PersonProjection(inputValueSerializer), _projection) + public fun people(_alias: String? = null, _projection: PersonProjection.() -> PersonProjection): + QueryProjection { + field(_alias, "people", PersonProjection(inputValueSerializer), _projection) return this } } 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 7c8293453..ad71ba58c 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,13 +9,14 @@ public class QueryProjection( inputValueSerializer: InputValueSerializerInterface? = null, ) : GraphQLProjection(inputValueSerializer) { public fun person( + _alias: String? = null, a1: String? = default("a1"), a2: String, a3: I? = default("a3"), _projection: PersonProjection.() -> PersonProjection, ): QueryProjection { - field("person", PersonProjection(inputValueSerializer), _projection, "a1" to a1 , "a2" to a2 , - "a3" to a3) + field(_alias, "person", PersonProjection(inputValueSerializer), _projection, "a1" to a1 , "a2" + to a2 , "a3" to a3) return this } } 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 61fa9bd74..a809790c5 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 @@ -52,4 +52,33 @@ class QueryTest { query ) } + + @Test + fun testQueryWithAlias() { + val query = DgsClient.buildQuery { + person(_alias= "person1", a2 = "person1") { + firstname + } + person(_alias= "person2", a2 = "person2") { + firstname + } + } + + assertEquals( + """{ + | __typename + | person1: person(a2: "person1") { + | __typename + | firstname + | } + | person2: person(a2: "person2") { + | __typename + | firstname + | } + |} + | + """.trimMargin(), + query + ) + } } diff --git a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/projectionWithUnion/expected/client/QueryProjection.kt b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/projectionWithUnion/expected/client/QueryProjection.kt index 82720c43a..563b68d05 100644 --- a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/projectionWithUnion/expected/client/QueryProjection.kt +++ b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/projectionWithUnion/expected/client/QueryProjection.kt @@ -2,17 +2,20 @@ package com.netflix.graphql.dgs.codegen.cases.projectionWithUnion.expected.clien import com.netflix.graphql.dgs.client.codegen.InputValueSerializerInterface import com.netflix.graphql.dgs.codegen.GraphQLProjection +import kotlin.String public class QueryProjection( inputValueSerializer: InputValueSerializerInterface? = null, ) : GraphQLProjection(inputValueSerializer) { - public fun u(_projection: UProjection.() -> UProjection): QueryProjection { - field("u", UProjection(inputValueSerializer), _projection) + public fun u(_alias: String? = null, _projection: UProjection.() -> UProjection): + QueryProjection { + field(_alias, "u", UProjection(inputValueSerializer), _projection) return this } - public fun us(_projection: UProjection.() -> UProjection): QueryProjection { - field("us", UProjection(inputValueSerializer), _projection) + public fun us(_alias: String? = null, _projection: UProjection.() -> UProjection): + QueryProjection { + field(_alias, "us", UProjection(inputValueSerializer), _projection) return this } } diff --git a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/union/expected/client/QueryProjection.kt b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/union/expected/client/QueryProjection.kt index 631aedad1..852f9b315 100644 --- a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/union/expected/client/QueryProjection.kt +++ b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/union/expected/client/QueryProjection.kt @@ -2,13 +2,14 @@ package com.netflix.graphql.dgs.codegen.cases.union.expected.client import com.netflix.graphql.dgs.client.codegen.InputValueSerializerInterface import com.netflix.graphql.dgs.codegen.GraphQLProjection +import kotlin.String public class QueryProjection( inputValueSerializer: InputValueSerializerInterface? = null, ) : GraphQLProjection(inputValueSerializer) { - public fun search(_projection: SearchResultProjection.() -> SearchResultProjection): - QueryProjection { - field("search", SearchResultProjection(inputValueSerializer), _projection) + public fun search(_alias: String? = null, + _projection: SearchResultProjection.() -> SearchResultProjection): QueryProjection { + field(_alias, "search", SearchResultProjection(inputValueSerializer), _projection) return this } } 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 52bed646d..51296ec79 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 @@ -7,9 +7,13 @@ import kotlin.String public class QueryProjection( inputValueSerializer: InputValueSerializerInterface? = null, ) : GraphQLProjection(inputValueSerializer) { - public fun search(text: String, - _projection: SearchResultPageProjection.() -> SearchResultPageProjection): QueryProjection { - field("search", SearchResultPageProjection(inputValueSerializer), _projection, "text" to text) + public fun search( + _alias: String? = null, + text: String, + _projection: SearchResultPageProjection.() -> SearchResultPageProjection, + ): QueryProjection { + field(_alias, "search", SearchResultPageProjection(inputValueSerializer), _projection, "text" to + text) return this } } diff --git a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/unionTypesWithoutInterfaceCanDeserialize/expected/client/SearchResultPageProjection.kt b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/unionTypesWithoutInterfaceCanDeserialize/expected/client/SearchResultPageProjection.kt index 88a7967c1..67b566586 100644 --- a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/unionTypesWithoutInterfaceCanDeserialize/expected/client/SearchResultPageProjection.kt +++ b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/unionTypesWithoutInterfaceCanDeserialize/expected/client/SearchResultPageProjection.kt @@ -2,13 +2,15 @@ package com.netflix.graphql.dgs.codegen.cases.unionTypesWithoutInterfaceCanDeser import com.netflix.graphql.dgs.client.codegen.InputValueSerializerInterface import com.netflix.graphql.dgs.codegen.GraphQLProjection +import kotlin.String public class SearchResultPageProjection( inputValueSerializer: InputValueSerializerInterface? = null, ) : GraphQLProjection(inputValueSerializer) { - public fun items(_projection: SearchResultProjection.() -> SearchResultProjection): + public fun items(_alias: String? = null, + _projection: SearchResultProjection.() -> SearchResultProjection): SearchResultPageProjection { - field("items", SearchResultProjection(inputValueSerializer), _projection) + field(_alias, "items", SearchResultProjection(inputValueSerializer), _projection) return this } } diff --git a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/unionWithExtendedType/expected/client/QueryProjection.kt b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/unionWithExtendedType/expected/client/QueryProjection.kt index a5b1dc557..fc7118c58 100644 --- a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/unionWithExtendedType/expected/client/QueryProjection.kt +++ b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/unionWithExtendedType/expected/client/QueryProjection.kt @@ -2,13 +2,14 @@ package com.netflix.graphql.dgs.codegen.cases.unionWithExtendedType.expected.cli import com.netflix.graphql.dgs.client.codegen.InputValueSerializerInterface import com.netflix.graphql.dgs.codegen.GraphQLProjection +import kotlin.String public class QueryProjection( inputValueSerializer: InputValueSerializerInterface? = null, ) : GraphQLProjection(inputValueSerializer) { - public fun search(_projection: SearchResultProjection.() -> SearchResultProjection): - QueryProjection { - field("search", SearchResultProjection(inputValueSerializer), _projection) + public fun search(_alias: String? = null, + _projection: SearchResultProjection.() -> SearchResultProjection): QueryProjection { + field(_alias, "search", SearchResultProjection(inputValueSerializer), _projection) return this } } 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 a39393bd9..c4b2d5e55 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,11 +121,12 @@ 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(projection) .returns(typeName) .addStatement( - """field(%S, %T(inputValueSerializer), _projection%L)""", + """field(_alias, %S, %T(inputValueSerializer), _projection%L)""", field.name, projectionType, field.inputValueDefinitions.joinToString(" ") { """, "${it.name}" to ${it.name}""" } diff --git a/graphql-dgs-codegen-shared-core/src/main/kotlin/com/netflix/graphql/dgs/codegen/Kotlin2Core.kt b/graphql-dgs-codegen-shared-core/src/main/kotlin/com/netflix/graphql/dgs/codegen/Kotlin2Core.kt index ac6398db7..6c27f9bad 100644 --- a/graphql-dgs-codegen-shared-core/src/main/kotlin/com/netflix/graphql/dgs/codegen/Kotlin2Core.kt +++ b/graphql-dgs-codegen-shared-core/src/main/kotlin/com/netflix/graphql/dgs/codegen/Kotlin2Core.kt @@ -128,6 +128,7 @@ abstract class GraphQLProjection( } protected fun field( + alias: String? = null, name: String, projection: T, projectionFields: T.() -> T, @@ -136,13 +137,14 @@ abstract class GraphQLProjection( val defaults = DefaultTracker.getAndClear(this::class.qualifiedName!!) projectionFields.invoke(projection) - builder.selection( - Field.newField() - .name(name) - .arguments(arguments(args.toList(), defaults)) - .selectionSet(projection.builder.build()) - .build() - ) + val fieldBuilder = Field.newField() + .name(name) + .arguments(arguments(args.toList(), defaults)) + .selectionSet(projection.builder.build()) + + alias?.also { fieldBuilder.alias(it) } + + builder.selection(fieldBuilder.build()) } protected fun fragment(