-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add custom suffix to generated types
Add a new configuration option `typeSuffix` to the `CodeGenConfig` class and update the code generation methods to append the `typeSuffix` to the generated type names. * **CodeGenConfig**: Add a new configuration option `typeSuffix` to the `CodeGenConfig` class. * **Java DataTypeGenerator**: Update the `generate` method to append the `typeSuffix` to the generated type names. * **Kotlin DataTypeGenerator**: Update the `generate` method to append the `typeSuffix` to the generated type names.
- Loading branch information
Showing
27 changed files
with
623 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
...st/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithPrefix/expected/DgsClient.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.netflix.graphql.dgs.codegen.cases.dataClassWithPrefix.expected | ||
|
||
import com.netflix.graphql.dgs.client.codegen.InputValueSerializerInterface | ||
import com.netflix.graphql.dgs.codegen.GraphQLProjection | ||
import com.netflix.graphql.dgs.codegen.cases.dataClassWithPrefix.expected.client.QueryProjection | ||
import graphql.language.OperationDefinition | ||
import kotlin.String | ||
|
||
public object DgsClient { | ||
public fun buildQuery(inputValueSerializer: InputValueSerializerInterface? = null, | ||
_projection: QueryProjection.() -> QueryProjection | ||
): String = | ||
GraphQLProjection.asQuery(OperationDefinition.Operation.QUERY, | ||
QueryProjection(inputValueSerializer), _projection) | ||
} |
29 changes: 29 additions & 0 deletions
29
...kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithPrefix/expected/DgsConstants.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.netflix.graphql.dgs.codegen.cases.dataClassWithPrefix.expected | ||
|
||
import kotlin.String | ||
|
||
public object DgsConstants { | ||
public const val QUERY_TYPE: String = "Query" | ||
|
||
public object QUERY { | ||
public const val TYPE_NAME: String = "Query" | ||
|
||
public const val Search: String = "search" | ||
|
||
public object SEARCH_INPUT_ARGUMENT { | ||
public const val MovieFilter: String = "movieFilter" | ||
} | ||
} | ||
|
||
public object MOVIE { | ||
public const val TYPE_NAME: String = "Movie" | ||
|
||
public const val Title: String = "title" | ||
} | ||
|
||
public object MOVIEFILTER { | ||
public const val TYPE_NAME: String = "MovieFilter" | ||
|
||
public const val TitleFilter: String = "titleFilter" | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
.../netflix/graphql/dgs/codegen/cases/dataClassWithPrefix/expected/client/MovieProjection.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.netflix.graphql.dgs.codegen.cases.dataClassWithPrefix.expected.client | ||
|
||
import com.netflix.graphql.dgs.client.codegen.InputValueSerializerInterface | ||
import com.netflix.graphql.dgs.codegen.GraphQLProjection | ||
|
||
public class MovieProjection( | ||
inputValueSerializer: InputValueSerializerInterface? = null, | ||
) : GraphQLProjection(inputValueSerializer) { | ||
public val title: MovieProjection | ||
get() { | ||
field("title") | ||
return this | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
.../netflix/graphql/dgs/codegen/cases/dataClassWithPrefix/expected/client/QueryProjection.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.netflix.graphql.dgs.codegen.cases.dataClassWithPrefix.expected.client | ||
|
||
import com.netflix.graphql.dgs.client.codegen.InputValueSerializerInterface | ||
import com.netflix.graphql.dgs.codegen.GraphQLProjection | ||
import com.netflix.graphql.dgs.codegen.cases.dataClassWithPrefix.expected.types.DgsMovieFilter | ||
import kotlin.String | ||
|
||
public class QueryProjection( | ||
inputValueSerializer: InputValueSerializerInterface? = null, | ||
) : GraphQLProjection(inputValueSerializer) { | ||
public fun search( | ||
movieFilter: DgsMovieFilter, | ||
_alias: String? = null, | ||
_projection: MovieProjection.() -> MovieProjection, | ||
): QueryProjection { | ||
field(_alias, "search", MovieProjection(inputValueSerializer), _projection, "movieFilter" to | ||
movieFilter) | ||
return this | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
...tlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithPrefix/expected/types/DgsMovie.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package com.netflix.graphql.dgs.codegen.cases.dataClassWithPrefix.expected.types | ||
|
||
import com.fasterxml.jackson.`annotation`.JsonIgnoreProperties | ||
import com.fasterxml.jackson.`annotation`.JsonProperty | ||
import com.fasterxml.jackson.`annotation`.JsonTypeInfo | ||
import com.fasterxml.jackson.databind.`annotation`.JsonDeserialize | ||
import com.fasterxml.jackson.databind.`annotation`.JsonPOJOBuilder | ||
import com.netflix.graphql.dgs.codegen.cases.dataClassDocs.expected.types.Movie | ||
import java.lang.IllegalStateException | ||
import kotlin.String | ||
import kotlin.jvm.JvmName | ||
|
||
/** | ||
* Movies are fun to watch. | ||
* They also work well as examples in GraphQL. | ||
*/ | ||
@JsonTypeInfo(use = JsonTypeInfo.Id.NONE) | ||
@JsonDeserialize(builder = DgsMovie.Builder::class) | ||
public class DgsMovie( | ||
title: () -> String? = titleDefault, | ||
) { | ||
private val __title: () -> String? = title | ||
|
||
@get:JvmName("getTitle") | ||
public val title: String? | ||
get() = __title.invoke() | ||
|
||
public companion object { | ||
private val titleDefault: () -> String? = | ||
{ throw IllegalStateException("Field `title` was not requested") } | ||
} | ||
|
||
@JsonPOJOBuilder | ||
@JsonIgnoreProperties("__typename") | ||
public class Builder { | ||
private var title: () -> String? = titleDefault | ||
|
||
@JsonProperty("title") | ||
public fun withTitle(title: String?): Builder = this.apply { | ||
this.title = { title } | ||
} | ||
|
||
public fun build(): Movie = Movie( | ||
title = title, | ||
) | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...om/netflix/graphql/dgs/codegen/cases/dataClassWithPrefix/expected/types/DgsMovieFilter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.netflix.graphql.dgs.codegen.cases.dataClassWithPrefix.expected.types | ||
|
||
import com.fasterxml.jackson.`annotation`.JsonCreator | ||
import com.fasterxml.jackson.`annotation`.JsonProperty | ||
import com.netflix.graphql.dgs.codegen.GraphQLInput | ||
import kotlin.Any | ||
import kotlin.Pair | ||
import kotlin.String | ||
import kotlin.collections.List | ||
|
||
/** | ||
* Example filter for Movies. | ||
* | ||
* It takes a title and such. | ||
*/ | ||
public class DgsMovieFilter @JsonCreator constructor( | ||
@JsonProperty("titleFilter") | ||
public val titleFilter: String? = default<DgsMovieFilter, String?>("titleFilter", null), | ||
) : GraphQLInput() { | ||
override fun fields(): List<Pair<String, Any?>> = listOf("titleFilter" to titleFilter) | ||
} |
41 changes: 41 additions & 0 deletions
41
...tlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithPrefix/expected/types/DgsQuery.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.netflix.graphql.dgs.codegen.cases.dataClassWithPrefix.expected.types | ||
|
||
import com.fasterxml.jackson.`annotation`.JsonIgnoreProperties | ||
import com.fasterxml.jackson.`annotation`.JsonProperty | ||
import com.fasterxml.jackson.`annotation`.JsonTypeInfo | ||
import com.fasterxml.jackson.databind.`annotation`.JsonDeserialize | ||
import com.fasterxml.jackson.databind.`annotation`.JsonPOJOBuilder | ||
import java.lang.IllegalStateException | ||
import kotlin.jvm.JvmName | ||
|
||
@JsonTypeInfo(use = JsonTypeInfo.Id.NONE) | ||
@JsonDeserialize(builder = DgsQuery.Builder::class) | ||
public class DgsQuery( | ||
search: () -> DgsMovie? = searchDefault, | ||
) { | ||
private val __search: () -> DgsMovie? = search | ||
|
||
@get:JvmName("getSearch") | ||
public val search: DgsMovie? | ||
get() = __search.invoke() | ||
|
||
public companion object { | ||
private val searchDefault: () -> DgsMovie? = | ||
{ throw IllegalStateException("Field `search` was not requested") } | ||
} | ||
|
||
@JsonPOJOBuilder | ||
@JsonIgnoreProperties("__typename") | ||
public class Builder { | ||
private var search: () -> DgsMovie? = searchDefault | ||
|
||
@JsonProperty("search") | ||
public fun withSearch(search: DgsMovie?): Builder = this.apply { | ||
this.search = { search } | ||
} | ||
|
||
public fun build(): DgsQuery = DgsQuery( | ||
search = search, | ||
) | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
...integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithPrefix/schema.graphql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
type Query { | ||
search(movieFilter: MovieFilter!): Movie | ||
} | ||
|
||
""" | ||
Movies are fun to watch. | ||
They also work well as examples in GraphQL. | ||
""" | ||
type Movie { | ||
title: String | ||
} | ||
|
||
""" | ||
Example filter for Movies. | ||
It takes a title and such. | ||
""" | ||
input MovieFilter { | ||
titleFilter: String | ||
} |
14 changes: 14 additions & 0 deletions
14
...egTest/kotlin/com/netflix/graphql/dgs/codegen/cases/inputWithPrefix/expected/DgsClient.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.netflix.graphql.dgs.codegen.cases.inputWithPrefix.expected | ||
|
||
import com.netflix.graphql.dgs.client.codegen.InputValueSerializerInterface | ||
import com.netflix.graphql.dgs.codegen.GraphQLProjection | ||
import com.netflix.graphql.dgs.codegen.cases.inputWithPrefix.expected.client.QueryProjection | ||
import graphql.language.OperationDefinition | ||
import kotlin.String | ||
|
||
public object DgsClient { | ||
public fun buildQuery(inputValueSerializer: InputValueSerializerInterface? = null, | ||
_projection: QueryProjection.() -> QueryProjection): String = | ||
GraphQLProjection.asQuery(OperationDefinition.Operation.QUERY, | ||
QueryProjection(inputValueSerializer), _projection) | ||
} |
23 changes: 23 additions & 0 deletions
23
...est/kotlin/com/netflix/graphql/dgs/codegen/cases/inputWithPrefix/expected/DgsConstants.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.netflix.graphql.dgs.codegen.cases.inputWithPrefix.expected | ||
|
||
import kotlin.String | ||
|
||
public object DgsConstants { | ||
public const val QUERY_TYPE: String = "Query" | ||
|
||
public object QUERY { | ||
public const val TYPE_NAME: String = "Query" | ||
|
||
public const val Movies: String = "movies" | ||
|
||
public object MOVIES_INPUT_ARGUMENT { | ||
public const val Filter: String = "filter" | ||
} | ||
} | ||
|
||
public object MOVIEFILTER { | ||
public const val TYPE_NAME: String = "MovieFilter" | ||
|
||
public const val Genre: String = "genre" | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
.../com/netflix/graphql/dgs/codegen/cases/inputWithPrefix/expected/client/QueryProjection.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.netflix.graphql.dgs.codegen.cases.inputWithPrefix.expected.client | ||
|
||
import com.netflix.graphql.dgs.client.codegen.InputValueSerializerInterface | ||
import com.netflix.graphql.dgs.codegen.GraphQLProjection | ||
import com.netflix.graphql.dgs.codegen.cases.inputWithPrefix.expected.types.DgsMovieFilter | ||
|
||
public class QueryProjection( | ||
inputValueSerializer: InputValueSerializerInterface? = null, | ||
) : GraphQLProjection(inputValueSerializer) { | ||
public fun movies(filter: DgsMovieFilter? = default<QueryProjection, DgsMovieFilter?>("filter")): | ||
QueryProjection { | ||
field("movies", "filter" to filter) | ||
return this | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...in/com/netflix/graphql/dgs/codegen/cases/inputWithPrefix/expected/types/DgsMovieFilter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.netflix.graphql.dgs.codegen.cases.inputWithPrefix.expected.types | ||
|
||
import com.fasterxml.jackson.`annotation`.JsonCreator | ||
import com.fasterxml.jackson.`annotation`.JsonProperty | ||
import com.netflix.graphql.dgs.codegen.GraphQLInput | ||
import kotlin.Any | ||
import kotlin.Pair | ||
import kotlin.String | ||
import kotlin.collections.List | ||
|
||
public class DgsMovieFilter @JsonCreator constructor( | ||
@JsonProperty("genre") | ||
public val genre: String? = default<DgsMovieFilter, String?>("genre", null), | ||
) : GraphQLInput() { | ||
override fun fields(): List<Pair<String, Any?>> = listOf("genre" to genre) | ||
} |
43 changes: 43 additions & 0 deletions
43
...t/kotlin/com/netflix/graphql/dgs/codegen/cases/inputWithPrefix/expected/types/DgsQuery.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package com.netflix.graphql.dgs.codegen.cases.inputWithPrefix.expected.types | ||
|
||
import com.fasterxml.jackson.`annotation`.JsonIgnoreProperties | ||
import com.fasterxml.jackson.`annotation`.JsonProperty | ||
import com.fasterxml.jackson.`annotation`.JsonTypeInfo | ||
import com.fasterxml.jackson.databind.`annotation`.JsonDeserialize | ||
import com.fasterxml.jackson.databind.`annotation`.JsonPOJOBuilder | ||
import java.lang.IllegalStateException | ||
import kotlin.String | ||
import kotlin.collections.List | ||
import kotlin.jvm.JvmName | ||
|
||
@JsonTypeInfo(use = JsonTypeInfo.Id.NONE) | ||
@JsonDeserialize(builder = DgsQuery.Builder::class) | ||
public class DgsQuery( | ||
movies: () -> List<String?>? = moviesDefault, | ||
) { | ||
private val __movies: () -> List<String?>? = movies | ||
|
||
@get:JvmName("getMovies") | ||
public val movies: List<String?>? | ||
get() = __movies.invoke() | ||
|
||
public companion object { | ||
private val moviesDefault: () -> List<String?>? = | ||
{ throw IllegalStateException("Field `movies` was not requested") } | ||
} | ||
|
||
@JsonPOJOBuilder | ||
@JsonIgnoreProperties("__typename") | ||
public class Builder { | ||
private var movies: () -> List<String?>? = moviesDefault | ||
|
||
@JsonProperty("movies") | ||
public fun withMovies(movies: List<String?>?): Builder = this.apply { | ||
this.movies = { movies } | ||
} | ||
|
||
public fun build(): DgsQuery = DgsQuery( | ||
movies = movies, | ||
) | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
...src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/inputWithPrefix/schema.graphql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
type Query { | ||
movies(filter: MovieFilter): [String] | ||
} | ||
|
||
input MovieFilter { | ||
genre: String | ||
} |
Oops, something went wrong.