百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
G

graphql-schema-registry

> 后端框架
开源

GraphQL 方案注册表

376 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

GraphQL 方案注册表

graphql-schema-registry

Graphql schema storage as dockerized on-premise service for federated graphql gateway server (based on apollo server) as alternative to Apollo studio, The Guild's Hive, WunderGraph

Features

  • Stores versioned schema for graphql-federated services
  • Serves supergraph schema for graphql gateway based on provided services & their versions.
    • Apollo federation v1 & v2 is supported
  • Validates new schema to be compatible with other running services
  • Provides UI for developers to see stored schema & its history diff
  • Stores service urls emulating managed federation: you no longer need to hardcode the services in your gateway's constructor, or rely on an additonal service (etcd, consul) for service discovery
  • Does async schema usage analysis to minimize breaking changes from reaching production
  • Publishes schema registration events to minimize supergraph update time
  • Stores & shows in UI automatic persisted queries (passed by the gateway) for better visibility

https://user-images.githubusercontent.com/445122/194967021-8e5d1750-db39-4809-8485-55d2b1b19429.mp4

Installation

With default settings, UI should be accessible at http://localhost:6001

On bare host

bash
git clone https://github.com/tot-ra/graphql-schema-registry.git && cd graphql-schema-registry
cp example.env .env && nano .env
npm install && npm run build
node app/schema-registry.js

Docker image

We have docker image published for main node service. It assumes you have postgres/redis running separately. Use exact IP instead of localhost. Use exact docker image tag to avoid breaking changes.

bash
docker pull artjomkurapov/graphql-schema-registry:5.5.1
docker run -e DB_CLIENT=pg -e DB_HOST=localhost -e DB_USERNAME=postgres -e DB_SECRET=postgres -e DB_PORT=5432 -e DB_NAME=schema_registry -p 6001:3000 artjomkurapov/graphql-schema-registry

Docker-compose

bash
git clone https://github.com/tot-ra/graphql-schema-registry.git && cd graphql-schema-registry
docker-compose -f docker-compose.base.yml -f docker-compose.prod.yml up

Architecture

Components

…
Name Role Description
federated gateway Required Apollo server running in federated mode. You should have your own. Check examples folder how to configure it. Note however, that gateway is very simplified and does not have proper error handling, query cost limit checks or fail-safe mechanisms.
schema registry Required Main service that we provide
postgres Required Main data storage of schemas and other derivative data
query analyzer Optional Processes queries in async mode, required for usage tracking. Main code in /src/worker folder
redis Required Shared cache and pub/sub layer used for APQ cache, schema update notifications, and query usage event ingestion

Tech stack

Frontend (/client folder) Backend (/src folder)
react nodejs 25.x
apollo client express, hapi/joi
styled-components apollo-server-express, dataloader
redis 8
knex
postgres 18

DB structure

Migrations are done using knex

…

Configuration

We use environment variables for configuration. You can:

  • pass them directly
  • add .env file and dotenv will pick them up
  • add them to docker-compose.yml or Dockerfile

The following are the different environment variables that are looked up that allow configuring the schema registry in different ways.

Variable Name Description Default
DB_CLIENT DB driver used by knex pg
DB_HOST Host name of the Postgres server gql-schema-registry-db
DB_USERNAME Username to connect to Postgres postgres
DB_SECRET Password used to connect to Postgres postgres
DB_PORT Port used when connecting to Postgres 5432
DB_NAME Name of the Postgres database to connect to schema_registry
DB_ADMIN_DATABASE Admin DB used for existence checks/creation before migrations postgres
DB_SSL Enables TLS for Postgres connections false
DB_SSL_REJECT_UNAUTHORIZED Controls server cert validation when DB_SSL=true true
DB_SSL_CA Optional CA certificate content for TLS (supports \\n escaped newlines) Empty
DB_EXECUTE_MIGRATIONS Controls whether DB migrations are executed upon registry startup or not true
ASSETS_URL Controls the url that web assets are served from localhost:6001
NODE_ENV Specifies the environment. Use production to load js/css from dist/assets Empty
ASYNC_SCHEMA_UPDATES Specifies if async achema updates is enabled false
REDIS_SCHEMA_UPDATES_CHANNEL Redis pub/sub channel used for schema update notifications graphql-schema-updates
REDIS_QUERIES_CHANNEL Redis pub/sub channel used by gateway request logging and query analyzer graphql-queries
LOG_LEVEL Minimum level of logs to output info
LOG_TYPE Output log type, supports pretty or json. pretty
LOG_STREAMING_ENABLED Controls whether logs are streamed over Redis to be presented in UI true
REDIS_HOST Host name of the Redis server gql-schema-registry-redis
REDIS_PORT Port used when connecting to Redis 6379
REDIS_SECRET Password used to connect to Redis Empty
REDIS_DB Index of the logical redis database 2

For development we rely on docker network and use hostnames from docker-compose.yml. Node service uses it to connect to postgres & redis and change it if you install it with your own setup. For dynamic service discovery (if you need multiple hosts for scaling), override app/config.js and diplomat.js

Use cases / FAQ

When/how do I register schema?

On service start-up (runtime), make POST to /schema/push to register schema (see API reference for details). Make sure to handle failure.

See example for nodejs/ESM.

How do I register GraphQL subscriptions from event-stream services?

If you have a dedicated websocket/event service (for example event-stream-filter) that exposes GraphQL Subscription operations, register that SDL separately with:

  • POST /subscriptions/push

This subscription catalog is intentionally separate from federated supergraph composition:

  • POST /schema/push is for federated gateway service schemas
  • POST /subscriptions/push is for event-stream subscription visibility in UI and analytics

Minimal runtime payload example:

json
{
  "name": "event-stream-filter",
  "version": "latest",
  "ws_url": "ws://event-stream-filter:8350/graphql",
  "type_defs": "type Subscription { onApiaryUpdated: ApiaryEvent } type ApiaryEvent { id: String name: String } type Query { hello: String }"
}

How do I register schema that is being developed?

Usually in production, POST /schema/push requires unique version that should be unique git or docker hash. But, if you are developing a service and you run schema-registry locally, you can set version: "latest" to skip this version check.

Do I need to deregister services?

  • if your gateway uses /schema/compose then no, schema is composed based on services you see as healthy
  • if your gateway uses /schema/latest then maybe. Schema-registry will provide last schema that was registered in time. So if you deploy older version of your service, you will still have last schema there that you would need to deregister. Schema has is_active flag in DB that you can manually toggle via UI.

When do I need to validate schema?

On pre-commit / deploy make a POST /schema/validate to see if its compatible with current schema. If you have multiple regions or environments (test), makes sense to check all.

How do I migrate schema between services?

If service A contains schema that needs to be migrated to service B with close to 0 downtime, you will need to orchestrate schema & traffic change. Instead of juggling with schema status flags, we suggest the following scenario:

mermaid
sequenceDiagram
    participant service_A
    participant service_B
    participant schemaRegistry

    loop Every 5 sec
       service_B->>+schemaRegistry: register schema B + A1
       s

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

TypeScriptapollodockergraphqlnodejs

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类后端框架
定价开源

> 相关工具

N
Node.js
基于 V8 的 JavaScript 运行时
D
Django
Python 高级 Web 框架
S
Spring Boot
Java 生态主流微服务框架