graphql-api
Skill110 starsChanged 9 months agoApache-2.0View on GitHub
GraphQL API design and implementation patterns. Use when building GraphQL servers, defining schemas, writing resolvers, implementing subscriptions, or consuming GraphQL APIs.
1 other project uses a version of this.
Adopted by
Most recently taken up by
- yiweiwan/skillstheir own version, first seen May 12, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- yiweiwan/skills★ 1same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository75 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- algorithmic-artSkill
- api-designSkill
- apple-notesSkill
- apple-remindersSkill
- article-writingSkill
- async-pythonSkill
- brand-guidelinesSkill
- camsnapSkill
- canvas-designSkill
- celery-tasksSkill
- claude-apiSkill
- coding-agentSkill
- content-engineSkill
- diffsSkill
- doc-coauthoringSkill
- docker-deploymentSkill
- docxSkill
- e2e-testingSkill
- email-serviceSkill
- fastapi-backendSkill
- frontend-designSkill
- frontend-slidesSkill
- gh-issuesSkill
- githubSkill
- git-workflowSkill
- healthcheckSkill
- internal-commsSkill
- investor-materialsSkill
- jwt-authenticationSkill
- market-researchSkill
- mcp-builderSkill
- mermaid-diagramsSkill
- microservicesSkill
- mobile-react-nativeSkill
- model-usageSkill
- nextjs-fullstackSkill
- nodejs-expressSkill
- obsidianSkill
- openai-whisperSkill
- oracleSkill
- pdfSkill
- peekabooSkill
- planning-with-filesSkill
- postgres-databaseSkill
- pptxSkill
- prisma-ormSkill
- proseSkill
- pytest-patternsSkill
- react-typescriptSkill
- redis-cachingSkill
- s3-file-storageSkill
- security-reviewSkill
- session-logsSkill
- skill-creatorSkill
- slack-gif-creatorSkill
- sqlalchemy-ormSkill
- state-managementSkill
- strategic-compactSkill
- stripe-paymentsSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 2 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 278
ALWAYS use DataLoaders for relation fields (never query DB in individual resolvers)
- Very specific: line 281
Never expose internal IDs — use opaque ID type
- Distinctive: line 284
Use persisted queries in production (security + performance)
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
GraphQL API Patterns
Schema Design (SDL)
# schema.graphql
type Query {
user(id: ID!): User
users(filter: UserFilter, pagination: Pagination): UserConnection!
posts(authorId: ID, published: Boolean): [Post!]!
}
type Mutation {
createUser(input: CreateUserInput!): UserPayload!
updateUser(id: ID!, input: UpdateUserInput!): UserPayload!
deleteUser(id: ID!): Boolean!
}
type Subscription {
messageAdded(chatId: ID!): Message!
}
type User {
id: ID!
email: String!
name: String!
posts: [Post!]!
createdAt: DateTime!
}
type Post {
id: ID!
title: String!
body: String!
published: Boolean!
author: User!
tags: [String!]!
}
# Pagination (Relay-style)
type UserConnection {
edges: [UserEdge!]!
pageInfo: PageInfo!
totalCount: Int!
}
type UserEdge { node: User!; cursor: String! }
type PageInfo { hasNextPage: Boolean!; endCursor: String }
# Input types
input CreateUserInput {
email: String!
name: String!
password: String!
}
input UserFilter {
role: Role
search: String
}
input Pagination {
first: Int
after: String
}
# Error handling — union pattern
union UserPayload = User | UserError
type UserError { message: String!; code: String! }
enum Role { USER ADMIN }
scalar DateTimeServer Setup (Strawberry / Python)
# graphql_app.py
import strawberry
from strawberry.fastapi import GraphQLRouter
from strawberry.types import Info
@strawberry.type
class User:
id: strawberry.ID
email: str
name: str
@strawberry.field
async def posts(self, info: Info) -> list["Post"]:
return await info.context["loaders"].posts_by_user.load(self.id)
@strawberry.type
class Query:
@strawberry.field
async def user(self, id: strawberry.ID, info: Info) -> User | None:
return await info.context["db"].get_user(id)
@strawberry.field
async def users(self) -> list[User]:
return await info.context["db"].list_users()
@strawberry.type
class Mutation:
@strawberry.mutation
async def create_user(self, email: str, name: str, info: Info) -> User:
return await info.context["db"].create_user(email=email, name=name)
schema = strawberry.Schema(query=Query, mutation=Mutation)
# FastAPI integration
graphql_app = GraphQLRouter(schema, context_getter=get_context)
app.include_router(graphql_app, prefix="/graphql")DataLoader (N+1 Prevention)
from strawberry.dataloader import DataLoader
async def load_posts_by_user(user_ids: list[str]) -> list[list[Post]]:
"""Batch-load posts for many users in one DB query."""
rows = await db.fetch(
"SELECT * FROM posts WHERE author_id = ANY($1)", user_ids
)
# Group by author_id
grouped = {}
for row in rows:
grouped.setdefault(row["author_id"], []).append(Post(**row))
return [grouped.get(uid, []) for uid in user_ids]
async def get_context():
return {
"db": db,
"loaders": {
"posts_by_user": DataLoader(load_fn=load_posts_by_user)
}
}Server Setup (Node.js / Apollo)
import { ApolloServer } from '@apollo/server'
import { startStandaloneServer } from '@apollo/server/standalone'
const typeDefs = `#graphql
type Query {
users: [User!]!
user(id: ID!): User
}
type User {
id: ID!
name: String!
email: String!
}
`
const resolvers = {
Query: {
users: async (_, __, { dataSources }) => dataSources.usersAPI.getUsers(),
user: async (_, { id }, { dataSources }) => dataSources.usersAPI.getUser(id),
},
}
const server = new ApolloServer({ typeDefs, resolvers })
const { url } = await startStandaloneServer(server, {
context: async ({ req }) => ({
token: req.headers.authorization,
dataSources: { usersAPI: new UsersAPI() },
}),
})Client Usage (urql / React)
import { useQuery, useMutation } from 'urql'
const GET_USERS = `
query GetUsers($filter: UserFilter) {
users(filter: $filter) {
edges {
node { id name email }
}
pageInfo { hasNextPage endCursor }
}
}
`
function UserList() {
const [result] = useQuery({
query: GET_USERS,
variables: { filter: { role: 'USER' } },
})
if (result.fetching) return <p>Loading...</p>
if (result.error) return <p>Error: {result.error.message}</p>
return result.data.users.edges.map(({ node }) => (
<div key={node.id}>{node.name}</div>
))
}
// Mutation
const CREATE_USER = `
mutation CreateUser($email: String!, $name: String!) {
createUser(input: { email: $email, name: $name }) {
... on User { id name }
... on UserError { message code }
}
}
`
const [, createUser] = useMutation(CREATE_USER)
await createUser({ email, name })Subscriptions (WebSocket)
// Server
const typeDefs = `
type Subscription {
messageAdded(chatId: ID!): Message!
}
`
const resolvers = {
Subscription: {
messageAdded: {
subscribe: (_, { chatId }, { pubsub }) =>
pubsub.asyncIterator(`MESSAGE_ADDED_${chatId}`),
},
},
}
// Publish from mutation
await pubsub.publish(`MESSAGE_ADDED_${chatId}`, { messageAdded: newMessage })
// Client
import { createClient } from 'graphql-ws'
const client = createClient({ url: 'ws://localhost:4000/graphql' })
client.subscribe(
{ query: `subscription { messageAdded(chatId: "1") { id text } }` },
{ next: (data) => console.log(data), error: console.error }
)Authentication & Authorization
# Strawberry permission classes
from strawberry.permission import BasePermission
class IsAuthenticated(BasePermission):
message = "User is not authenticated"
def has_permission(self, source, info: Info, **kwargs) -> bool:
return info.context["user"] is not None
class IsAdmin(BasePermission):
message = "User is not an admin"
def has_permission(self, source, info: Info, **kwargs) -> bool:
user = info.context["user"]
return user and user.role == "ADMIN"
@strawberry.type
class Query:
@strawberry.field(permission_classes=[IsAuthenticated])
async def me(self, info: Info) -> User:
return info.context["user"]
@strawberry.field(permission_classes=[IsAdmin])
async def admin_stats(self) -> Stats:
...Rules
- ALWAYS use DataLoaders for relation fields (never query DB in individual resolvers)
- Union types for mutations (UserPayload = User | UserError) — not exceptions
- Relay-style pagination for lists (edges/node/pageInfo + totalCount)
- Never expose internal IDs — use opaque
IDtype - Depth limiting: reject queries deeper than 5-7 levels (prevent DoS)
- Query complexity analysis: reject queries above budget (e.g., 100 complexity)
- Use persisted queries in production (security + performance)
- Subscriptions over WebSocket; SSE is not standard for GraphQL
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

