Skip to content

Releases: deno-libs/gql

3.0.1

17 Jul 23:48
Compare
Choose a tag to compare
  • move to JSR
  • bump std
  • mention support for Bun

Full Changelog: 2.0.2...3.0.1

2.0.2

31 Mar 13:07
Compare
Choose a tag to compare
bump deps

2.0.1

04 Jan 11:45
Compare
Choose a tag to compare
bump std

2.0.0

09 Nov 12:38
f308841
Compare
Choose a tag to compare

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/gql@2.0.0/mod.ts'
import { makeExecutableSchema } from 'npm:@graphql-tools/schema@10.0.0'
import { gql } from 'https://deno.land/x/graphql_tag@0.1.2/mod.ts'
import type { Request as GQLRequest } from 'npm:graphql-http@1.22.0'

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

Use `npm:` specifiers instead of ESM CDN

01 Aug 16:28
Compare
Choose a tag to compare
1.2.4

update readme example

1.2.3

21 Apr 15:42
Compare
Choose a tag to compare
remove `target=deno` causing dep conflicts and bump examples

1.2.2

18 Apr 20:30
025e3ac
Compare
Choose a tag to compare
Update README.md

1.2.1

15 Mar 09:57
Compare
Choose a tag to compare
update examples & readme

1.2.0

28 Jan 16:44
Compare
Choose a tag to compare
fix badge and eggs publish

1.1.2

13 Jul 13:32
Compare
Choose a tag to compare
move all types to types.ts, bump deps, remove tinyhttp example