Skip to content

Releases: enisdenjo/graphql-ws

v5.14.2

23 Oct 14:52
Compare
Choose a tag to compare

5.14.2 (2023-10-23)

Bug Fixes

  • client: correct close code for Bad Gateway reason (#512) (0438650)

v5.14.1

28 Sep 18:05
Compare
Choose a tag to compare

5.14.1 (2023-09-28)

Bug Fixes

  • server: Acknowledge connection before notifying the client to avoid race conditions with slow sends (#506) (8cb82bd), closes #501

v5.14.0

22 Jun 12:26
Compare
Choose a tag to compare

5.14.0 (2023-06-22)

Features

  • client: Async iterator for subscriptions (#486) (fb4b967)

Examples

Use the client

import { createClient } from 'graphql-ws';

const client = createClient({
  url: 'ws://localhost:4000/graphql',
});

// query
(async () => {
  const query = client.iterate({
    query: '{ hello }',
  });

  const { value } = await query.next();
  expect(value).toEqual({ hello: 'world' });
})();

// subscription
(async () => {
  const subscription = client.iterate({
    query: 'subscription { greetings }',
  });

  for await (const event of subscription) {
    expect(event).toEqual({ greetings: 'Hi' });

    // complete a running subscription by breaking the iterator loop
    break;
  }
})();

v5.13.1

15 May 11:50
Compare
Choose a tag to compare

5.13.1 (2023-05-15)

Bug Fixes

  • Remove unnecessary bun-types directives (e9a56f7), closes #478

v5.13.0

12 May 11:31
Compare
Choose a tag to compare

5.13.0 (2023-05-12)

Features

Examples

Start the server with Bun

import { makeHandler, handleProtocols } from 'graphql-ws/lib/use/lib/bun';
import { schema } from './previous-step';

Bun.serve({
  fetch(req, server) {
    const [path, _search] = req.url.split('?');
    if (!path.endsWith('/graphql')) {
      return new Response('Not Found', { status: 404 });
    }
    if (req.headers.get('upgrade') != 'websocket') {
      return new Response('Upgrade Required', { status: 426 });
    }
    if (handleProtocols(req.headers.get('sec-websocket-protocol') || '')) {
      return new Response('Bad Request', { status: 404 });
    }
    if (!server.upgrade(req)) {
      return new Response('Internal Server Error', { status: 500 });
    }
    return new Response();
  },
  websocket: makeHandler({ schema }),
  port: 4000,
});

console.log('Listening to port 4000');

Start the server with Deno

import { serve } from 'https://deno.land/std/http/mod.ts';
import {
  makeHandler,
  GRAPHQL_TRANSPORT_WS_PROTOCOL,
} from 'https://esm.sh/graphql-ws/lib/use/deno';
import { schema } from './previous-step.ts';

const handler = makeHandler({ schema });

serve(
  (req: Request) => {
    const [path, _search] = req.url.split('?');
    if (!path.endsWith('/graphql')) {
      return new Response('Not Found', { status: 404 });
    }
    if (req.headers.get('upgrade') != 'websocket') {
      return new Response('Upgrade Required', { status: 426 });
    }
    const { socket, response } = Deno.upgradeWebSocket(req, {
      protocol: GRAPHQL_TRANSPORT_WS_PROTOCOL,
      idleTimeout: 12_000,
    });
    handler(socket);
    return response;
  },
  { port: 4000 },
);

v5.12.1

31 Mar 12:22
Compare
Choose a tag to compare

5.12.1 (2023-03-31)

Bug Fixes

  • Add file extensions to imports/exports in ESM type definitions (48775be)

v5.12.0

06 Mar 01:40
Compare
Choose a tag to compare

5.12.0 (2023-03-06)

Features

v5.11.3

01 Feb 15:22
Compare
Choose a tag to compare

5.11.3 (2023-02-01)

Bug Fixes

  • ws,uWebSockets,@fastify/websocket: Handle internal errors that are not instances of Error (#442) (9884889), closes #441

v5.11.2

21 Sep 19:44
Compare
Choose a tag to compare

5.11.2 (2022-09-21)

Bug Fixes

  • Reorder types paths in package.json for better import resolution (#406) (37263c5)

v5.11.1

16 Sep 15:19
Compare
Choose a tag to compare

5.11.1 (2022-09-16)

Bug Fixes

  • server: Shouldn't send a complete message if client sent it (331fe47), closes #403