Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/deno-libs/gql
☁ Universal GraphQL HTTP middleware for Deno and Bun
https://github.com/deno-libs/gql
bun deno graphql graphql-api graphql-server
Last synced: 2 days ago
JSON representation
☁ Universal GraphQL HTTP middleware for Deno and Bun
- Host: GitHub
- URL: https://github.com/deno-libs/gql
- Owner: deno-libs
- License: mit
- Created: 2021-03-13T19:09:43.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2024-07-17T23:48:47.000Z (5 months ago)
- Last Synced: 2024-11-15T12:52:19.192Z (28 days ago)
- Topics: bun, deno, graphql, graphql-api, graphql-server
- Language: TypeScript
- Homepage: https://jsr.io/@deno-libs/gql
- Size: 219 KB
- Stars: 194
- Watchers: 5
- Forks: 10
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Audit: audit_test.ts
Awesome Lists containing this project
- awesome-graphql - gql - Universal GraphQL HTTP middleware for Deno. (Implementations / JavaScript/TypeScript)
- awesome-list - gql - libs | 94 | (TypeScript)
- awesome-deno - gql - Universal GraphQL HTTP middleware. (Modules / Web utils)
README
[![nest badge][nest-badge]](https://nest.land/package/gql)
[![GitHub Workflow Status][gh-actions-img]][github-actions]
[![Codecov][cov-badge]][cov] [![][docs-badge]][docs]
[![][code-quality-img]][code-quality]# gql
Universal and spec-compliant [GraphQL](https://www.graphql.com/) HTTP middleware
for Deno and Bun. Based on [graphql-http](https://github.com/graphql/graphql-http).## Features
- ✨ Works with `Deno.serve`, `Bun.serve` and [oak](https://github.com/oakserver/oak)
- ⚡
[GraphQL Playground](https://github.com/graphql/graphql-playground/tree/master/packages/graphql-playground-html)
integration (via `graphiql: true`)## Get started
The simplest setup with `Deno.serve`:
```ts
import { GraphQLHTTP } from 'jsr:@deno-libs/[email protected]/mod.ts'
import { makeExecutableSchema } from 'npm:@graphql-tools/[email protected]'
import { gql } from 'https://deno.land/x/[email protected]/mod.ts'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({
schema,
graphiql: true,
})(req)
: new Response('Not Found', { status: 404 })
})
```Then run:
```sh
$ curl -X POST localhost:3000/graphql -d '{ "query": "{ hello }" }' -H "Content-Type: application/json"
{
"data": {
"hello": "Hello World!"
}
}
```Or in the GraphQL Playground:
![image](https://user-images.githubusercontent.com/35937217/112218821-4133c800-8c35-11eb-984a-5c21fa71c229.png)
[docs-badge]: https://img.shields.io/github/v/release/deno-libs/gql?label=Docs&logo=deno&style=for-the-badge&color=DD3FAA
[docs]: https://doc.deno.land/https/deno.land/x/gql/mod.ts
[gh-actions-img]: https://img.shields.io/github/actions/workflow/status/deno-libs/gql/main.yml?branch=master&style=for-the-badge&logo=github&label=&color=DD3FAA&
[github-actions]: https://github.com/deno-libs/gql/actions
[cov]: https://coveralls.io/github/deno-libs/gql
[cov-badge]: https://img.shields.io/coveralls/github/deno-libs/gql?style=for-the-badge&color=DD3FAA
[nest-badge]: https://img.shields.io/badge/publushed%20on-nest.land-DD3FAA?style=for-the-badge
[code-quality-img]: https://img.shields.io/codefactor/grade/github/deno-libs/gql?style=for-the-badge&color=DD3FAA
[code-quality]: https://www.codefactor.io/repository/github/deno-libs/gql