Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save BenSchwab/03d3afdbac7e6065cd048cdddabf1c6d to your computer and use it in GitHub Desktop.
Save BenSchwab/03d3afdbac7e6065cd048cdddabf1c6d to your computer and use it in GitHub Desktop.
// ktlint-disable
// This file was autogenerated, do not modify.
package com.airbnb.android.test.niobecodegen
import com.airbnb.android.base.airdate.AirDate
import com.airbnb.android.base.airdate.AirDateTime
import com.airbnb.android.base.apiv3.GlobalID
import com.airbnb.android.lib.apiv3.fragmentCopyCast
import com.airbnb.android.lib.apiv3.NiobeOperation
import com.airbnb.android.lib.apiv3.scalar.CustomType
import com.apollographql.apollo.api.CustomTypeValue.GraphQLJsonObject
import com.apollographql.apollo.api.Input
import com.apollographql.apollo.api.InputType
import com.apollographql.apollo.api.Mutation
import com.apollographql.apollo.api.Operation
import com.apollographql.apollo.api.OperationName
import com.apollographql.apollo.api.Query
import com.apollographql.apollo.api.Response
import com.apollographql.apollo.api.ResponseField
import com.apollographql.apollo.api.ScalarTypeAdapters
import com.apollographql.apollo.api.ScalarTypeAdapters.Companion.DEFAULT
import com.apollographql.apollo.api.internal.InputFieldMarshaller
import com.apollographql.apollo.api.internal.InputFieldWriter
import com.apollographql.apollo.api.internal.OperationRequestBodyComposer
import com.apollographql.apollo.api.internal.QueryDocumentMinifier
import com.apollographql.apollo.api.internal.ResponseFieldMapper
import com.apollographql.apollo.api.internal.ResponseFieldMarshaller
import com.apollographql.apollo.api.internal.ResponseReader
import com.apollographql.apollo.api.internal.SimpleOperationResponseParser
import kotlin.Any
import kotlin.Array
import kotlin.Long
import kotlin.String
import kotlin.Suppress
import kotlin.collections.List
import kotlin.collections.Map
import kotlin.jvm.Throws
import kotlin.jvm.Transient
import okio.Buffer
import okio.BufferedSource
import okio.ByteString
import okio.IOException
@Suppress(
"NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName",
"RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter", "ObjectPropertyNaming"
)
class NestedAbstractVaryingSelectionQuery : Query<NestedAbstractVaryingSelectionQuery.Data, NestedAbstractVaryingSelectionQuery.Data, Operation.Variables>, NiobeOperation {
override fun operationId(): String = OPERATION_ID
override fun queryDocument(): String = QUERY_DOCUMENT
override fun wrapData(data: Data?): Data? = data
override fun variables(): Operation.Variables = Operation.EMPTY_VARIABLES
override fun name(): OperationName = OPERATION_NAME
override fun responseFieldMapper(): ResponseFieldMapper<Data> = ResponseFieldMapper {
Data(it)
}
@Throws(IOException::class)
override fun parse(source: BufferedSource, scalarTypeAdapters: ScalarTypeAdapters): Response<Data> = SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters)
@Throws(IOException::class)
override fun parse(byteString: ByteString, scalarTypeAdapters: ScalarTypeAdapters): Response<Data> = parse(Buffer().write(byteString), scalarTypeAdapters)
@Throws(IOException::class)
override fun parse(source: BufferedSource): Response<Data> = parse(source, DEFAULT)
@Throws(IOException::class)
override fun parse(byteString: ByteString): Response<Data> = parse(byteString, DEFAULT)
override fun composeRequestBody(scalarTypeAdapters: ScalarTypeAdapters): ByteString =
OperationRequestBodyComposer.compose(
operation = this,
autoPersistQueries = false,
withQueryDocument = true,
scalarTypeAdapters = scalarTypeAdapters
)
override fun composeRequestBody(): ByteString = OperationRequestBodyComposer.compose(
operation = this,
autoPersistQueries = false,
withQueryDocument = true,
scalarTypeAdapters = DEFAULT
)
override fun composeRequestBody(
autoPersistQueries: Boolean,
withQueryDocument: Boolean,
scalarTypeAdapters: ScalarTypeAdapters
): ByteString = OperationRequestBodyComposer.compose(
operation = this,
autoPersistQueries = autoPersistQueries,
withQueryDocument = withQueryDocument,
scalarTypeAdapters = scalarTypeAdapters
)
data class Data(
val luke: Luke
) : Operation.Data {
override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller { writer ->
writer.writeObject(RESPONSE_FIELDS[0], this@Data.luke.marshaller())
}
companion object {
private val RESPONSE_FIELDS: Array<ResponseField> = arrayOf(
ResponseField.forObject("luke", "luke", null, false, null)
)
operator fun invoke(reader: ResponseReader): Data = reader.run {
val luke = readObject<Luke>(RESPONSE_FIELDS[0]) { reader -> Luke(reader) }!!
Data(
luke = luke
)
}
}
data class Luke(
val __typename: String = "Human",
val possessions: List<Possession>
) {
fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller { writer ->
writer.writeString(RESPONSE_FIELDS[0], this@Luke.__typename)
writer.writeList(RESPONSE_FIELDS[1], this@Luke.possessions) { value, listItemWriter ->
value?.forEach { value -> listItemWriter.writeObject(value.marshaller()) }
}
}
companion object {
private val RESPONSE_FIELDS: Array<ResponseField> = arrayOf(
ResponseField.forString("__typename", "__typename", null, false, null),
ResponseField.forList("possessions", "possessions", null, false, null)
)
operator fun invoke(reader: ResponseReader): Luke = reader.run {
val __typename = readString(RESPONSE_FIELDS[0])!!
val possessions = readList<Possession>(RESPONSE_FIELDS[1]) { reader -> reader.readObject<Possession> { reader -> Possession(reader) } }!!.map { it!! }
Luke(
__typename = __typename,
possessions = possessions
)
}
}
interface Possession {
val asAbstractDroid: NestedAbstractVaryingSelectionQuery.Data.Luke.Possession.AbstractDroid?
get() = this as? NestedAbstractVaryingSelectionQuery.Data.Luke.Possession.AbstractDroid
fun marshaller(): ResponseFieldMarshaller
companion object {
private val RESPONSE_FIELDS: Array<ResponseField> = arrayOf(
ResponseField.forString("__typename", "__typename", null, false, null),
ResponseField.forFragment(
"__typename", "__typename", listOf(
ResponseField.Condition.typeCondition(arrayOf("Ship"))
)
),
ResponseField.forFragment(
"__typename", "__typename", listOf(
ResponseField.Condition.typeCondition(arrayOf("Droid", "KnockOffDroid"))
)
)
)
operator fun invoke(reader: ResponseReader): Possession = reader.run {
when (readString(RESPONSE_FIELDS[0])) {
"Droid", "KnockOffDroid" -> readFragment<OtherAbstractDroidImpl>(RESPONSE_FIELDS[2]) { reader ->
OtherAbstractDroidImpl(reader)
}!!
else -> readFragment<OtherThingImpl>(RESPONSE_FIELDS[1]) { reader ->
OtherThingImpl(reader)
}!!
}
}
}
interface AbstractDroid: NestedAbstractVaryingSelectionQuery.Data.Luke.Possession {
val owner: Owner?
interface Owner {
interface AbstractWookie: NestedAbstractVaryingSelectionQuery.Data.Luke.Possession.AbstractDroid.Owner {
val hairLength: Double?
fun copyFragment(
hairLength: Double? = this.hairLength
): AbstractWookie
}
interface Human: NestedAbstractVaryingSelectionQuery.Data.Luke.Possession.AbstractDroid.Owner {
val name: String
fun copyFragment(
name: String = this.name
): Human
}
fun marshaller(): ResponseFieldMarshaller
}
fun copyFragment(
owner: NestedAbstractVaryingSelectionQuery.Data.Luke.Possession.AbstractDroid.Owner? = this.owner
): AbstractDroid
}
private data class OtherAbstractDroidImpl(
val __typename: String,
override val owner: Owner?
) : NestedAbstractVaryingSelectionQuery.Data.Luke.Possession.AbstractDroid {
override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller { writer ->
writer.writeString(RESPONSE_FIELDS[0], this@OtherAbstractDroidImpl.__typename)
writer.writeObject(RESPONSE_FIELDS[1], this@OtherAbstractDroidImpl.owner?.marshaller())
}
companion object {
private val RESPONSE_FIELDS: Array<ResponseField> = arrayOf(
ResponseField.forString("__typename", "__typename", null, false, null),
ResponseField.forObject("owner", "owner", null, true, null)
)
operator fun invoke(reader: ResponseReader): OtherAbstractDroidImpl = reader.run {
val __typename = readString(RESPONSE_FIELDS[0])!!
val owner = readObject<Owner>(RESPONSE_FIELDS[1]) { reader -> Owner(reader) }
OtherAbstractDroidImpl(
__typename = __typename,
owner = owner
)
}
}
override fun copyFragment(
owner: NestedAbstractVaryingSelectionQuery.Data.Luke.Possession.AbstractDroid.Owner?
) = copy(
owner = owner.fragmentCopyCast<NestedAbstractVaryingSelectionQuery.Data.Luke.Possession.OtherAbstractDroidImpl.Owner?>(this.owner)
)
interface Owner : NestedAbstractVaryingSelectionQuery.Data.Luke.Possession.AbstractDroid.Owner {
val asHuman: NestedAbstractVaryingSelectionQuery.Data.Luke.Possession.AbstractDroid.Owner.Human?
get() = this as? NestedAbstractVaryingSelectionQuery.Data.Luke.Possession.AbstractDroid.Owner.Human
val asAbstractWookie: NestedAbstractVaryingSelectionQuery.Data.Luke.Possession.OtherAbstractDroidImpl.Owner.AbstractWookie?
get() = this as? NestedAbstractVaryingSelectionQuery.Data.Luke.Possession.OtherAbstractDroidImpl.Owner.AbstractWookie
companion object {
private val RESPONSE_FIELDS: Array<ResponseField> = arrayOf(
ResponseField.forString("__typename", "__typename", null, false, null),
ResponseField.forFragment(
"__typename", "__typename", listOf(
ResponseField.Condition.typeCondition(arrayOf())
)
),
ResponseField.forFragment(
"__typename", "__typename", listOf(
ResponseField.Condition.typeCondition(arrayOf("Human"))
)
),
ResponseField.forFragment(
"__typename", "__typename", listOf(
ResponseField.Condition.typeCondition(arrayOf("Wookie"))
)
)
)
operator fun invoke(reader: ResponseReader): Owner = reader.run {
when (readString(RESPONSE_FIELDS[0])) {
"Human" -> readFragment<OtherHumanImpl>(RESPONSE_FIELDS[2]) { reader ->
OtherHumanImpl(reader)
}!!
"Wookie" -> readFragment<OtherAbstractWookieImpl>(RESPONSE_FIELDS[3]) { reader ->
OtherAbstractWookieImpl(reader)
}!!
else -> readFragment<OtherBeingImpl>(RESPONSE_FIELDS[1]) { reader ->
OtherBeingImpl(reader)
}!!
}
}
}
interface Human: NestedAbstractVaryingSelectionQuery.Data.Luke.Possession.AbstractDroid.Owner {
val name: String
fun copyFragment(
name: String = this.name
): Human
}
private data class OtherHumanImpl(
val __typename: String,
override val name: String
) : NestedAbstractVaryingSelectionQuery.Data.Luke.Possession.AbstractDroid.Owner.Human, NestedAbstractVaryingSelectionQuery.Data.Luke.Possession.OtherAbstractDroidImpl.Owner {
override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller { writer ->
writer.writeString(RESPONSE_FIELDS[0], this@OtherHumanImpl.__typename)
writer.writeString(RESPONSE_FIELDS[1], this@OtherHumanImpl.name)
}
companion object {
private val RESPONSE_FIELDS: Array<ResponseField> = arrayOf(
ResponseField.forString("__typename", "__typename", null, false, null),
ResponseField.forString("name", "name", null, false, null)
)
operator fun invoke(reader: ResponseReader): OtherHumanImpl = reader.run {
val __typename = readString(RESPONSE_FIELDS[0])!!
val name = readString(RESPONSE_FIELDS[1])!!
OtherHumanImpl(
__typename = __typename,
name = name
)
}
}
override fun copyFragment(
name: String
) = copy(
name = name
)
}
interface AbstractWookie: NestedAbstractVaryingSelectionQuery.Data.Luke.Possession.AbstractDroid.Owner.AbstractWookie, NestedAbstractVaryingSelectionQuery.Data.Luke.Possession.OtherAbstractDroidImpl.Owner {
}
private data class OtherAbstractWookieImpl(
val __typename: String,
override val hairLength: Double?
) : NestedAbstractVaryingSelectionQuery.Data.Luke.Possession.OtherAbstractDroidImpl.Owner.AbstractWookie {
override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller { writer ->
writer.writeString(RESPONSE_FIELDS[0], this@OtherAbstractWookieImpl.__typename)
writer.writeDouble(RESPONSE_FIELDS[1], this@OtherAbstractWookieImpl.hairLength)
}
companion object {
private val RESPONSE_FIELDS: Array<ResponseField> = arrayOf(
ResponseField.forString("__typename", "__typename", null, false, null),
ResponseField.forDouble("hairLength", "hairLength", null, true, null)
)
operator fun invoke(reader: ResponseReader): OtherAbstractWookieImpl = reader.run {
val __typename = readString(RESPONSE_FIELDS[0])!!
val hairLength = readDouble(RESPONSE_FIELDS[1])
OtherAbstractWookieImpl(
__typename = __typename,
hairLength = hairLength
)
}
}
override fun copyFragment(
hairLength: Double?
) = copy(
hairLength = hairLength
)
}
private data class OtherBeingImpl(
val __typename: String
) : NestedAbstractVaryingSelectionQuery.Data.Luke.Possession.OtherAbstractDroidImpl.Owner {
override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller { writer ->
writer.writeString(RESPONSE_FIELDS[0], this@OtherBeingImpl.__typename)
}
companion object {
private val RESPONSE_FIELDS: Array<ResponseField> = arrayOf(
ResponseField.forString("__typename", "__typename", null, false, null)
)
operator fun invoke(reader: ResponseReader): OtherBeingImpl = reader.run {
val __typename = readString(RESPONSE_FIELDS[0])!!
OtherBeingImpl(
__typename = __typename
)
}
}
}
}
}
private data class OtherThingImpl(
val __typename: String
) : NestedAbstractVaryingSelectionQuery.Data.Luke.Possession {
override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller { writer ->
writer.writeString(RESPONSE_FIELDS[0], this@OtherThingImpl.__typename)
}
companion object {
private val RESPONSE_FIELDS: Array<ResponseField> = arrayOf(
ResponseField.forString("__typename", "__typename", null, false, null)
)
operator fun invoke(reader: ResponseReader): OtherThingImpl = reader.run {
val __typename = readString(RESPONSE_FIELDS[0])!!
OtherThingImpl(
__typename = __typename
)
}
}
}
}
}
}
companion object {
const val OPERATION_ID: String =
"28575bfd84434a4becbe1dcedf2c208770f32686337f3f4c3789cfc9e350ade5"
val QUERY_DOCUMENT: String = QueryDocumentMinifier.minify(
"""
query nestedAbstractVaryingSelection {
luke {
__typename
possessions {
__typename
... on AbstractDroid {
owner {
__typename
... on AbstractWookie {
hairLength
}
... on Human {
name
}
}
}
}
}
}
""".trimMargin()
)
val OPERATION_NAME: OperationName = object : OperationName {
override fun name(): String = "nestedAbstractVaryingSelection"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment