I have some queries that return a lot of nested fi...
# apollo-kotlin
n
I have some queries that return a lot of nested fields. I have to access some of them by going through about 5 different other fields. Is there anyway to shorten how i’d access the brand in the generated kotlin code? I don’t want to do hero.friends.person.home.kitchen.stove.brand every time I need the brand.
Copy code
{
  hero {
    friends {
      person {
          home {
            kitchen {
                stove {
                    brand
                }
            }  
          }
      }
    }
  }
}
m
Not really. There have been some thoughts about implementing something like lodash for Kotlin but you can have the same results with an extension function so it was never prioritized:
Copy code
val Hero.Data.stoveBrand 
  get() = data?.friends?.person?.home?.kitchen?.stove?.brand
1
👌 2
👍 1
n
oh that’s awesome
I think being able to just preview that query through an introspection is really helpful