Skip to content

Commit e1ca748

Browse files
committed
Add support for aliases in queries
1 parent 95f27dc commit e1ca748

File tree

49 files changed

+275
-142
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+275
-142
lines changed

graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/constantsForInputTypes/expected/client/QueryProjection.kt

+7-3
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,15 @@ package com.netflix.graphql.dgs.codegen.cases.constantsForInputTypes.expected.cl
22

33
import com.netflix.graphql.dgs.codegen.GraphQLProjection
44
import com.netflix.graphql.dgs.codegen.cases.constantsForInputTypes.expected.types.PersonFilter
5+
import kotlin.String
56

67
public class QueryProjection : GraphQLProjection() {
7-
public fun people(filter: PersonFilter? = default<QueryProjection, PersonFilter?>("filter"),
8-
_projection: PersonProjection.() -> PersonProjection): QueryProjection {
9-
field("people", PersonProjection(), _projection, "filter" to filter)
8+
public fun people(
9+
_alias: String? = null,
10+
filter: PersonFilter? = default<QueryProjection, PersonFilter?>("filter"),
11+
_projection: PersonProjection.() -> PersonProjection,
12+
): QueryProjection {
13+
field(_alias, "people", PersonProjection(), _projection, "filter" to filter)
1014
return this
1115
}
1216
}

graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/constantsWithExtendedInputTypes/expected/client/QueryProjection.kt

+7-3
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,15 @@ package com.netflix.graphql.dgs.codegen.cases.constantsWithExtendedInputTypes.ex
22

33
import com.netflix.graphql.dgs.codegen.GraphQLProjection
44
import com.netflix.graphql.dgs.codegen.cases.constantsWithExtendedInputTypes.expected.types.PersonFilter
5+
import kotlin.String
56

67
public class QueryProjection : GraphQLProjection() {
7-
public fun people(filter: PersonFilter? = default<QueryProjection, PersonFilter?>("filter"),
8-
_projection: PersonProjection.() -> PersonProjection): QueryProjection {
9-
field("people", PersonProjection(), _projection, "filter" to filter)
8+
public fun people(
9+
_alias: String? = null,
10+
filter: PersonFilter? = default<QueryProjection, PersonFilter?>("filter"),
11+
_projection: PersonProjection.() -> PersonProjection,
12+
): QueryProjection {
13+
field(_alias, "people", PersonProjection(), _projection, "filter" to filter)
1014
return this
1115
}
1216
}
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
package com.netflix.graphql.dgs.codegen.cases.constantsWithExtendedInterface.expected.client
22

33
import com.netflix.graphql.dgs.codegen.GraphQLProjection
4+
import kotlin.String
45

56
public class QueryProjection : GraphQLProjection() {
6-
public fun people(_projection: PersonProjection.() -> PersonProjection): QueryProjection {
7-
field("people", PersonProjection(), _projection)
7+
public fun people(_alias: String? = null, _projection: PersonProjection.() -> PersonProjection):
8+
QueryProjection {
9+
field(_alias, "people", PersonProjection(), _projection)
810
return this
911
}
1012
}
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
package com.netflix.graphql.dgs.codegen.cases.constantsWithExtendedQuery.expected.client
22

33
import com.netflix.graphql.dgs.codegen.GraphQLProjection
4+
import kotlin.String
45

56
public class QueryProjection : GraphQLProjection() {
6-
public fun people(_projection: PersonProjection.() -> PersonProjection): QueryProjection {
7-
field("people", PersonProjection(), _projection)
7+
public fun people(_alias: String? = null, _projection: PersonProjection.() -> PersonProjection):
8+
QueryProjection {
9+
field(_alias, "people", PersonProjection(), _projection)
810
return this
911
}
1012

11-
public fun friends(_projection: PersonProjection.() -> PersonProjection): QueryProjection {
12-
field("friends", PersonProjection(), _projection)
13+
public fun friends(_alias: String? = null, _projection: PersonProjection.() -> PersonProjection):
14+
QueryProjection {
15+
field(_alias, "friends", PersonProjection(), _projection)
1316
return this
1417
}
1518
}
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
package com.netflix.graphql.dgs.codegen.cases.constantsWithExtendedTypes.expected.client
22

33
import com.netflix.graphql.dgs.codegen.GraphQLProjection
4+
import kotlin.String
45

56
public class QueryProjection : GraphQLProjection() {
6-
public fun people(_projection: PersonProjection.() -> PersonProjection): QueryProjection {
7-
field("people", PersonProjection(), _projection)
7+
public fun people(_alias: String? = null, _projection: PersonProjection.() -> PersonProjection):
8+
QueryProjection {
9+
field(_alias, "people", PersonProjection(), _projection)
810
return this
911
}
1012
}

graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassDocs/expected/client/QueryProjection.kt

+7-3
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,15 @@ package com.netflix.graphql.dgs.codegen.cases.dataClassDocs.expected.client
22

33
import com.netflix.graphql.dgs.codegen.GraphQLProjection
44
import com.netflix.graphql.dgs.codegen.cases.dataClassDocs.expected.types.MovieFilter
5+
import kotlin.String
56

67
public class QueryProjection : GraphQLProjection() {
7-
public fun search(movieFilter: MovieFilter, _projection: MovieProjection.() -> MovieProjection):
8-
QueryProjection {
9-
field("search", MovieProjection(), _projection, "movieFilter" to movieFilter)
8+
public fun search(
9+
_alias: String? = null,
10+
movieFilter: MovieFilter,
11+
_projection: MovieProjection.() -> MovieProjection,
12+
): QueryProjection {
13+
field(_alias, "search", MovieProjection(), _projection, "movieFilter" to movieFilter)
1014
return this
1115
}
1216
}

graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassFieldDocs/expected/client/QueryProjection.kt

+7-3
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,15 @@ package com.netflix.graphql.dgs.codegen.cases.dataClassFieldDocs.expected.client
22

33
import com.netflix.graphql.dgs.codegen.GraphQLProjection
44
import com.netflix.graphql.dgs.codegen.cases.dataClassFieldDocs.expected.types.MovieFilter
5+
import kotlin.String
56

67
public class QueryProjection : GraphQLProjection() {
7-
public fun search(movieFilter: MovieFilter, _projection: MovieProjection.() -> MovieProjection):
8-
QueryProjection {
9-
field("search", MovieProjection(), _projection, "movieFilter" to movieFilter)
8+
public fun search(
9+
_alias: String? = null,
10+
movieFilter: MovieFilter,
11+
_projection: MovieProjection.() -> MovieProjection,
12+
): QueryProjection {
13+
field(_alias, "search", MovieProjection(), _projection, "movieFilter" to movieFilter)
1014
return this
1115
}
1216
}
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
package com.netflix.graphql.dgs.codegen.cases.dataClassWIthNoFields.expected.client
22

33
import com.netflix.graphql.dgs.codegen.GraphQLProjection
4+
import kotlin.String
45

56
public class QueryProjection : GraphQLProjection() {
6-
public fun me(_projection: PersonProjection.() -> PersonProjection): QueryProjection {
7-
field("me", PersonProjection(), _projection)
7+
public fun me(_alias: String? = null, _projection: PersonProjection.() -> PersonProjection):
8+
QueryProjection {
9+
field(_alias, "me", PersonProjection(), _projection)
810
return this
911
}
1012
}
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
package com.netflix.graphql.dgs.codegen.cases.dataClassWithBooleanField.expected.client
22

33
import com.netflix.graphql.dgs.codegen.GraphQLProjection
4+
import kotlin.String
45

56
public class QueryProjection : GraphQLProjection() {
6-
public fun test(_projection: RequiredTestTypeProjection.() -> RequiredTestTypeProjection):
7-
QueryProjection {
8-
field("test", RequiredTestTypeProjection(), _projection)
7+
public fun test(_alias: String? = null,
8+
_projection: RequiredTestTypeProjection.() -> RequiredTestTypeProjection): QueryProjection {
9+
field(_alias, "test", RequiredTestTypeProjection(), _projection)
910
return this
1011
}
1112
}
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
package com.netflix.graphql.dgs.codegen.cases.dataClassWithDeclaredScalars.expected.client
22

33
import com.netflix.graphql.dgs.codegen.GraphQLProjection
4+
import kotlin.String
45

56
public class EntityConnectionProjection : GraphQLProjection() {
6-
public fun pageInfo(_projection: PageInfoProjection.() -> PageInfoProjection):
7-
EntityConnectionProjection {
8-
field("pageInfo", PageInfoProjection(), _projection)
7+
public fun pageInfo(_alias: String? = null,
8+
_projection: PageInfoProjection.() -> PageInfoProjection): EntityConnectionProjection {
9+
field(_alias, "pageInfo", PageInfoProjection(), _projection)
910
return this
1011
}
1112

12-
public fun edges(_projection: EntityEdgeProjection.() -> EntityEdgeProjection):
13-
EntityConnectionProjection {
14-
field("edges", EntityEdgeProjection(), _projection)
13+
public fun edges(_alias: String? = null,
14+
_projection: EntityEdgeProjection.() -> EntityEdgeProjection): EntityConnectionProjection {
15+
field(_alias, "edges", EntityEdgeProjection(), _projection)
1516
return this
1617
}
1718
}
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.netflix.graphql.dgs.codegen.cases.dataClassWithDeclaredScalars.expected.client
22

33
import com.netflix.graphql.dgs.codegen.GraphQLProjection
4+
import kotlin.String
45

56
public class EntityEdgeProjection : GraphQLProjection() {
67
public val cursor: EntityEdgeProjection
@@ -9,8 +10,9 @@ public class EntityEdgeProjection : GraphQLProjection() {
910
return this
1011
}
1112

12-
public fun node(_projection: EntityProjection.() -> EntityProjection): EntityEdgeProjection {
13-
field("node", EntityProjection(), _projection)
13+
public fun node(_alias: String? = null, _projection: EntityProjection.() -> EntityProjection):
14+
EntityEdgeProjection {
15+
field(_alias, "node", EntityProjection(), _projection)
1416
return this
1517
}
1618
}
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
package com.netflix.graphql.dgs.codegen.cases.dataClassWithDeclaredScalars.expected.client
22

33
import com.netflix.graphql.dgs.codegen.GraphQLProjection
4+
import kotlin.String
45

56
public class QueryProjection : GraphQLProjection() {
6-
public fun entity(_projection: EntityProjection.() -> EntityProjection): QueryProjection {
7-
field("entity", EntityProjection(), _projection)
7+
public fun entity(_alias: String? = null, _projection: EntityProjection.() -> EntityProjection):
8+
QueryProjection {
9+
field(_alias, "entity", EntityProjection(), _projection)
810
return this
911
}
1012

11-
public
12-
fun entityConnection(_projection: EntityConnectionProjection.() -> EntityConnectionProjection):
13-
QueryProjection {
14-
field("entityConnection", EntityConnectionProjection(), _projection)
13+
public fun entityConnection(_alias: String? = null,
14+
_projection: EntityConnectionProjection.() -> EntityConnectionProjection): QueryProjection {
15+
field(_alias, "entityConnection", EntityConnectionProjection(), _projection)
1516
return this
1617
}
1718
}

graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithDeeplyNestedComplexField/expected/client/CarProjection.kt

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.netflix.graphql.dgs.codegen.cases.dataClassWithDeeplyNestedComplexField.expected.client
22

33
import com.netflix.graphql.dgs.codegen.GraphQLProjection
4+
import kotlin.String
45

56
public class CarProjection : GraphQLProjection() {
67
public val make: CarProjection
@@ -15,8 +16,9 @@ public class CarProjection : GraphQLProjection() {
1516
return this
1617
}
1718

18-
public fun engine(_projection: EngineProjection.() -> EngineProjection): CarProjection {
19-
field("engine", EngineProjection(), _projection)
19+
public fun engine(_alias: String? = null, _projection: EngineProjection.() -> EngineProjection):
20+
CarProjection {
21+
field(_alias, "engine", EngineProjection(), _projection)
2022
return this
2123
}
2224
}

graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithDeeplyNestedComplexField/expected/client/EngineProjection.kt

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.netflix.graphql.dgs.codegen.cases.dataClassWithDeeplyNestedComplexField.expected.client
22

33
import com.netflix.graphql.dgs.codegen.GraphQLProjection
4+
import kotlin.String
45

56
public class EngineProjection : GraphQLProjection() {
67
public val type: EngineProjection
@@ -21,9 +22,9 @@ public class EngineProjection : GraphQLProjection() {
2122
return this
2223
}
2324

24-
public fun performance(_projection: PerformanceProjection.() -> PerformanceProjection):
25-
EngineProjection {
26-
field("performance", PerformanceProjection(), _projection)
25+
public fun performance(_alias: String? = null,
26+
_projection: PerformanceProjection.() -> PerformanceProjection): EngineProjection {
27+
field(_alias, "performance", PerformanceProjection(), _projection)
2728
return this
2829
}
2930
}
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
package com.netflix.graphql.dgs.codegen.cases.dataClassWithDeeplyNestedComplexField.expected.client
22

33
import com.netflix.graphql.dgs.codegen.GraphQLProjection
4+
import kotlin.String
45

56
public class QueryProjection : GraphQLProjection() {
6-
public fun cars(_projection: CarProjection.() -> CarProjection): QueryProjection {
7-
field("cars", CarProjection(), _projection)
7+
public fun cars(_alias: String? = null, _projection: CarProjection.() -> CarProjection):
8+
QueryProjection {
9+
field(_alias, "cars", CarProjection(), _projection)
810
return this
911
}
1012
}
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
package com.netflix.graphql.dgs.codegen.cases.dataClassWithExtendedInterface.expected.client
22

33
import com.netflix.graphql.dgs.codegen.GraphQLProjection
4+
import kotlin.String
45

56
public class QueryProjection : GraphQLProjection() {
6-
public fun people(_projection: PersonProjection.() -> PersonProjection): QueryProjection {
7-
field("people", PersonProjection(), _projection)
7+
public fun people(_alias: String? = null, _projection: PersonProjection.() -> PersonProjection):
8+
QueryProjection {
9+
field(_alias, "people", PersonProjection(), _projection)
810
return this
911
}
1012
}
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
package com.netflix.graphql.dgs.codegen.cases.dataClassWithInterface.expected.client
22

33
import com.netflix.graphql.dgs.codegen.GraphQLProjection
4+
import kotlin.String
45

56
public class QueryProjection : GraphQLProjection() {
6-
public fun people(_projection: PersonProjection.() -> PersonProjection): QueryProjection {
7-
field("people", PersonProjection(), _projection)
7+
public fun people(_alias: String? = null, _projection: PersonProjection.() -> PersonProjection):
8+
QueryProjection {
9+
field(_alias, "people", PersonProjection(), _projection)
810
return this
911
}
1012
}
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
package com.netflix.graphql.dgs.codegen.cases.dataClassWithInterfaceInheritance.expected.client
22

33
import com.netflix.graphql.dgs.codegen.GraphQLProjection
4+
import kotlin.String
45

56
public class QueryProjection : GraphQLProjection() {
6-
public fun people(_projection: PersonProjection.() -> PersonProjection): QueryProjection {
7-
field("people", PersonProjection(), _projection)
7+
public fun people(_alias: String? = null, _projection: PersonProjection.() -> PersonProjection):
8+
QueryProjection {
9+
field(_alias, "people", PersonProjection(), _projection)
810
return this
911
}
1012
}
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
package com.netflix.graphql.dgs.codegen.cases.dataClassWithListProperties.expected.client
22

33
import com.netflix.graphql.dgs.codegen.GraphQLProjection
4+
import kotlin.String
45

56
public class QueryProjection : GraphQLProjection() {
6-
public fun people(_projection: PersonProjection.() -> PersonProjection): QueryProjection {
7-
field("people", PersonProjection(), _projection)
7+
public fun people(_alias: String? = null, _projection: PersonProjection.() -> PersonProjection):
8+
QueryProjection {
9+
field(_alias, "people", PersonProjection(), _projection)
810
return this
911
}
1012
}
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
package com.netflix.graphql.dgs.codegen.cases.dataClassWithMappedInterfaces.expected.client
22

33
import com.netflix.graphql.dgs.codegen.GraphQLProjection
4+
import kotlin.String
45

56
public class QueryProjection : GraphQLProjection() {
6-
public fun products(_projection: ProductProjection.() -> ProductProjection): QueryProjection {
7-
field("products", ProductProjection(), _projection)
7+
public fun products(_alias: String? = null,
8+
_projection: ProductProjection.() -> ProductProjection): QueryProjection {
9+
field(_alias, "products", ProductProjection(), _projection)
810
return this
911
}
1012
}
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
package com.netflix.graphql.dgs.codegen.cases.dataClassWithMappedTypes.expected.client
22

33
import com.netflix.graphql.dgs.codegen.GraphQLProjection
4+
import kotlin.String
45

56
public class EntityConnectionProjection : GraphQLProjection() {
6-
public fun pageInfo(_projection: PageInfoProjection.() -> PageInfoProjection):
7-
EntityConnectionProjection {
8-
field("pageInfo", PageInfoProjection(), _projection)
7+
public fun pageInfo(_alias: String? = null,
8+
_projection: PageInfoProjection.() -> PageInfoProjection): EntityConnectionProjection {
9+
field(_alias, "pageInfo", PageInfoProjection(), _projection)
910
return this
1011
}
1112

12-
public fun edges(_projection: EntityEdgeProjection.() -> EntityEdgeProjection):
13-
EntityConnectionProjection {
14-
field("edges", EntityEdgeProjection(), _projection)
13+
public fun edges(_alias: String? = null,
14+
_projection: EntityEdgeProjection.() -> EntityEdgeProjection): EntityConnectionProjection {
15+
field(_alias, "edges", EntityEdgeProjection(), _projection)
1516
return this
1617
}
1718
}

0 commit comments

Comments
 (0)