Which GraphQL package is recommended for integration with Hono? #4746
Replies: 2 comments 1 reply
-
|
Have you tried |
Beta Was this translation helpful? Give feedback.
-
|
Echoing @Namchee: import { Hono } from 'hono'
import { graphqlServer } from '@hono/graphql-server'
import { buildSchema } from 'graphql'
const schema = buildSchema(`
type Query {
hello: String
}
`)
const app = new Hono()
app.use('/graphql', graphqlServer({
schema,
rootValue: { hello: () => 'Hello, World!' },
}))
app.get('/api/health', (c) => c.json({ status: 'ok' }))
export default appFor subscriptions, file uploads, persisted queries or anything else beyond a basic schema, import { createYoga, createSchema } from 'graphql-yoga'
const yoga = createYoga({
schema: createSchema({
typeDefs: `type Query { hello: String }`,
resolvers: { Query: { hello: () => 'Hello' } },
}),
})
app.use('/graphql', (c) => yoga.fetch(c.req.raw, c.env))Apollo Server also works but carries more weight and is harder to deploy on edge runtimes. For a demo that needs to look production-ready, I'd reach for |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I looked at
https://www.npmjs.com/and looked especially for:@getcronit/pylon: < 700 weekly downloadsgraphql-yoga: ~ 300.000 weekly downloads@apollo/server: ~ 800.000 weekly downloadsAre there other packages that can seriously be recommended? I want to extend a REST API (of course built with Hono) to have an additional GraphQL API. In the 1st step it's mainly for demo purposes, but should be somehow realistic and look serious. Any hints are welcome! And also hints about an integration into a Hono app.
Beta Was this translation helpful? Give feedback.
All reactions