https://kotlinlang.org logo
Title
j

Jeremie

11/04/2021, 2:23 PM
Using fragments: is there a way to put the fragment at the root at the object?
//graphql 
query myQuery {
    rootObject {
        ...On RootObjectA {
           ... myFragment
       }
    }
}

fragment myFragment on RootObjectA {
   id
   name
}
//Kotlin object gets structured like this:

rootObject.fragments.myFragment.id
// What Id like to see:

rootObject.id.  // or rootObject.fragments.id if `fragments` are required because of the casting from the ON function
m

mbonnin

11/04/2021, 2:24 PM
You can look into
codegenModels.set("responseBased")
(you'll have to use 3.x for this)
😮 1
👀 1
j

Jeremie

11/04/2021, 2:33 PM
already am using 3. 😄
🎉 1
🥳 2
sorry, but if someone can help me set it...im probably doing something dumb...
apollo {
    packageName.set("<http://com.mycompany.app|com.mycompany.app>")
  generateKotlinModels.set(true)   codegenModels.set(MODELS_RESPONSE_BASED)

}
> Could not get unknown property 'MODELS_RESPONSE_BASED' for extension 'apollo' of type com.apollographql.apollo3.gradle.internal.DefaultApolloExtension.
maybe ill try updating to beta02 im on alpha 07 rn
1
m

mbonnin

11/04/2021, 2:48 PM
You'll most likely need to import
MODELS_RESPONSE_BASED
Just hardcode the value, it'll be easier:
codegenModels.set("responseBased")
(I just updated the doc)
j

Jeremie

11/04/2021, 2:50 PM
thanks!
m

mbonnin

11/04/2021, 2:50 PM
Updating to beta02 is a good idea although it shouldn't change that specific issue
j

Jeremie

11/04/2021, 2:50 PM
yeah i just did it i didnt realized you guys are moving so fast!! 😄 good work over there
ill start checking for releases weekly.
👍 1
ps: it works and its amazing ❤️ ❤️ thanks for the good work and thanks for the support
❤️ 1