Skip to content

Hono middleware does not support subscription #31

Closed
@motopods

Description

@motopods
import { weave } from "@gqloom/core"
import { graphqlServer } from "@hono/graphql-server"
import { serve } from "@hono/node-server"
import { Hono } from "hono"
import { helloResolver } from "./resolvers"

import { createYoga } from "graphql-yoga"

export const app = new Hono()
 
const schema = weave(helloResolver)
 
// this not support subscription
// app.use("/graphql", graphqlServer({ schema, graphiql: true }))
 
// this works
const yoga = createYoga({
	schema,
	graphiql: true,
})
app.use("/graphql", async (ctx) => {
	return await yoga.fetch(ctx.req.raw, ctx)
})

serve(app, (info) => {
  console.info(
    `GraphQL server is running on http://localhost:${info.port}/graphql`
  )
})

I have tested that it is a problem with the hono middleware itself, but I don't know how to pass the context when using yoga.fetch directly.
I can't get context by useContext in subscription resovler, it's always undefined. query and mutation is OK.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions