Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] [@hono/graphql-server] error: Unexpected reading #472

Open
WuChenDi opened this issue Apr 24, 2024 · 1 comment
Open

[bug] [@hono/graphql-server] error: Unexpected reading #472

WuChenDi opened this issue Apr 24, 2024 · 1 comment

Comments

@WuChenDi
Copy link

Hi, Apologies for the inconvenience. I am unsure of the source of the error.

The version of bun used is 1.1.3.

wd@cd MINGW64 /c/cd/github/my-app
$ pnpm run dev

> @cdlab996/graphql-server@ dev C:\cd\github\my-app
> bun run --hot src/index.ts

error: Unexpected reading "C:\cd\github\my-app\node_modules\graphql"

Below is my original code:

  • /src/index.ts
import { Hono } from 'hono'
import { cors } from 'hono/cors'
import { graphqlServer } from '@hono/graphql-server'
import { buildSchema } from 'graphql'

const app = new Hono()

app.get('/', (c) => {
  return c.text('Hello Hono!')
})

const schema = buildSchema(`
type Account {
  name: String,
  age: Int,
  sex: String,
  department: String
}
type Query {
  hello: String,
  userName: String,
  age: Int,
  account: Account
}
`)

const rootResolver = (ctx: any) => {
  console.log(ctx)

  return {
    hello: () => 'Hello Hono!',
    userName: () => 'dd',
    age: () => 25,
    account: () => {
      return {
        name: 'dd',
        age: 25,
        sex: 'boy',
        department: 'technical division',
      }
    },
  }
}

app.use(cors())

app.use(
  '/graphql',
  graphqlServer({
    schema,
    rootResolver,
    pretty: true,
  })
)

app.fire()

// export default app
export default {
  port: process.env.SERVER_PORT || 3000,
  fetch: app.fetch,
}
  • package.json
{
  "name": "@cdlab996/graphql-server",
  "scripts": {
    "dev": "bun run --hot src/index.ts"
  },
  "dependencies": {
    "@hono/graphql-server": "^0.4.3",
    "graphql": "^16.8.1",
    "hono": "^4.2.7"
  },
  "devDependencies": {
    "@types/bun": "latest"
  }
}
@yusukebe
Copy link
Member

yusukebe commented May 1, 2024

Hi @WuChenDi

@metrue Could you see this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants