GraphQL Flashcards

πŸ”Ί GraphQL Flashcards

Query language & runtime for APIs β€” fetch exactly what you need

πŸ’‘ What is GraphQL?

A query language for APIs and a server-side runtime to fulfill queries using your existing data.

πŸ“ Schema

Defines types and relationships: type, interface, union, enum, input, and scalar.

πŸ” Queries

Read operations that specify the exact fields needed. Supports arguments, aliases, and fragments.

✏️ Mutations

Write operations to create/update/delete data. Can return updated objects with requested fields.

πŸ“‘ Subscriptions

Real-time updates over WebSockets. Server pushes events to subscribed clients.

🧩 Resolvers

Functions that resolve a field’s value. Can call DBs, REST services, or other APIs.

🧱 Scalars & Custom Scalars

Built-ins: Int, Float, String, Boolean, ID. Add custom types like DateTime.

🧬 Fragments

Reusable field selections to reduce duplication across queries and mutations.

πŸ—ΊοΈ SDL (Schema Definition Language)

Human-readable syntax to define types and operations, e.g., type Query { me: User }.

πŸ›‘οΈ Validation & Types

Queries validated against schema before execution; strong typing enables safe evolution of APIs.

πŸš€ Tooling

Apollo, GraphQL Yoga, Mercurius, graphql-js, Relay, Hasura, URQL, GraphiQL/Playground.

🧭 Best Practices

Pagination (cursor-based), batching & caching, data loaders, auth at resolver level, error masking, persisted queries.