πΊ 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.