Are properties always fetched? #1321
-
Hi,
However, when I added a breakpoint to a property getter, the program only ran in the breakpoint, if the query asked for that field.
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hello 👋 Documentation simply states that field has to be somehow initialized, i.e. given schema type Foo {
# this field is quickly resolved in milliseconds
bar: String!
# this field is backed by slow API and it takes 10 second to compute
baz: Int!
} If you simply expose that type as a data class Foo(val bar: String, val baz: Int) then it is not possible to create an instance of class class Foo(val bar: String) {
fun baz(): Int {
// some
// this code only executes if query asks for baz
}
} |
Beta Was this translation helpful? Give feedback.
Hello 👋
Yes data fetchers for corresponding fields (regardless whether they are backed by a function or a property) will only be called if given query explicitly asks for it.
Documentation simply states that field has to be somehow initialized, i.e. given schema
If you simply expose that type as a
then it is not possible to create an instance of class
Foo
without calculating the value ofbar
(fast) andbaz
(slow) fields. Regardless whether user asks for slowbaz
or not, we HAVE to ca…