cd ../projects
Backend · API·2025·public repository·repo: graphql-api-1791

GraphQL API

Typed GraphQL schema design with FastAPI + Strawberry

// illustrative mock, real screenshots coming soon

A GraphQL API built with FastAPI and Strawberry, showcasing schema design, typed resolvers, and a clean, well-structured API surface.

$ cat problem.md

REST endpoints sprawl as clients' data needs grow; a typed GraphQL schema gives clients exactly what they ask for with a single, self-documenting contract.

$ whoami --role

Design & build (solo)

  • Python
  • FastAPI
  • Strawberry
  • GraphQL

$ cat approach.md

  1. 01Schema-first design with Strawberry's Python type system
  2. 02Typed resolvers wired into FastAPI
  3. 03Self-documenting, introspectable API surface

$ ls highlights/

Schema-first GraphQL design
Strawberry + FastAPI integration
Typed, introspectable resolvers

$ cat api.md

GraphQL over HTTP · Strawberry + FastAPI·POST /graphql·auth: None · public demo schema

A schema-first GraphQL API: typed Strawberry types, resolver composition into a single Query/Mutation root, and DataLoader batching to kill N+1 queries. Everything below is taken straight from the published source.

// Argument names shown from the resolver source; the live GraphQL Playground at /graphql is the canonical schema.

Types

TYPE

UserType

A user, and the author of a post.

  • id: Int!
  • name: String!
  • email: String!
TYPE

PostType

A post with its nested author.

  • id: Int!
  • title: String!
  • content: String!
  • author: UserType!

Queries

QUERY

users

List all users.

  • users: [UserType!]!
QUERY

posts

List all posts with authors.

  • posts: [PostType!]!
QUERY

post

Fetch a single post by id (raises if missing).

  • post(post_id: Int!): PostType!

Mutations

MUTATION

createUser

Create a user; rejects a duplicate email.

  • createUser(name: String!, email: String!): UserType!
MUTATION

createPost

Create a post for an existing author.

  • createPost(title: String!, content: String!, author_id: Int!): PostType!
MUTATION

updatePost

Patch a post's title and/or content.

  • updatePost(post_id: Int!, title: String, content: String): PostType!
MUTATION

deletePost

Delete a post by id.

  • deletePost(post_id: Int!): Boolean!

Examples

query GetAllPosts
query GetAllPosts {
  posts {
    id
    title
    content
    author {
      id
      name
    }
  }
}
response
{
  "data": {
    "posts": [
      {
        "id": 1,
        "title": "GraphQL Rocks",
        "content": "Really loving this",
        "author": { "id": 1, "name": "Jane Doe" }
      }
    ]
  }
}
mutation createPost
mutation {
  createPost(title: "GraphQL Rocks", content: "Really loving this", authorId: 1) {
    id
    title
    author { name }
  }
}