Skip to content

GraphQL and Protobuf docs drift

Rimfe reviews .graphql, .gql, .proto, AsyncAPI and JSON Schema files from their diff. It takes the type, field, message and enum names on the changed lines, finds the docs sections that mention them, and checks each section against the change. That catches renamed fields and removed values, with less precision than the OpenAPI comparison.

Updated

How a schema diff is reviewed

  • A changed schema is always reviewed, read before other files, and never counted as a docs page, even inside your docs folder.
  • The names on the changed lines are collected. Schema keywords such as type, input, message, rpc, enum and repeated are not names, and neither are very short words.
  • Each docs section that mentions one of those names is read and checked against the diff. A finding quotes the schema line and the page line.
  • API specs and schemas are read before other changed files. A very long schema diff is read from its start, up to a size limit.

Formats

FormatFilesHow it is reviewed
GraphQL.graphql, .gqlFrom the diff.
Protobuf.protoFrom the diff.
AsyncAPIasyncapi.json, .yaml, .ymlFrom the diff.
JSON Schema*.schema.jsonFrom the diff. Properties up to four levels deep are also read as config keys, with type, default, enum, required and deprecated: true.
OpenAPI and Swaggeropenapi.yaml, swagger.json and othersCompared operation by operation. See the OpenAPI page.

Example: a GraphQL field is renamed

The teams guide shows a query that selects members. Rimfe finds that section through the removed name, reads it against the diff, and posts a Docs conflict that quotes the query and the schema line, with an edit to people.

schema/team.graphql
  type Team {    id: ID!-   members: [User!]!+   people: [User!]!  }

Example: a Protobuf field is renamed

docs/guides/billing.md tells integrators to send customer_id with each invoice. A code mapping from proto/billing/** to that page makes it the first page read, and the stale line gets a Docs conflict.

proto/billing/v1/invoice.proto
  message Invoice {    string id = 1;-   string customer_id = 2;+   string account_id = 2;  }

Docs tools beside schemas

A GraphQL or gRPC reference generated from the schema at build time is not a file in your repository, so Rimfe cannot read it. The pages that go stale are the written ones: guides with sample queries, field tables and integration steps, in any Markdown, MDX, reST or AsciiDoc site such as Docusaurus or Mintlify.

Set up a schema repository

Map schema files to the pages that describe them, so those pages are read first. A review rule can hold every new field or message to a docs requirement.

.rimfe.json
{  "$schema": "https://rimfe.com/schema/rimfe.json",  "docsGlobs": ["docs/**/*.{md,mdx}"],  "codeMappings": [    { "source": "schema/**/*.graphql", "target": "docs/api/graphql/" },    { "source": "proto/billing/**", "target": "docs/guides/billing.md" }  ],  "rules": [    "Every new GraphQL type or field is described in docs/api/graphql"  ]}

Limits

  • There is no structural comparison. A nullability change such as String! to String, a new directive or a field number change is read as text on the changed line, not as a typed change.
  • A schema defined in code, with a code-first GraphQL library, is read as code in that language. GraphQL types are not extracted from it.
  • Directives and federation metadata are not interpreted.
  • Docs coverage counts OpenAPI and Swagger operations, not GraphQL fields or gRPC methods.

Try it on your next pull request.

Free for public repositories, with unlimited members.

Start free with GitHub