All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.lahzouz.apollo.graphql.client.adapter.GetBooksQuery_ResponseAdapter.kt Maven / Gradle / Ivy

//
// AUTO-GENERATED FILE. DO NOT MODIFY.
//
// This class was automatically generated by Apollo GraphQL version '3.0.0'.
//
package com.lahzouz.apollo.graphql.client.adapter

import com.apollographql.apollo3.api.Adapter
import com.apollographql.apollo3.api.CustomScalarAdapters
import com.apollographql.apollo3.api.StringAdapter
import com.apollographql.apollo3.api.json.JsonReader
import com.apollographql.apollo3.api.json.JsonWriter
import com.apollographql.apollo3.api.list
import com.apollographql.apollo3.api.obj
import com.lahzouz.apollo.graphql.client.GetBooksQuery
import java.lang.Long
import kotlin.String
import kotlin.Unit
import kotlin.collections.List

public object GetBooksQuery_ResponseAdapter {
  public object Data : Adapter {
    public val RESPONSE_NAMES: List = listOf("books")

    public override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters):
        GetBooksQuery.Data {
      var books: List? = null

      while(true) {
        when (reader.selectName(RESPONSE_NAMES)) {
          0 -> books = Book.obj().list().fromJson(reader, customScalarAdapters)
          else -> break
        }
      }

      return GetBooksQuery.Data(
        books = books!!
      )
    }

    public override fun toJson(
      writer: JsonWriter,
      customScalarAdapters: CustomScalarAdapters,
      `value`: GetBooksQuery.Data
    ): Unit {
      writer.name("books")
      Book.obj().list().toJson(writer, customScalarAdapters, value.books)
    }
  }

  public object Book : Adapter {
    public val RESPONSE_NAMES: List = listOf("id", "title", "author")

    public override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters):
        GetBooksQuery.Book {
      var id: Long? = null
      var title: String? = null
      var author: GetBooksQuery.Author? = null

      while(true) {
        when (reader.selectName(RESPONSE_NAMES)) {
          0 -> id = customScalarAdapters.responseAdapterFor(com.lahzouz.apollo.graphql.client.type.Long.type).fromJson(reader,
              customScalarAdapters)
          1 -> title = StringAdapter.fromJson(reader, customScalarAdapters)
          2 -> author = Author.obj().fromJson(reader, customScalarAdapters)
          else -> break
        }
      }

      return GetBooksQuery.Book(
        id = id!!,
        title = title!!,
        author = author!!
      )
    }

    public override fun toJson(
      writer: JsonWriter,
      customScalarAdapters: CustomScalarAdapters,
      `value`: GetBooksQuery.Book
    ): Unit {
      writer.name("id")
      customScalarAdapters.responseAdapterFor(com.lahzouz.apollo.graphql.client.type.Long.type).toJson(writer,
          customScalarAdapters, value.id)

      writer.name("title")
      StringAdapter.toJson(writer, customScalarAdapters, value.title)

      writer.name("author")
      Author.obj().toJson(writer, customScalarAdapters, value.author)
    }
  }

  public object Author : Adapter {
    public val RESPONSE_NAMES: List = listOf("name")

    public override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters):
        GetBooksQuery.Author {
      var name: String? = null

      while(true) {
        when (reader.selectName(RESPONSE_NAMES)) {
          0 -> name = StringAdapter.fromJson(reader, customScalarAdapters)
          else -> break
        }
      }

      return GetBooksQuery.Author(
        name = name!!
      )
    }

    public override fun toJson(
      writer: JsonWriter,
      customScalarAdapters: CustomScalarAdapters,
      `value`: GetBooksQuery.Author
    ): Unit {
      writer.name("name")
      StringAdapter.toJson(writer, customScalarAdapters, value.name)
    }
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy