Skip to content

Commit

Permalink
Merge pull request #676 from Netflix/feature/kotlin2-aliases
Browse files Browse the repository at this point in the history
Add support for aliases in kotlin2 queries
  • Loading branch information
mbossenbroek authored Apr 20, 2024
2 parents a5d4919 + f00d03c commit 8a6f6cf
Show file tree
Hide file tree
Showing 54 changed files with 298 additions and 192 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<QueryProjection, PersonFilter?>("filter"),
_projection: PersonProjection.() -> PersonProjection): QueryProjection {
field("people", PersonProjection(inputValueSerializer), _projection, "filter" to filter)
public fun people(
_alias: String? = null,
filter: PersonFilter? = default<QueryProjection, PersonFilter?>("filter"),
_projection: PersonProjection.() -> PersonProjection,
): QueryProjection {
field(_alias, "people", PersonProjection(inputValueSerializer), _projection, "filter" to filter)
return this
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<QueryProjection, PersonFilter?>("filter"),
_projection: PersonProjection.() -> PersonProjection): QueryProjection {
field("people", PersonProjection(inputValueSerializer), _projection, "filter" to filter)
public fun people(
_alias: String? = null,
filter: PersonFilter? = default<QueryProjection, PersonFilter?>("filter"),
_projection: PersonProjection.() -> PersonProjection,
): QueryProjection {
field(_alias, "people", PersonProjection(inputValueSerializer), _projection, "filter" to filter)
return this
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Loading

0 comments on commit 8a6f6cf

Please sign in to comment.