apollo-kotlin

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Apollo Kotlin Guide

Apollo Kotlin 指南

Apollo Kotlin is a strongly typed GraphQL client that generates Kotlin models from your GraphQL operations and schema, that can be used in Android, JVM, and Kotlin Multiplatform projects.
Apollo Kotlin是一款强类型GraphQL客户端,可根据你的GraphQL操作和Schema生成Kotlin模型,适用于Android、JVM和Kotlin多平台(KMP)项目。

Process

流程

Follow this process when adding or working with Apollo Kotlin:
  • Confirm target platforms (Android, JVM, KMP), GraphQL endpoint(s), and how schemas are sourced.
  • Configure Gradle and code generation, including custom scalars
  • Create a shared
    ApolloClient
    with auth, logging, and caching.
  • Implement operations.
  • Validate behavior with tests and error handling.
添加或使用Apollo Kotlin时,请遵循以下流程:
  • 确认目标平台(Android、JVM、KMP)、GraphQL端点以及Schema的获取方式。
  • 配置Gradle和代码生成,包括自定义标量类型
  • 创建带有认证、日志和缓存功能的共享
    ApolloClient
  • 实现操作逻辑。
  • 通过测试和错误处理验证行为。

Reference Files

参考文件

  • Setup - Gradle plugin, schema download, codegen config (including scalars), client configuration (auth, logging, interceptors)
  • Operations - Queries, mutations, subscriptions, and how to execute them
  • Caching - Setup and use the normalized cache
  • Setup - Gradle插件、Schema下载、代码生成配置(包括标量类型)、客户端配置(认证、日志、拦截器)
  • Operations - 查询、变更、订阅,以及如何执行它们
  • Caching - 搭建并使用规范化缓存

Scripts

脚本

  • list-apollo-kotlin-versions.sh - List versions of Apollo Kotlin
  • list-apollo-kotlin-normalized-cache-versions.sh - List versions of the Apollo Kotlin Normalized Cache library
  • list-apollo-kotlin-versions.sh - 列出Apollo Kotlin的版本
  • list-apollo-kotlin-normalized-cache-versions.sh - 列出Apollo Kotlin规范化缓存库的版本

Key Rules

关键规则

  • Use Apollo Kotlin v4+, do not use v3 or older versions.
  • Keep schema and operations in source control to make builds reproducible.
  • 使用Apollo Kotlin v4及以上版本,请勿使用v3或更早版本。
  • 将Schema和操作存入版本控制,确保构建可复现。