Files
goplt/docs/content/stories/epic8/8.2-graphql-api.md

1.3 KiB

Story 8.2: GraphQL API

Metadata

  • Story ID: 8.2
  • Title: GraphQL API
  • Epic: 8 - Advanced Features & Polish
  • Status: Pending
  • Priority: Low
  • Estimated Time: 8-10 hours
  • Dependencies: 1.5, 2.1, 4.1

Goal

Add optional GraphQL API alongside REST API for flexible data querying.

Description

This story implements a GraphQL API using gqlgen that provides an alternative to REST endpoints with flexible querying capabilities.

Deliverables

1. GraphQL Schema

  • Install github.com/99designs/gqlgen
  • Create GraphQL schema:
    • User queries
    • Blog queries
    • Mutations
    • Subscriptions (optional)

2. GraphQL Resolvers

  • Implement resolvers:
    • Use existing services
    • Add authorization checks
    • Error handling

3. GraphQL Endpoint

  • Add GraphQL endpoint: POST /graphql
  • GraphQL playground: GET /graphql (development)
  • Integration with authentication

Acceptance Criteria

  • GraphQL schema is defined
  • Resolvers work correctly
  • Authorization is enforced
  • GraphQL endpoint works
  • GraphQL playground works (dev)

Files to Create/Modify

  • api/graphql/schema.graphql - GraphQL schema
  • internal/api/graphql/resolvers.go - Resolvers
  • internal/server/routes.go - Add GraphQL route