PlannedETA Q4 202589 votes

GraphQL Schema Smoke Tests

DocsCI will parse GraphQL query and mutation examples from your documentation, validate them against your live schema introspection, and detect deprecated field usage, type mismatches, and missing required arguments — filed as PR comments with suggested fixes.

The GraphQL docs quality problem

GraphQL schemas evolve constantly. Fields get deprecated, types change, arguments are renamed. Documentation query examples break in three silent ways:

Deprecated field usage
# Schema: user.email is deprecated, use user.emailAddress
query GetUser {
  user(id: "123") {
    name
    email       # ← deprecated, docs example still uses it
  }
}
Users copy the example, get a deprecation warning, and file a support ticket.
Type mismatch in variables
# Schema: createPost(authorId: ID!) — not String
mutation CreatePost($title: String!, $authorId: String!) {
  createPost(title: $title, authorId: $authorId) { id }
}
# ↑ authorId should be ID!, not String!
Query fails at runtime with a cryptic type error.
Missing required arguments
# Schema: post(id: ID!, locale: String!) — locale is required
query GetPost($id: ID!) {
  post(id: $id) {        # ← missing required locale argument
    title
    content
  }
}
Query returns a 400 or null — confusing to developers new to the API.

How GraphQL smoke tests will work

1
Schema introspection

DocsCI fetches your GraphQL schema via introspection query (`__schema`) against your staging endpoint. Supports standard introspection, schema file upload, or SDL file in the repo.

2
Query extraction from docs

GraphQL fenced code blocks (`graphql`, `gql`) are extracted from Markdown/MDX files. Variables blocks are extracted from adjacent json/javascript code blocks or inline comments.

3
Static validation

Extracted queries are validated against the schema using graphql-js validate(). Checks: deprecated fields, type compatibility, required arguments, unknown fields, and fragment consistency.

4
Optional: live smoke test

With `graphql.smoke_test: true`, DocsCI executes the query against your staging endpoint (allowlisted). Validates that the response matches the documented shape.

5
PR comments with fixes

Each finding is filed as a PR comment with the exact file/line, the validation error, and a suggested fix. Deprecated field findings include the replacement field name from the schema's @deprecated reason.

Planned configuration

# docsci.yml (planned GraphQL config)
graphql:
  # Schema source (one of):
  schema_url: "https://staging-api.example.com/graphql"  # introspection
  # schema_file: "schema.graphql"                         # SDL file in repo

  # Introspection auth (if needed)
  schema_auth:
    type: bearer
    token_env: GRAPHQL_SCHEMA_TOKEN

  # Validation rules
  check_deprecated: true          # fail on deprecated field usage
  check_types: true               # validate variable types
  check_required_args: true       # flag missing required arguments
  fail_on_deprecated: false       # warn only, don't fail CI
  fail_on_type_error: true        # type errors block merge

  # Optional: live smoke test
  smoke_test: false               # set true to execute queries against staging
  smoke_test_url: "https://staging-api.example.com/graphql"
  smoke_test_auth:
    type: bearer
    token_env: GRAPHQL_API_TOKEN

Sample PR comment output

## ⚠️ DocsCI — GraphQL — docs/reference/users.md:34

**Finding:** Deprecated field `user.email` — use `user.emailAddress` instead.
**Rule:** check_deprecated
**Impact:** warning

```diff
  query GetUser($id: ID!) {
    user(id: $id) {
      name
-     email
+     emailAddress
    }
  }
```

---

## ❌ DocsCI — GraphQL — docs/guides/create-post.md:89

**Finding:** Variable `$authorId` has type `String!` but schema expects `ID!`
**Rule:** check_types
**Impact:** critical — blocks merge

```diff
- mutation CreatePost($title: String!, $authorId: String!) {
+ mutation CreatePost($title: String!, $authorId: ID!) {
```

Timeline

NowREST/curl example execution available
Oct 2025Private beta: GraphQL static validation (schema file)
Nov 2025Schema introspection support
Dec 2025GA: GraphQL smoke tests on all plans
Q1 2026Live smoke test execution (optional)

Using GraphQL? Tell us about your schema.

We're looking for GraphQL teams to co-design the smoke test feature. Share your use case and join the Q4 beta.