Skip to content

Latest commit

 

History

History
591 lines (329 loc) · 31 KB

CHANGELOG.md

File metadata and controls

591 lines (329 loc) · 31 KB

4.2.3 (2021-03-23)

Bug Fixes

  • client: Reduce WebSocket event listeners and add new client message event (#104) (68d0e20), closes #102

4.2.2 (2021-03-17)

Bug Fixes

  • server: return instead of break at switch case ends (e9447e4), closes #140

4.2.1 (2021-03-11)

Bug Fixes

  • client: New error event listener for handling connection errors (#136) (127b69f), closes #135

4.2.0 (2021-02-25)

Bug Fixes

  • Only UMD build has side effects (66ed43f)

Features

  • client: isFatalConnectionProblem option for deciding if the connect error should be immediately reported or the connection retried (#126) (8115871), closes #122

4.1.6 (2021-02-18)

Bug Fixes

4.1.5 (2021-02-12)

Bug Fixes

  • Main entrypoint in exports is just "." (8f70b02)

4.1.4 (2021-02-12)

Bug Fixes

  • Define entry points through the exports field and use .mjs suffixed ESM imports (#110) (4196238)

4.1.3 (2021-02-08)

Bug Fixes

  • client: Should emit closed event when disposing (5800de8), closes #108
  • client: Shouldn’t send the Complete message if socket is not open (cd12024)

4.1.2 (2021-01-24)

Bug Fixes

4.1.1 (2021-01-19)

Bug Fixes

  • client: Export relevant elements from the browser bundle (b106dbe), closes #97
  • client: Wait for server acknowledgement indefinitely (a4bd602), closes #98

4.1.0 (2021-01-13)

Bug Fixes

  • server: onDisconnect is called exclusively if the connection is acknowledged (33ed5f2)

Features

  • server: Add onClose callback for closures at any point in time (dd0d4fa)

4.0.0 (2021-01-13)

Bug Fixes

  • server: Client can complete/cancel any operation (0ad1c4c)
  • server: Enforce ID uniqueness across all operations and during the whole subscription life (#96) (65d1bfa)

Features

  • server: Add onDisconnect callback (#94) (2a61268)
  • server: Log a warning for unsupported subprotocols (88a12ef), closes #92

BREAKING CHANGES

  • server: The return function of server.opened (closed) now requires the close event code and reason for reporting to the onDisconnect callback.
  • server: The Context.subscriptions record value can be either an AsyncIterator or a Promise.

3.2.0 (2020-12-17)

Features

3.1.0 (2020-12-11)

Bug Fixes

  • client: Time retries and socket change waits (7c707db), closes #85

Features

  • client: onNonLazyError allows you to catch errors reported in non-lazy mode (cd1e7df)

3.0.2 (2020-12-10)

Bug Fixes

  • client: No retries when disposed (0d5e6c2)

3.0.1 (2020-12-10)

Performance Improvements

  • client: Await timeouts only in recursive connects (55c8fc8)

3.0.0 (2020-12-09)

Features

  • client: Retry with randomised exponential backoff or provide your own strategy (#84) (d3e7a17)

BREAKING CHANGES

  • client: Client retryTimeout option has been replaced with the new retryWait.

retryWait allows you to control the retry timeout strategy by resolving the returned promise when ready. The default implements the randomised exponential backoff like so:

// this is the default
const retryWait = async function randomisedExponentialBackoff(retries: number) {
  let retryDelay = 1000; // start with 1s delay
  for (let i = 0; i < retries; i++) {
    retryDelay *= 2; // square `retries` times
  }
  await new Promise((resolve) =>
    setTimeout(
      // resolve pending promise with added random timeout from 300ms to 3s
      resolve,
      retryDelay + Math.floor(Math.random() * (3000 - 300) + 300),
    ),
  );
};

2.0.1 (2020-12-03)

Bug Fixes

  • client: Close event's wasClean is not necessary (2c65f0e), closes #81

2.0.0 (2020-11-20)

Features

BREAKING CHANGES

  • server: You now "make" a ready-to-use server that can be used with any WebSocket implementation!

Summary of breaking changes:

  • No more keepAlive. The user should provide its own keep-alive implementation. (I highly recommend WebSocket Ping and Pongs)
  • No more HTTP request in the server context.
  • No more WebSocket in the server context (you're the one that creates it).
  • You use your own WebSocket server
  • Server exports only makeServer (no more createServer)

Benefits

  • You're responsible for the server (any optimisation or adjustment can be applied)
  • Any WebSocket server can be used (or even mocked if necessary)
  • You control the disposal of the server (close or transfer clients however you wish)
  • New extra field in the Context for storing custom values useful for callbacks
  • Full control of authentication flow
  • Full control over error handling
  • True zero-dependency

Migrating from v1

Only the server has to be migrated. Since this release allows you to use your favourite WebSocket library (or your own implementation), using ws is just one way of using graphql-ws. This is how to use the implementation shipped with the lib:

/**
 * ❌ instead of the lib creating a WebSocket server internally with the provided arguments
 */
import https from 'https';
import { createServer } from 'graphql-ws';

const server = https.createServer(...);

createServer(
  {
    onConnect(ctx) {
      // were previously directly on the context
      ctx.request as IncomingRequest
      ctx.socket as WebSocket
    },
    ...rest,
  },
  {
    server,
    path: '/graphql',
  },
);

/**
 * ✅ you have to supply the server yourself
 */
import https from 'https';
import ws from 'ws'; // yarn add ws
import { useServer } from 'graphql-ws/lib/use/ws'; // notice the import path

const server = https.createServer(...);
const wsServer = new ws.Server({
  server,
  path: '/graphql',
});

useServer(
  {
    onConnect(ctx) {
      // are now in the `extra` field
      ctx.extra.request as IncomingRequest
      ctx.extra.socket as WebSocket
    },
    ...rest,
  },
  wsServer,
  // optional keepAlive with ping pongs (defaults to 12 seconds)
);

1.14.0 (2020-11-15)

Features

  • server: context may return a promise (cd5c2f8), closes #74

1.13.1 (2020-11-14)

Bug Fixes

  • client: Some close events are not worth retrying (4d9134b)
  • message: Allow data field to be of any type (533248e), closes #72
  • message: Allow payload field to be of any type for NextMessage (7cebbfe), closes #72
  • Use ID type for message id field (87ebd35)

1.13.0 (2020-11-12)

Bug Fixes

  • client: One cleanup per subscription (#67) (5a5ae4d)
  • Stop sending messages after receiving complete (#65) (3f4f836)

Features

  • client: connectionParams may return a promise (#71) (33f210c)
  • client: Allow keeping the connection alive for some time before lazy closing (#69) (555c2c3)

1.12.0 (2020-11-07)

Bug Fixes

  • client: Close with error message during connecting issues (f8ecdd7)

Features

  • Send optional payload with the ConnectionAck message (#60) (1327e77)

1.11.0 (2020-11-04)

Bug Fixes

  • Node 10 is the min supported version (19844d7)
  • Support more graphql versions (de69b4e)
  • server: Close socket if onSubscribe returns invalid array (#53) (0464a54)
  • server: Consistently set rootValue and contextValue, if not overridden (#49) (7aa3bcd)
  • server: Distribute server error to all clients even if one error listener throws (#56) (b96dbb9)
  • server: Don't surface bad request error details in production (#55) (70317b2)

Features

  • cjs, esm and umd builds with minification and compression for the browser (#58) (ebb8dfe)

Performance Improvements

  • Reduce runtime prototype traversal for hasOwnProperty (#52) (1bb9218)

1.10.0 (2020-11-03)

Features

  • Subscribe message query must be a string (#45) (60d9cd5)
  • server: For dynamic usage, context option can be a function too (#46) (149b582)

1.9.3 (2020-10-31)

Bug Fixes

  • Drop TypeScript DOM lib dependency (a81e8c1)
  • Support more Node versions by not using globalThis (79c2ed2)

1.9.2 (2020-10-31)

Bug Fixes

  • server: Make sure to use onSubscribe result exclusively (51fdb7c)
  • Export useful types (e4cc4d4)
  • client: Accept nullish values for operationName and variables (2d60dda)

1.9.1 (2020-10-25)

Features

  • Package rename graphql-transport-ws 👉 graphql-ws. (#43)

1.9.0 (2020-10-24)

⚠️ Deprecated

Package has been renamed from graphql-transport-ws to graphql-ws.

Features

  • server: More callbacks, clearer differences and higher extensibility (#40) (507a222)

BREAKING CHANGES

Should've been a major release but semantic-release didn't detect the breaking changes of the 507a222 commit, so here we are...

This time we come with a few breaking changes that will open doors for all sorts of enhancements. Check the linked PR for more details.

Server option onSubscribe

  • Now executes before any other subscribe message processing
  • Now takes 2 arguments, the Context and the SubscribeMessage
  • Now returns nothing,ExecutionArgs or an array of GraphQLErrors
    • Returning void (or nothing) will leave the execution args preparation and validation to the library
    • Returned ExecutionArgs will be used directly for the GraphQL operation execution (preparations and validation should be done by you in this case)
    • Returned array of GraphQLErrors will be reported to the client through the ErrorMessage

Server option validationRules

Dropped in favour of applying custom validation rules in the onSubscribe callback. Find the recipe in the readme!

Server option formatExecutionResult

Dropped in favour of using the return value of onNext callback.

1.8.2 (2020-10-22)

⚠️ Deprecated

Package has been renamed from graphql-transport-ws to graphql-ws.

Bug Fixes

  • server: No need to bind this scope (f76ac73)

1.8.1 (2020-10-22)

⚠️ Deprecated

Package has been renamed from graphql-transport-ws to graphql-ws.

Bug Fixes

  • yarn engine is not required (#34) (89484b8)
  • server: Hide internal server error messages from the client in production (36fe405), closes #31

1.8.0 (2020-10-19)

⚠️ Deprecated

Package has been renamed from graphql-transport-ws to graphql-ws.

Features

  • server: Support returning multiple results from execute (#28) (dbbd88b)

1.7.0 (2020-10-01)

⚠️ Deprecated

Package has been renamed from graphql-transport-ws to graphql-ws.

Bug Fixes

  • client: Dispose of subscription on complete or error messages (#23) (fb4d8e9)
  • server: subscription operations are distinct on the message ID (#24) (dfffb05)

Features

  • client: Optional generateID to provide subscription IDs (#22) (9a3f54a), closes #21

1.6.0 (2020-09-28)

⚠️ Deprecated

Package has been renamed from graphql-transport-ws to graphql-ws.

Features

  • client: Support providing custom WebSocket implementations (#18) (1515fe2)

1.5.0 (2020-09-18)

⚠️ Deprecated

Package has been renamed from graphql-transport-ws to graphql-ws.

Bug Fixes

  • server: Use subscribe from the config (6fbd47c)

Features

  • server: Define execution/subscription context in creation options (5b3d253), closes #13

1.4.2 (2020-09-16)

⚠️ Deprecated

Package has been renamed from graphql-transport-ws to graphql-ws.

Bug Fixes

  • server: Receiving more than one ConnectionInit message closes the socket immediately (757c6e9)

1.4.1 (2020-09-11)

⚠️ Deprecated

Package has been renamed from graphql-transport-ws to graphql-ws.

Performance Improvements

  • client: Memoize message parsing for each subscriber (2a7ba46)

1.4.0 (2020-09-10)

⚠️ Deprecated

Package has been renamed from graphql-transport-ws to graphql-ws.

Bug Fixes

  • client: Only query is required in the subscribe payload (e892530)

Features

  • server: Pass roots for operation fields as an option (dcb5ed4)

1.3.0 (2020-09-10)

⚠️ Deprecated

Package has been renamed from graphql-transport-ws to graphql-ws.

Features

  • WebSocket Ping and Pong as keep-alive (#11) (16ae316)
  • client: Emit events for connecting, connected and closed (627775b)
  • client: Implement silent-reconnects (c6f7872), closes #7
  • client: Lazy option can be changed (fb0ec14)

1.2.0 (2020-09-04)

⚠️ Deprecated

Package has been renamed from graphql-transport-ws to graphql-ws.

Features

  • Package rename @enisdenjo/graphql-transport-ws 👉 graphql-transport-ws. (494f676)

1.1.1 (2020-08-28)

⚠️ Deprecated

Package has been renamed from graphql-transport-ws to graphql-ws.

Bug Fixes

  • add the sink to the subscribed map AFTER emitting a subscribe message (814f46c)
  • notify only relevant sinks about errors or completions (62155ba)

1.1.0 (2020-08-28)

⚠️ Deprecated

Package has been renamed from graphql-transport-ws to graphql-ws.

Bug Fixes

  • server: allow skipping init message wait with zero values (a7419df)
  • server: use subscription specific formatter for queries and mutations too (5672a04)

Features

  • client: introduce Socky 🧦 - the nifty internal socket state manager (#8) (a4bee6f)

1.0.2 (2020-08-26)

⚠️ Deprecated

Package has been renamed from graphql-transport-ws to graphql-ws.

Bug Fixes

  • correctly detect WebSocket server (eab29dc)

1.0.1 (2020-08-26)

⚠️ Deprecated

Package has been renamed from graphql-transport-ws to graphql-ws.

Bug Fixes

  • reset connected/connecting state when disconnecting and disposing (2eb3cd5)
  • client: cant read the CloseEvent.reason after bundling so just pass the whole event to the sink error and let the user handle it (9ccb46b)
  • client: send complete message and close only if socket is still open (49b75ce)
  • http and ws have no default exports (5c01ed9)
  • include types file holding important types (f3e4edf)
  • server: scoped execution result formatter from onConnect (f91fadb)
  • export both the client and the server from index (29923b1)
  • server: store the intial request in the context (6927ee0)

1.0.0 (2020-08-17)

⚠️ Deprecated

Package has been renamed from graphql-transport-ws to graphql-ws.

Features

  • client: Re-implement following the new transport protocol (#6) (5191a35)
  • server: Implement following the new transport protocol (#1) (a412d25)
  • Rewrite GraphQL over WebSocket Protocol (#2) (42045c5)

BREAKING CHANGES