Skip to content

Are properties always fetched? #1321

Answered by dariuszkuc
nk-coding asked this question in Q&A
Discussion options

You must be logged in to vote

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

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 Foo without calculating the value of bar (fast) and baz (slow) fields. Regardless whether user asks for slow baz or not, we HAVE to ca…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@nk-coding
Comment options

Answer selected by nk-coding
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants