Skip to content

Defaulting values do not work when using it on child objects #1503

@JustinSchwarzwald

Description

@JustinSchwarzwald

Library Version
graphql-kotlin-spring-server version "6.1.0"
org.springframework.boot version "2.7.2"

Describe the bug
When using a default argument for a child object, the default parameter is given "null" instead of a default value.

To Reproduce
Steps to reproduce the behavior. Please provide:
For a depth of 1

@Component
class DefaultValueQueryDepth1 : Query {
    suspend fun returnTrueIfModelValueDefaults(queryModel: QueryModel?): Boolean {
        return queryModel?.value == "defaultValue"
    }
}
data class QueryModel(val value: String? = "defaultValue")

For a depth of 2

@Component
class DefaultValueQueryDepth2 : Query {
    suspend fun returnTrueIfChildValueDefaults(parentQueryModel: ParentQueryModel): Boolean {
        return parentQueryModel.childQueryModel?.value == "defaultValue"
    }
}
data class ParentQueryModel(val childQueryModel: ChildQueryModel? = ChildQueryModel("defaultValue"))
data class ChildQueryModel(val value: String? = "defaultValue")

image

Please also see the following repo for the bug : https://github.com/JustinSchwarzwald/GraphQLDefaultingValuesBug

Expected behavior
The child object should receive the default value that is specified.

Metadata

Metadata

Assignees

Labels

module: generatorIssue affects the schema generator and federation codetype: bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions