📖 Guide

GraphQL Reference

Complete GraphQL reference — schema definition, types, queries, mutations, directives, fragments, and common patterns.

69 commands across 11 categories

Schema Definition

CommandDescription
type Query { users: [User!]! user(id: ID!): User }
Define root Query type — entry point for reads
type Mutation { createUser(input: CreateUserInput!): User! deleteUser(id: ID!): Boolean! }
Define root Mutation type — entry point for writes
type Subscription { messageAdded(channelId: ID!): Message! }
Define root Subscription type — real-time data
schema { query: Query mutation: Mutation subscription: Subscription }
Explicit schema definition (optional, auto-inferred from type names)
"""User account in the system""" type User { ... }
Schema documentation using description strings
# Comment type User { ... }
Code comments (not included in introspection)

Scalar Types

CommandDescription
String
UTF-8 character sequence
Int
Signed 32-bit integer
Float
Signed double-precision floating-point value
Boolean
true or false
ID
Unique identifier — serialized as String
scalar DateTime
Custom scalar type declaration
scalar JSON
Custom scalar for arbitrary JSON data
scalar URL
Custom scalar for URL validation

Object Types

CommandDescription
type User { id: ID! name: String! email: String! age: Int posts: [Post!]! }
Object type with required (!) and optional fields
String!
Non-null — field can never return null
[String]
Nullable list of nullable strings
[String!]!
Non-null list of non-null strings (most common for lists)
[String!]
Nullable list of non-null strings
type Post { id: ID! title: String! author: User! comments(first: Int = 10): [Comment!]! }
Field with arguments and default value
type Query { users(limit: Int, offset: Int, sort: SortOrder): [User!]! }
Query with multiple optional arguments

Input Types

CommandDescription
input CreateUserInput { name: String! email: String! age: Int }
Input type for mutation arguments
input UpdateUserInput { name: String email: String age: Int }
Input type with all optional fields (partial update)
input PaginationInput { page: Int! = 1 perPage: Int! = 20 }
Input type with default values
input FilterInput { field: String! operator: FilterOperator! value: String! }
Input type for dynamic filtering
mutation { createUser(input: CreateUserInput!) { id name } }
Using an input type in a mutation

Enums

CommandDescription
enum Role { ADMIN USER MODERATOR }
Enum type — restricted set of values
enum SortOrder { ASC DESC }
Enum for sort direction
enum Status { DRAFT PUBLISHED ARCHIVED }
Enum for content status
type User { role: Role! }
Using an enum as a field type
query { users(sort: ASC) { name } }
Passing enum value in a query

Interfaces & Unions

CommandDescription
interface Node { id: ID! } type User implements Node { id: ID! name: String! }
Interface — shared fields across types
interface Timestamped { createdAt: DateTime! updatedAt: DateTime! } type Post implements Node & Timestamped { id: ID! createdAt: DateTime! updatedAt: DateTime! title: String! }
Implementing multiple interfaces
union SearchResult = User | Post | Comment
Union type — value can be one of several types
query { search(query: "hello") { ... on User { name } ... on Post { title } ... on Comment { body } } }
Querying a union type with inline fragments
query { node(id: "123") { __typename ... on User { name } ... on Post { title } } }
Use __typename to identify the concrete type
union Timeline = Post | Photo | Video | Link
Union for a feed/timeline of mixed content

Directives

CommandDescription
@deprecated(reason: "Use newField instead")
Mark a field as deprecated
query ($withDetails: Boolean!) { user { name email @include(if: $withDetails) } }
@include — conditionally include a field
query ($minimal: Boolean!) { user { name bio @skip(if: $minimal) } }
@skip — conditionally skip a field
@specifiedBy(url: "https://tools.ietf.org/html/rfc3339")
Link scalar to its specification
directive @auth(requires: Role!) on FIELD_DEFINITION
Custom directive definition
type Mutation { deleteUser(id: ID!): Boolean! @auth(requires: ADMIN) }
Using a custom directive on a field
directive @cacheControl(maxAge: Int!) on FIELD_DEFINITION | OBJECT
Custom directive on multiple locations

Variables

CommandDescription
query GetUser($id: ID!) { user(id: $id) { name email } }
Query with a required variable
query GetUsers($limit: Int = 10, $offset: Int = 0) { users(limit: $limit, offset: $offset) { name } }
Variables with default values
mutation CreateUser($input: CreateUserInput!) { createUser(input: $input) { id name } }
Mutation with input variable
{ "id": "123", "input": { "name": "Alice", "email": "alice@example.com" } }
Variable values JSON (sent alongside query)
query ($ids: [ID!]!) { users(ids: $ids) { name } }
List variable type

Fragments

CommandDescription
fragment UserFields on User { id name email avatar }
Named fragment — reusable field selection
query { user(id: "1") { ...UserFields } admin: user(id: "2") { ...UserFields } }
Using a fragment with spread syntax
query { search(query: "hello") { ... on User { name email } ... on Post { title body } } }
Inline fragments — type-specific fields without named fragment
fragment PostWithAuthor on Post { title body author { ...UserFields } }
Nested fragments — compose fragments together
fragment Recursive on Comment { id body replies { id body } }
Fragment for nested/recursive structures

Introspection

CommandDescription
{ __schema { types { name } } }
List all types in the schema
{ __schema { queryType { name } mutationType { name } } }
Get root type names
{ __type(name: "User") { name fields { name type { name kind } } } }
Introspect a specific type and its fields
{ __type(name: "User") { fields { name description isDeprecated deprecationReason } } }
Check for deprecated fields
{ __schema { directives { name description locations args { name } } } }
List all available directives
query { __typename }
Get the typename of the current query root
{ __schema { types { name kind description } } }
Full type list with kinds (OBJECT, SCALAR, ENUM, etc.)

Common Patterns

CommandDescription
type PageInfo { hasNextPage: Boolean! hasPreviousPage: Boolean! startCursor: String endCursor: String } type UserEdge { node: User! cursor: String! } type UserConnection { edges: [UserEdge!]! pageInfo: PageInfo! totalCount: Int! }
Relay-style cursor pagination
type Query { users(first: Int, after: String, last: Int, before: String): UserConnection! }
Connection-based pagination query
type Query { users(page: Int! = 1, perPage: Int! = 20): UserPage! } type UserPage { items: [User!]! total: Int! page: Int! totalPages: Int! }
Offset-based pagination (simpler alternative)
type MutationResponse { success: Boolean! message: String user: User errors: [FieldError!] } type FieldError { field: String! message: String! }
Standardized mutation response with error handling
interface Node { id: ID! } type Query { node(id: ID!): Node }
Node interface pattern — fetch any entity by global ID
type Query { viewer: User! }
Viewer pattern — current authenticated user as entry point
extend type Query { products: [Product!]! }
Schema extension — add fields to existing types (federation/modular schemas)
type Subscription { onUserCreated: User! onPostUpdated(id: ID!): Post! }
Subscription patterns for real-time updates

More Guides

🌿
Git Commands
Complete Git command reference — from basics to advanced workflows. Searchable, with examples.
📝
Vim Commands
Complete Vim/Vi command reference — modes, motions, editing, search, and advanced features.
🐳
Docker Commands
Complete Docker & Docker Compose command reference — containers, images, volumes, networks, and orchestration.
🔤
Regex Reference
Complete regular expression reference — syntax, patterns, quantifiers, groups, lookaheads, and common recipes.
🐧
Linux Commands
Complete Linux/Bash command reference — file management, text processing, networking, system admin, and shell scripting.
☸️
Kubernetes Commands
Complete Kubernetes & kubectl command reference — pods, deployments, services, configmaps, and cluster management.
🐍
Python Reference
Complete Python reference — syntax, data structures, string methods, file I/O, comprehensions, and common patterns.
🗃️
SQL Reference
Complete SQL reference — queries, joins, aggregation, subqueries, indexes, and database management.
🌐
Nginx Reference
Complete Nginx configuration reference — server blocks, locations, proxying, SSL, load balancing, and caching.
🔐
SSH Commands
Complete SSH reference — connections, key management, tunneling, config, SCP/SFTP, and security hardening.
👷
Jenkins Reference
Complete Jenkins reference — pipeline syntax, Jenkinsfile, plugins, CLI, agents, and CI/CD patterns.
📨
HTTP Headers Reference
Complete HTTP headers reference — request headers, response headers, caching, security, CORS, and content negotiation. Searchable, with examples.
🐘
PostgreSQL Reference
Comprehensive PostgreSQL reference — from connection basics to advanced features like JSONB, full-text search, window functions, and performance tuning.
Async Patterns Reference
Multi-language async/concurrency patterns — JavaScript, Python, Go, Rust, Java, and universal concurrency patterns.
📡
Protobuf & gRPC Reference
Comprehensive reference for Protocol Buffers (proto3) and gRPC — message definitions, services, streaming, and common patterns.
📚
JS Array Methods
Complete JavaScript Array methods reference — creating, searching, transforming, sorting, iterating, and common patterns. Searchable, with examples.
🌊
Tailwind CSS Reference
Complete Tailwind CSS reference — layout, spacing, typography, colors, responsive design, states, and common patterns. Searchable, with examples.
💻
VS Code Shortcuts
Complete VS Code keyboard shortcuts — editing, navigation, search, multi-cursor, terminal, debug, and more. Searchable, with Cmd/Ctrl notation.
🔲
CSS Grid Reference
Complete CSS Grid reference — container properties, item placement, grid functions, and common layout patterns. Searchable, with examples.
📦
CSS Flexbox Reference
Complete CSS Flexbox reference — container properties, item properties, and common layout patterns. Searchable, with examples.
⚛️
React Hooks Reference
Complete React Hooks reference — useState, useEffect, useContext, custom hooks, and common patterns. Searchable, with examples.
🔷
TypeScript Reference
Complete TypeScript reference — types, interfaces, generics, utility types, and advanced patterns. Searchable, with examples.
☁️
AWS CLI Reference
Complete AWS CLI reference — EC2, S3, IAM, Lambda, ECS, RDS, CloudFormation, and common operations.
🐹
Go Reference
Complete Go (Golang) reference — syntax, types, functions, concurrency, error handling, and common patterns.
💠
PowerShell Reference
Complete PowerShell reference — cmdlets, pipelines, scripting, file operations, remote management, and Active Directory.
💾
Redis Commands
Complete Redis command reference — strings, hashes, lists, sets, sorted sets, pub/sub, transactions, and server management.
🏗️
Terraform Commands
Complete Terraform reference — init, plan, apply, state management, modules, workspaces, and HCL syntax.
⚙️
Ansible Commands
Complete Ansible reference — playbooks, modules, inventory, roles, vault, and ad-hoc commands.

📖 Free, searchable command reference. Bookmark this page for quick access.