22 · Integrations
GraphQL — forge/server has it built in
Pylon is Hono's GraphQL adapter. forge/server ships GraphQLEngine directly: schema + resolvers + DataLoader, no separate package.
Code
pylon.js
const { WebApp, GraphQLEngine } = require(class="tk-str">39;@hyperbridge/forge/server39;); const app = new WebApp(); const gql = new GraphQLEngine({ typeDefs: class="tk-str">` type Query { hello: String user(id: Int!): User } type User { id: Int, name: String } `, resolvers: { Query: { hello: () => class="tk-str">39;world39;, user: (_, { id }) => ({ id, name: class="tk-str">`User ${id}` }), }, }, }); app.post(class="tk-str">39;/graphql39;, async (c) => { const { query, variables } = await c.req.json(); return c.json(await gql.execute(query, variables)); }); app.listen(3000);
How it works
GraphQLEngine is a minimal but complete GraphQL implementation: schema parsing, type resolution, validation, execution, batching.
DataLoader (also exported from forge/server) handles the N+1 query problem the same way Facebook's original library does.
Subscriptions ride on the WebSocket support already in forge/server — no additional package.
Try it
Quickstart
curl -X POST http://localhost:3000/graphql -d '{"query":"{ hello }"}'
Related modules
This is HBForge's port of Hono's example. Read the original at hono.dev/examples/pylon.