gql

☁ Universal GraphQL HTTP middleware for Deno and Bun

MIT License

Stars
193
Committers
4

Bot releases are visible (Hide)

gql - 3.0.1 Latest Release

Published by talentlessguy 3 months ago

  • move to JSR
  • bump std
  • mention support for Bun

Full Changelog: https://github.com/deno-libs/gql/compare/2.0.2...3.0.1

gql -

Published by talentlessguy 7 months ago

gql -

Published by talentlessguy 10 months ago

gql - 2.0.0

Published by talentlessguy 12 months ago

A re-write of gql to fully comply with GraphQL-over-HTTP spec, based on graphql-http.

Breaking Changes

  • runHttpQuery is removed. Query handling logic is now handled fully by graphql-http.
  • GQLParams is removed. Use graphql-http Request type instead.
  • request type text/plain is no longer a valid. Use application/json instead

New Features

  • All of the configuration for GraphQL-over-HTTP (for example validationRules) is now available for gql.
  • New GraphQLHTTP function argument - reqCtx. Use it to modify the request context for GraphQL Request object.

Example:

import { GraphQLHTTP } from 'https://deno.land/x/[email protected]/mod.ts'
import { makeExecutableSchema } from 'npm:@graphql-tools/[email protected]'
import { gql } from 'https://deno.land/x/[email protected]/mod.ts'
import type { Request as GQLRequest } from 'npm:[email protected]'

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

type ReqContext = {
  request: Request
  isRequestContext: boolean
}

type Context = {
  request: Request
  originalReq: GQLRequest<Request, ReqContext>
}

const resolvers = {
  Query: {
    hello: (_root: unknown, _args: unknown, ctx: Context) => {
      return `Hello from request context: ${ctx.originalReq.context.isRequestContext}`
    },
  },
}

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, Context, ReqContext>({
      schema,
      graphiql: true,
      context: (request) => ({ request: req, originalReq: request }),
    }, () => ({ request: req, isRequestContext: true }))(req)
    : new Response('Not Found', { status: 404 })
})

Misc

  • Added GraphQL-over-HTTP compliance tests (100% compliance)
  • Bumped GraphQL from 16.6 to 16.8.1
gql - Use `npm:` specifiers instead of ESM CDN

Published by talentlessguy about 1 year ago

gql -

Published by talentlessguy over 1 year ago

gql -

Published by talentlessguy over 1 year ago

gql -

Published by talentlessguy over 1 year ago

gql -

Published by talentlessguy over 1 year ago

gql -

Published by talentlessguy over 2 years ago

gql -

Published by talentlessguy over 2 years ago

gql - 1.1.0: new option `playgroundOptions`

Published by talentlessguy about 3 years ago

v1.1 adds a new option to configure GraphQL Playground:

const app = GraphQLHTTP({
  graphiql: true,
  schema,
  rootValue,
  playgroundOptions: {
    cdnUrl: 'https://unpkg.com'
  }
})
gql - 1.0.0: use new `std/http` API

Published by talentlessguy about 3 years ago

The v1 version now supports new std/http API which is based on native HTTP server.

gql -

Published by talentlessguy about 3 years ago

gql -

Published by talentlessguy about 3 years ago

gql - v0.2: New property - `headers`

Published by talentlessguy about 3 years ago

You can now set custom HTTP headers for GraphQLHTTP handler:

GraphQLHTTP({ schema, headers: { Key: 'Value' } })
gql -

Published by talentlessguy about 3 years ago

gql -

Published by talentlessguy over 3 years ago

gql -

Published by talentlessguy over 3 years ago

gql -

Published by talentlessguy over 3 years ago

Package Rankings
Top 2.75% on Deno.land
Badges
Extracted from project README
nest badge GitHub Workflow Status Codecov
Related Projects