graphql-schema

tarafından apollographql

Endüstriyel en iyi uygulamalar rehberi; sezgisel, yüksek performanslı ve sürdürülebilir GraphQL şemaları tasarlamak için. İstemci odaklı tip organizasyonu, açık nullability desenleri ve geriye dönük uyumlu evrim stratejileri dahil olmak üzere temel tasarım ilkelerini kapsar. Tipler, adlandırma kuralları, imleç tabanlı sayfalama, hata modelleme ve güvenlik hususları hakkında referans dokümantasyonu sağlar. Kod örnekleriyle arayüzler, birleşimler, girdi tipleri, mutasyonlar ve ID stratejileri için pratik desenler içerir...

npx skills add https://github.com/apollographql/skills --skill graphql-schema

GraphQL Schema Design Guide

This guide covers best practices for designing GraphQL schemas that are intuitive, performant, and maintainable. Schema design is primarily a server-side concern that directly impacts API usability.

Schema Design Principles

1. Design for Client Needs

  • Think about what queries clients will write
  • Organize types around use cases, not database tables
  • Expose capabilities, not implementation details

2. Be Explicit

  • Use clear, descriptive names
  • Make nullability intentional
  • Document with descriptions

3. Design for Evolution

  • Plan for backwards compatibility
  • Use deprecation before removal
  • Avoid breaking changes
  • Give every new argument or input field a default value, or make it nullable. Existing clients don't send it, so a required field without a default makes their requests fail validation.

Quick Reference

Type Definition Syntax

"""
A user in the system.
"""
type User {
  id: ID!
  email: String!
  name: String
  posts(first: Int = 10, after: String): PostConnection!
  createdAt: DateTime!
}

Nullability Rules

PatternMeaning
StringNullable - may be null
String!Non-null - always has value
[String]Nullable list, nullable items
[String!]Nullable list, non-null items
[String]!Non-null list, nullable items
[String!]!Non-null list, non-null items

Best Practice: Use [Type!]! for lists - empty list over null, no null items.

Input vs Output Types

# Output type - what clients receive
type User {
  id: ID!
  email: String!
  createdAt: DateTime!
}

# Input type - what clients send
input CreateUserInput {
  email: String!
  name: String
}

# Mutation using input type
type Mutation {
  createUser(input: CreateUserInput!): User!
}

Interface Pattern

interface Node {
  id: ID!
}

type User implements Node {
  id: ID!
  email: String!
}

type Post implements Node {
  id: ID!
  title: String!
}

Union Pattern

union SearchResult = User | Post | Comment

type Query {
  search(query: String!): [SearchResult!]!
}

Reference Files

Detailed documentation for specific topics:

  • Types - Type design patterns, interfaces, unions, and custom scalars
  • Naming - Naming conventions for types, fields, and arguments
  • Pagination - Connection pattern and cursor-based pagination
  • Errors - Error modeling and result types
  • Security - Security best practices for schema design

Key Rules

Type Design

  • Define types based on domain concepts, not data storage
  • Use interfaces for shared fields across types
  • Use unions for mutually exclusive types
  • Keep types focused (single responsibility)
  • Avoid deep nesting - flatten when possible

Field Design

  • Fields should be named from client's perspective
  • Return the most specific type possible
  • Make expensive fields explicit (consider arguments)
  • Use arguments for filtering, sorting, pagination

Mutation Design

  • Use single input argument pattern: mutation(input: InputType!)
  • Return affected objects in mutation responses
  • Model mutations around business operations, not CRUD
  • Consider returning a union of success/error types

ID Strategy

  • Use globally unique IDs when possible
  • Implement Node interface for refetchability
  • Base64-encode compound IDs if needed

Ground Rules

  • ALWAYS add descriptions to types and fields
  • ALWAYS use non-null (!) for fields that cannot be null
  • ALWAYS use [Type!]! pattern for lists
  • ALWAYS paginate lists that can grow without limit, such as Query.users or Post.comments: return a connection and give first a default page size
  • NEVER expose database internals in schema
  • NEVER break backwards compatibility without deprecation
  • NEVER add a required argument or input field without a default value
  • PREFER dedicated input types over many arguments
  • PREFER enums over arbitrary strings for fixed values
  • USE ID type for identifiers, not String or Int
  • USE custom scalars for domain-specific values (DateTime, Email, URL)

apollographql tarafından daha fazla skill

apollo-federation
apollographql
Apollo Federation, birden fazla GraphQL API'sini (alt grafikler) birleşik bir süper grafik halinde oluşturmayı sağlar.
apollo-ios
apollographql
We need to translate the given English text into Turkish, preserving the name "apollo-ios" and technical terms like GraphQL, Swift, async/await, SQLite, HTTP, WebSocket, graphql-transport-ws. The instruction says to translate only the text inside <text>, and not include the name unless it appears in the source text. The name "apollo-ios" does not appear in the source text; the source says "Apollo iOS" (with a space). The instruction says "Name to preserve: apollo-ios" but the source has "Apollo iOS". We should preserve the exact name as given? The instruction says "preserve product names" and the name to preserve is "apollo-ios". However, the source text uses "Apollo iOS". I think we should keep "Apollo iOS" as is because that's the product name in the source. But the instruction says "Name to preserve: apollo-ios" - that might be a key. To be safe, I'll keep "Apollo iOS
apollo-router
apollographql
Apollo Router, Apollo Federation 2 süper grafiklerini çalıştırmak için Rust dilinde yazılmış yüksek performanslı bir grafik yönlendiricisidir. Alt grafiklerinizin önünde yer alır ve sorgu planlaması, yürütme ve yanıt birleştirme işlemlerini yönetir.
apollo-router-plugin-creator
apollographql
Apollo Router için yerel Rust eklentileri oluşturun.
apollo-server
apollographql
Apollo Server 5.x ile çeşitli framework'lerde GraphQL sunucuları oluşturmak için kapsamlı rehber. Şema tanımı, çözücüler, bağlam kurulumu ve TypeScript desteğiyle hata yönetimini kapsar. Prototipleme için bağımsız modu ve Express, Fastify, Koa ile sunucusuz ortamlar için entegrasyonları destekler. Çözücü desenleri, kimlik doğrulama/yetkilendirme, eklentiler, N+1 önleme için DataLoader ve performans optimizasyon tekniklerini içerir. Veri kaynakları, hata... için referans dokümantasyon sağlar.
graphql-operations
apollographql
Verimli, tür güvenli GraphQL işlemleri yazmak ve bunları fragmentlerle organize etmek için en iyi uygulamalar kılavuzu. Sorgular, mutasyonlar, abonelikler ve fragmentleri; adlandırma kuralları, değişken sözdizimi ve yönerge kullanımıyla kapsar. Temel ilkeleri vurgular: yalnızca gerekli alanları isteyin, tüm işlemleri adlandırın, sabit kodlanmış değerler yerine değişkenler kullanın ve önbelleğe alınabilirlik için id alanlarını ekleyin. Fragmentlerin bileşenlerle birlikte konumlandırılmasını ve koşullu alanlar için @include / @skip yönergelerinin kullanılmasını önerir...
rover
apollographql
Apollo Rover CLI, GraphQL şemalarını, federasyonu ve yerel süpergraf geliştirmeyi yönetmek içindir. Alt grafik şemalarını yayımlayın, alın ve doğrulayın; federasyonlu süper grafikleri yerel olarak veya GraphOS aracılığıyla oluşturun. Çalışan sunuculardan şema denetimi (dağıtım öncesi doğrulama), linting ve içe bakış içerir. rover dev komutu, geliştirme iş akışları için otomatik şema oluşturma ile yerel bir Yönlendirici başlatır. Yayımlamadan önce doğrulama ve komut dosyası oluşturma için JSON çıktısı ile CI/CD desenlerini destekler. Gerektirir...
rust-best-practices
apollographql
Apollo GraphQL'in en iyi uygulamalar el kitabına dayalı, doğal Rust kodlama standartları. Dokuz temel alanı kapsar: kodlama stilleri ve deyimler, clippy linting, performans optimizasyonu, hata yönetimi, test desenleri, generics ve dispatch, tip durumu deseni, dokümantasyon ve işaretçi güvenliği. Kopyalama yerine ödünç almayı, thiserror/anyhow ile Result tabanlı hata yönetimini ve release build'lerle performans profillemesini vurgular. Sahiplik desenleri, panic'ten kaçınma konularında hızlı başvuru rehberliği içerir,...