Skip to content

bimakw/graphql-store

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

graphql-store

GraphQL API for an e-commerce store built with Go, gqlgen, PostgreSQL, and Redis.

Features

  • Product CRUD with cursor-based pagination
  • Order management with transactional item creation
  • JWT authentication (register / login)
  • DataLoader for batched product lookups
  • Redis caching on product queries
  • Input validation

Stack

  • Go 1.24
  • gqlgen for GraphQL code generation
  • pgx/v5 for PostgreSQL
  • go-redis/v9 for caching
  • dataloadgen for N+1 prevention
  • golang-jwt for auth
  • testcontainers-go for integration tests

Setup

# start postgres and redis
docker compose up -d

# run the server
go run ./cmd/server

Server starts on http://localhost:8080 with the GraphQL playground.

Environment Variables

Variable Default Description
PORT 8080 Server port
DATABASE_URL postgres://store:store@localhost:5432/graphql_store?sslmode=disable Postgres DSN
REDIS_URL localhost:6379 Redis address
JWT_SECRET dev-secret-change-me JWT signing secret

Running Tests

# needs Docker for testcontainers
go test ./...

Project Structure

cmd/server/         main entrypoint
graph/
  schema/           GraphQL schema files
  model/            Go models (custom + generated)
  resolver/         resolver implementations
internal/
  auth/             JWT generation, validation, middleware
  cache/            Redis product cache
  db/               database connection and migrations
  loader/           DataLoader for batched queries
  store/            data access layer
testutil/           test helpers (testcontainers)

Docker

docker build -t graphql-store .
docker run -p 8080:8080 \
  -e DATABASE_URL=postgres://... \
  -e REDIS_URL=redis:6379 \
  -e JWT_SECRET=your-secret \
  graphql-store

About

GraphQL API for an e-commerce store — Go, gqlgen, PostgreSQL, Redis, DataLoader

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors