Skip to content

Commit a6d1102

Browse files
committed
JvmOverloads constructor to support missing directives arg
1 parent 3ae94cd commit a6d1102

1 file changed

Lines changed: 22 additions & 15 deletions

File tree

graphql-dgs-codegen-shared-core/src/main/kotlin/com/netflix/graphql/dgs/client/codegen/GraphQLQueryRequest.kt

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -55,25 +55,30 @@ class GraphQLQueryRequest
5555
this.selectionSet = selectionSet
5656
}
5757

58-
class GraphQLQueryRequestOptions(
59-
val scalars: Map<Class<*>, Coercing<*, *>> = emptyMap(),
60-
val graphQLContext: GraphQLContext = GraphQLContext.getDefault(),
61-
/**
62-
* Directives to attach to the top-level selection field (the root query, mutation,
63-
* or subscription field). Only valid for directives declared `on FIELD` in the schema.
64-
*/
65-
val operationFieldDirectives: List<Directive> = emptyList(),
66-
) {
67-
// When enabled, input values that are derived from properties
68-
// whose values are null will be serialized in the query request
69-
var allowNullablePropertyInputValues = false
70-
}
58+
class GraphQLQueryRequestOptions
59+
@JvmOverloads
60+
constructor(
61+
val scalars: Map<Class<*>, Coercing<*, *>> = emptyMap(),
62+
val graphQLContext: GraphQLContext = GraphQLContext.getDefault(),
63+
/**
64+
* Directives to attach to the top-level selection field (the field invoked on the root query,
65+
* mutation, or subscription field). Only valid for directives declared `on FIELD` in the schema.
66+
*/
67+
val operationFieldDirectives: List<Directive> = emptyList(),
68+
) {
69+
// When enabled, input values that are derived from properties
70+
// whose values are null will be serialized in the query request
71+
var allowNullablePropertyInputValues = false
72+
}
7173

7274
val inputValueSerializer =
7375
if (options?.allowNullablePropertyInputValues == true) {
7476
NullableInputValueSerializer(options.scalars)
7577
} else {
76-
InputValueSerializer(options?.scalars ?: emptyMap(), options?.graphQLContext ?: GraphQLContext.getDefault())
78+
InputValueSerializer(
79+
options?.scalars ?: emptyMap(),
80+
options?.graphQLContext ?: GraphQLContext.getDefault(),
81+
)
7782
}
7883

7984
val projectionSerializer = ProjectionSerializer(inputValueSerializer, query)
@@ -86,7 +91,9 @@ class GraphQLQueryRequest
8691
val operationDef = OperationDefinition.newOperationDefinition()
8792

8893
query.name?.let { operationDef.name(it) }
89-
query.getOperationType()?.let { operationDef.operation(OperationDefinition.Operation.valueOf(it.uppercase())) }
94+
query
95+
.getOperationType()
96+
?.let { operationDef.operation(OperationDefinition.Operation.valueOf(it.uppercase())) }
9097

9198
val selection = Field.newField(query.getOperationName())
9299
if (query.input.isNotEmpty()) {

0 commit comments

Comments
 (0)