-
Notifications
You must be signed in to change notification settings - Fork 99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for default Currency value #742
Open
dwilkolek
wants to merge
1
commit into
Netflix:master
Choose a base branch
from
dwilkolek:fix/734
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice add! ⭐