danvega / gqlversion

Repository from Github https://github.comdanvega/gqlversionRepository from Github https://github.comdanvega/gqlversion

GraphQL API Versioning Demo

A Spring Boot application demonstrating how GraphQL eliminates the need for API versioning through field-level evolution and deprecation.

Overview

This project showcases GraphQL's approach to API evolution by maintaining backward compatibility while introducing new fields. Instead of creating /api/v2 endpoints, GraphQL allows both old and new clients to coexist by requesting only the fields they need.

Key Concepts Demonstrated

  • Field-level deprecation using @deprecated directive
  • Backward compatibility with deprecated name field
  • Forward evolution with new firstName and lastName fields
  • Client flexibility - each client requests exactly what they need

Running the Application

# Run the application
./mvnw spring-boot:run

# Run tests
./mvnw test

Access GraphiQL at: http://localhost:8080/graphiql

Example Queries

Legacy client using deprecated field:

query {
  user(id: "123") {
    name
    email
  }
}

Modern client using new fields:

query {
  user(id: "123") {
    firstName
    lastName
    email
    avatar
    lastLoginAt
  }
}

Both queries work simultaneously without versioning.

Tech Stack

  • Spring Boot 3.5.6
  • Spring for GraphQL
  • Java 25
  • Maven

About


Languages

Language:Java 100.0%