GraphQL 標誌GraphQL

graphql-http

官方 graphql-http 套件 提供建立完全相容 GraphQL 伺服器的簡單方法。它有一個處理常式,適用於 Node.js 原生 http,以及處理常式,適用於著名的架構,如 ExpressFastifyKoa;以及處理常式,適用於不同的執行環境,如 DenoBun

Express#

import { createHandler } from "graphql-http/lib/use/express" // ES6
const { createHandler } = require("graphql-http/lib/use/express") // CommonJS

createHandler#

createHandler({
schema: GraphQLSchema,
rootValue?: ?any,
context?: ?any,
formatError?: ?Function,
validationRules?: ?Array<any>,
}): Handler

根據 GraphQL 架構建構一個 Express 處理常式。

請參閱 教學課程,以取得範例用法。

請參閱 GitHub README,以取得更廣泛的文件,包括如何將 graphql-http 與其他伺服器架構和執行環境搭配使用。

繼續閱讀 →graphql