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

mercurius

> 后端框架
开源

使用 Fastify 实现 GraphQL 服务器和网关

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

工具介绍

使用 Fastify 实现 GraphQL 服务器和网关

mercurius

Mercurius is a GraphQL adapter for Fastify

Features:

  • Caching of query parsing and validation.
  • Automatic loader integration to avoid 1 + N queries.
  • Just-In-Time compiler via graphql-jit.
  • Subscriptions.
  • Federation support via @mercuriusjs/federation, including Subscriptions.
  • Gateway implementation via @mercuriusjs/gateway, including Subscriptions.
  • Batched query support.
  • Customisable persisted queries.

Docs

  • Install
  • Quick Start
  • Examples
  • API
  • Context
  • Loaders
  • Hooks
  • Lifecycle
  • Federation
  • Subscriptions
  • Batched Queries
  • Persisted Queries
  • TypeScript Usage
  • HTTP
  • GraphQL over WebSocket
  • Integrations
  • Related Plugins
  • Security - CSRF Prevention
  • Faq
  • Contributing
  • Acknowledgements
  • License

Install

bash
npm i fastify mercurius graphql
# or
yarn add fastify mercurius graphql

The previous name of this module was fastify-gql (< 6.0.0).

Quick Start

javascript
'use strict'

const Fastify = require('fastify')
const mercurius = require('mercurius')

const app = Fastify()

const schema = `
  type Query {
    add(x: Int, y: Int): Int
  }
`

const resolvers = {
  Query: {
    add: async (_, { x, y }) => x + y
  }
}

app.register(mercurius, {
  schema,
  resolvers
})

app.get('/', async function (req, reply) {
  const query = '{ add(x: 2, y: 2) }'
  return reply.graphql(query)
})

app.listen({ port: 3000 })

Examples

Check GitHub repo for more examples.

Contributing

Mercurius is an OPEN Open Source Project. This means that:

Individuals making significant and valuable contributions are given commit-access to the project to contribute as they see fit. This project is more like an open wiki than a standard guarded open source project.

See the CONTRIBUTING.md file for more details.

Acknowledgements

The project is kindly sponsored by:

  • NearForm
  • Platformatic

The Mercurius name was gracefully donated by Marco Castelluccio. The usage of that library was described in https://hacks.mozilla.org/2015/12/web-push-notifications-from-irssi/, and you can find that codebase in https://github.com/marco-c/mercurius.

License

MIT

Issues· 0 开放

查看全部 Issues在 GitHub 打开

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

> 标签

JavaScriptfastifyfederationgatewaygraphql

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

> 工具信息

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

> 相关工具

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