Skip to content
master
Switch branches/tags
Code

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
Aug 28, 2021
Mar 23, 2021
Mar 13, 2021
Sep 22, 2021
Mar 13, 2021


nest badge GitHub Workflow Status Codecov

gql

Universal GraphQL HTTP middleware for Deno.

Features

Donate

DEV

🎁 FIRST 10 PATRONS WILL RECEIVE BONUS 5 DEV 🎁

Reward status: waiting for gas fees to get at least to 20-25 gwei

  • 0xB3ebEe9d3E0bad437B75f4678D390c0d9608daF5 [pending]
  • 0xAb0658c66670d93BF47B4b8D5797edD0a60F43A0 [pending]

The best way to support the project is to do staking on stakes.social. Note that you also get rewarded by staking, as well as the project author.

Get started

Vanilla

The simplest setup with std/http:

import { Server } from 'https://deno.land/std@0.107.0/http/server.ts'
import { GraphQLHTTP } from '../mod.ts'
import { makeExecutableSchema } from 'https://deno.land/x/graphql_tools@0.0.2/mod.ts'
import { gql } from 'https://deno.land/x/graphql_tag@0.0.1/mod.ts'

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

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

const s = new Server({
  handler: async (req) => {
    const { pathname } = new URL(req.url)

    return pathname === '/graphql'
      ? await GraphQLHTTP<Request>({
          schema: makeExecutableSchema({ resolvers, typeDefs }),
          graphiql: true
        })(req)
      : new Response('Not Found', { status: 404 })
  },
  addr: ':3000'
})

s.listenAndServe()

Then run:

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

Or in GraphQL Playground:

image