Skip to content
المشاريع

حول

☁ Universal GraphQL HTTP middleware for Deno and Bun

تطوير الويب والتطبيقات

كيف تُقاس هذه الأرقام

ما يمكنك فعله

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

النمو المقاس للنجوم

خلال 24 ساعة
٠
خلال 7 أيام
٠
خلال 15 يومًا
٠
خلال شهر
جارٍ جمع السجل

تغيّر صافي النجوم خلال فترات متداخلة، وليس مجموعًا يوميًا. تبقى القياسات المفقودة فارغة. النجوم تقيس الاهتمام لا جودة البرمجيات.

README.md

الأصل


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

استكشف مشاريع مشابهة ومرتبطة

جارٍ التحميل…