-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add support for default Currnecy value
- Loading branch information
Showing
11 changed files
with
255 additions
and
4 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
14 changes: 14 additions & 0 deletions
14
...tlin/com/netflix/graphql/dgs/codegen/cases/inputWithDefaultCurrency/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.inputWithDefaultCurrency.expected | ||
|
||
import com.netflix.graphql.dgs.client.codegen.InputValueSerializerInterface | ||
import com.netflix.graphql.dgs.codegen.GraphQLProjection | ||
import com.netflix.graphql.dgs.codegen.cases.inputWithDefaultCurrency.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
...n/com/netflix/graphql/dgs/codegen/cases/inputWithDefaultCurrency/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.inputWithDefaultCurrency.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 Orders: String = "orders" | ||
|
||
public object ORDERS_INPUT_ARGUMENT { | ||
public const val Filter: String = "filter" | ||
} | ||
} | ||
|
||
public object ORDERFILTER { | ||
public const val TYPE_NAME: String = "OrderFilter" | ||
|
||
public const val Value: String = "value" | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...lix/graphql/dgs/codegen/cases/inputWithDefaultCurrency/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.inputWithDefaultCurrency.expected.client | ||
|
||
import com.netflix.graphql.dgs.client.codegen.InputValueSerializerInterface | ||
import com.netflix.graphql.dgs.codegen.GraphQLProjection | ||
import com.netflix.graphql.dgs.codegen.cases.inputWithDefaultCurrency.expected.types.OrderFilter | ||
|
||
public class QueryProjection( | ||
inputValueSerializer: InputValueSerializerInterface? = null, | ||
) : GraphQLProjection(inputValueSerializer) { | ||
public fun orders(filter: OrderFilter? = default<QueryProjection, OrderFilter?>("filter")): | ||
QueryProjection { | ||
field("orders", "filter" to filter) | ||
return this | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
.../netflix/graphql/dgs/codegen/cases/inputWithDefaultCurrency/expected/types/OrderFilter.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,18 @@ | ||
package com.netflix.graphql.dgs.codegen.cases.inputWithDefaultCurrency.expected.types | ||
|
||
import com.fasterxml.jackson.`annotation`.JsonCreator | ||
import com.fasterxml.jackson.`annotation`.JsonProperty | ||
import com.netflix.graphql.dgs.codegen.GraphQLInput | ||
import java.util.Currency | ||
import kotlin.Any | ||
import kotlin.Pair | ||
import kotlin.String | ||
import kotlin.collections.List | ||
|
||
public class OrderFilter @JsonCreator constructor( | ||
@JsonProperty("value") | ||
public val `value`: Currency = default<OrderFilter, Currency>("value", | ||
java.util.Currency.getInstance("USD")), | ||
) : GraphQLInput() { | ||
override fun fields(): List<Pair<String, Any?>> = listOf("value" to `value`) | ||
} |
42 changes: 42 additions & 0 deletions
42
...in/com/netflix/graphql/dgs/codegen/cases/inputWithDefaultCurrency/expected/types/Query.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,42 @@ | ||
package com.netflix.graphql.dgs.codegen.cases.inputWithDefaultCurrency.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.jvm.JvmName | ||
|
||
@JsonTypeInfo(use = JsonTypeInfo.Id.NONE) | ||
@JsonDeserialize(builder = Query.Builder::class) | ||
public class Query( | ||
orders: () -> String? = ordersDefault, | ||
) { | ||
private val __orders: () -> String? = orders | ||
|
||
@get:JvmName("getOrders") | ||
public val orders: String? | ||
get() = __orders.invoke() | ||
|
||
public companion object { | ||
private val ordersDefault: () -> String? = | ||
{ throw IllegalStateException("Field `orders` was not requested") } | ||
} | ||
|
||
@JsonPOJOBuilder | ||
@JsonIgnoreProperties("__typename") | ||
public class Builder { | ||
private var orders: () -> String? = ordersDefault | ||
|
||
@JsonProperty("orders") | ||
public fun withOrders(orders: String?): Builder = this.apply { | ||
this.orders = { orders } | ||
} | ||
|
||
public fun build(): Query = Query( | ||
orders = orders, | ||
) | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
...Test/kotlin/com/netflix/graphql/dgs/codegen/cases/inputWithDefaultCurrency/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,9 @@ | ||
scalar Currency | ||
|
||
type Query { | ||
orders(filter: OrderFilter): String | ||
} | ||
|
||
input OrderFilter { | ||
value: Currency! = "USD" | ||
} |
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
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
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
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