Skip to content
프로젝트

소개

☁ Universal GraphQL HTTP middleware for Deno and Bun

웹 및 앱 개발

이 수치를 측정하는 방법

What you can do

  • ✨ Works with Deno.serve, Bun.serve and oak
  • ⚡ GraphQL Playground integration (via graphiql: true)
  • 🔄 Async context initialization support for auth, DB queries, and more

측정된 스타 증가

in 24h
0
in 7 days
0
in 15 days
0
in 1 month
기록 수집 중

서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.

README.md

Original


nest badge GitHub Workflow Status Codecov

gql

Universal and spec-compliant GraphQL HTTP middleware for Deno and Bun. Based on graphql-http.

Features

  • ✨ Works with Deno.serve, Bun.serve and oak
  • ⚡ GraphQL Playground integration (via graphiql: true)
  • 🔄 Async context initialization support for auth, DB queries, and more

Version compatibility

The schema you pass to GraphQLHTTP must come from the same major version of graphql that gql itself uses — graphql rejects schemas built by a different copy of itself, both at type-check time and at runtime.

graphql gql
v17 v5
v16 v4

Get started

The simplest setup with Deno.serve:

import { GraphQLHTTP } from 'jsr:@deno-libs/[email protected]'
import { makeExecutableSchema } from 'npm:@graphql-tools/[email protected]'
import { gql } from 'jsr:@deno-libs/[email protected]'

const typeDefs = gql`
  type Query {
    hello: String
  }
`

const resolvers = {
  Query: {
    hello: () => `Hello World!`,
  },
}

const schema = makeExecutableSchema({ resolvers, typeDefs })

Deno.serve({
  port: 3000,
  onListen({ hostname, port }) {
    console.log(`☁  Started on http://${hostname}:${port}`)
  },
}, async (req) => {
  const { pathname } = new URL(req.url)
  return pathname === '/graphql'
    ? await GraphQLHTTP<Request>({
      schema,
      graphiql: true,
    })(req)
    : new Response('Not Found', { status: 404 })
})

Then run:

$ curl -X POST localhost:3000/graphql -d '{ "query": "{ hello }" }' -H "Content-Type: application/json"
{
  "data": {
    "hello": "Hello World!"
  }
}

Or in the GraphQL Playground:

image

관련 프로젝트 살펴보기

불러오는 중…