Claude-skill-registry graphql-fundamentals
Master GraphQL core concepts - types, queries, mutations, and subscriptions
install
source · Clone the upstream repo
git clone https://github.com/majiayu000/claude-skill-registry
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/majiayu000/claude-skill-registry "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/data/graphql-fundamentals" ~/.claude/skills/majiayu000-claude-skill-registry-graphql-fundamentals && rm -rf "$T"
manifest:
skills/data/graphql-fundamentals/SKILL.mdsource content
GraphQL Fundamentals Skill
Master the building blocks of GraphQL APIs
Overview
This skill covers the essential GraphQL concepts every developer needs. From type definitions to query operations, you'll learn the foundation for building GraphQL APIs.
Quick Reference
| Concept | Syntax | Example |
|---|---|---|
| Scalar | , , , , | |
| Object | | |
| Input | | |
| Enum | | |
| List | or | |
| Non-null | | |
Core Concepts
1. Type System
# Scalar types (built-in) type Example { id: ID! # Unique identifier name: String! # Text age: Int # Integer (nullable) score: Float! # Decimal active: Boolean! # True/false } # Custom scalars scalar DateTime scalar JSON scalar Upload # Object types type User { id: ID! email: String! profile: Profile # Nested object posts: [Post!]! # List of objects } type Profile { bio: String avatar: String } # Enums enum UserRole { ADMIN EDITOR VIEWER } # Input types (for mutations) input CreateUserInput { email: String! name: String! role: UserRole = VIEWER # Default value } # Interfaces interface Node { id: ID! } type User implements Node { id: ID! name: String! } # Unions union SearchResult = User | Post | Comment
2. Queries
# Schema definition type Query { # Single item user(id: ID!): User # List with optional filter users(filter: UserFilter, limit: Int = 10): [User!]! # Search search(query: String!): [SearchResult!]! } # Client query examples query GetUser { user(id: "123") { id name email } } query GetUsersWithFilter { users(filter: { role: ADMIN }, limit: 5) { id name } } # With variables query GetUser($userId: ID!) { user(id: $userId) { id name } } # Variables: { "userId": "123" } # With aliases query GetTwoUsers { admin: user(id: "1") { name } editor: user(id: "2") { name } } # With fragments fragment UserFields on User { id name email } query GetUsers { users { ...UserFields } }
3. Mutations
# Schema definition type Mutation { createUser(input: CreateUserInput!): CreateUserPayload! updateUser(id: ID!, input: UpdateUserInput!): User! deleteUser(id: ID!): DeletePayload! } type CreateUserPayload { user: User errors: [Error!]! } # Client mutation mutation CreateUser($input: CreateUserInput!) { createUser(input: $input) { user { id name } errors { field message } } } # Variables: { "input": { "email": "test@example.com", "name": "Test" } }
4. Subscriptions
# Schema definition type Subscription { userCreated: User! messageReceived(channelId: ID!): Message! } # Client subscription subscription OnUserCreated { userCreated { id name createdAt } } subscription OnMessage($channelId: ID!) { messageReceived(channelId: $channelId) { id content sender { name } } }
Common Patterns
Nullability Cheat Sheet
type Example { # Required field - never null id: ID! # Optional field - can be null nickname: String # Required list, optional items tags: [String]! # [], ["a", null, "b"] # Required list, required items (most common) categories: [Category!]! # [], [cat1, cat2] # Optional list (avoid - ambiguous) # items: [Item] # null vs [] unclear }
Input Validation Pattern
input CreateUserInput { email: String! # Required name: String! # Required age: Int # Optional role: UserRole = VIEWER # Optional with default }
Troubleshooting
| Error | Cause | Solution |
|---|---|---|
| Field not in schema | Check spelling, verify schema |
| Missing variable declaration | Add to query signature |
| Resolver returned null for field | Fix resolver or make nullable |
| Type not defined | Add type definition |
Debug Commands
# Validate schema npx graphql-inspector validate schema.graphql # Introspect remote schema npx graphql-inspector introspect http://localhost:4000/graphql # Check for breaking changes npx graphql-inspector diff old.graphql new.graphql
Usage
Skill("graphql-fundamentals")
Related Skills
- Advanced schema patternsgraphql-schema-design
- Implementing resolversgraphql-resolvers
- TypeScript type generationgraphql-codegen
Related Agent
- For detailed guidance01-graphql-fundamentals