question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Defaulting values do not work when using it on child objects

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
samuelAndaloncommented, Aug 15, 2022

@cryptoki We will release a minor version in the following days.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Set default value on children records when `New` is clicked on ...
A default value will not work in this case, because default values can't access values on a parent record. They are set at...
Read more >
Defaulting in values from a parent ... - Salesforce Developers
It seems that newly created child objects do not have access to parent object values. This is absolutely essential.
Read more >
defaults() leaves child objects null · Issue #28344 - GitHub
I understand this is by design: Terraform will recursively visit all of the attributes or elements of the nested value and repeat the...
Read more >
Python: Child Inheriting Parents Default Values If Not Specified
So I'm either having issues with my inheritance (I'm really struggling with Super), or the signatures of my objects, and I'm not quite...
Read more >
Inheritance and the prototype chain - JavaScript | MDN
It should not be confused with the func.prototype property of functions, which instead ... The child object now looks like: // { value:...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found