Socket
Socket
Sign inDemoInstall

@graphiql/toolkit

Package Overview
Dependencies
Maintainers
2
Versions
90
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@graphiql/toolkit - npm Package Compare versions

Comparing version 0.3.1 to 0.3.2

6

CHANGELOG.md
# @graphiql/toolkit
## 0.3.2
### Patch Changes
- [`86795d5f`](https://github.com/graphql/graphiql/commit/86795d5ffa2d3e6c8aee74f761d02f054b428d46) Thanks [@acao](https://github.com/acao)! - Remove bad type definition from `subscriptions-transport-ws` #1992 closes #1989
## 0.3.1

@@ -4,0 +10,0 @@

7

dist/create-fetcher/lib.js

@@ -212,10 +212,11 @@ "use strict";

}
if (options.legacyClient) {
return exports.createLegacyWebsocketsFetcher(options.legacyClient);
}
if (options.subscriptionUrl) {
return exports.createWebsocketsFetcherFromUrl(options.subscriptionUrl, options.wsConnectionParams);
}
var legacyWebsocketsClient = options.legacyClient || options.legacyWsClient;
if (legacyWebsocketsClient) {
return exports.createLegacyWebsocketsFetcher(legacyWebsocketsClient);
}
};
exports.getWsFetcher = getWsFetcher;
//# sourceMappingURL=lib.js.map
import type { DocumentNode, IntrospectionQuery } from 'graphql';
import type { Client, ClientOptions } from 'graphql-ws';
import type { SubscriptionClient } from 'subscriptions-transport-ws';
export declare type Observable<T> = {

@@ -49,3 +48,2 @@ subscribe(opts: {

export declare type Fetcher = (graphQLParams: FetcherParams, opts?: FetcherOpts) => FetcherReturnType;
export declare type WebsocketsClient = Client | SubscriptionClient;
export interface CreateFetcherOptions {

@@ -55,3 +53,4 @@ url: string;

wsClient?: Client;
legacyClient?: SubscriptionClient;
legacyWsClient?: any;
legacyClient?: any;
headers?: Record<string, string>;

@@ -58,0 +57,0 @@ wsConnectionParams?: ClientOptions['connectionParams'];

## Create Fetcher
a utility for generating a full-featured `fetcher` for GraphiQL including `@stream`, `@defer` `IncrementalDelivery`and `multipart`
a utility for generating a full-featured `fetcher` for GraphiQL including `@stream`, `@defer` `IncrementalDelivery`and `multipart` and subscriptions using `graphql-ws` or the legacy websockets protocol
under the hood, it uses [`graphql-ws`](https://www.npmjs.com/package/graphql-ws) and [`meros`](https://www.npmjs.com/package/meros) which act as client reference implementations of the [GraphQL over HTTP Working Group Spec](https://github.com/graphql/graphql-over-http) specification, and the most popular transport spec proposals
under the hood, it uses [`graphql-ws`](https://www.npmjs.com/package/graphql-ws) client and [`meros`](https://www.npmjs.com/package/meros) which act as client reference implementations of the [GraphQL over HTTP Working Group Spec](https://github.com/graphql/graphql-over-http) specification, and the most popular transport spec proposals

@@ -13,4 +13,2 @@ ### Setup

npm
```bash

@@ -20,4 +18,2 @@ npm install --save @graphiql/toolkit

yarn
```bash

@@ -31,5 +27,5 @@ yarn add @graphiql/toolkit

#### HTTP/Multipart Usage
#### Default HTTP/Multipart IncrementalDelivery Usage
Here's a simple example. In this case, a websocket client isn't even initialized, only http (with multipart `@stream` and `@defer` support of course!).
Here's a simple example. In this case, a websocket client isn't even initialized, only http (with multipart `@stream` and `@defer` Incremental Delivery support of course!).

@@ -51,5 +47,5 @@ ```ts

#### HTTP/Multipart & Websockets
#### Adding Websockets
Just by providing the `subscriptionUrl`, you can generate a `graphql-ws` client
Just by providing the `subscriptionUrl`, you can also generate a `graphql-ws` client. This client now supports both HTTP/Multipart Incremental Delivery for `@defer` and `@stream`, _and_ websockets subscriptions

@@ -76,3 +72,3 @@ ```ts

You can further customize the `wsClient` implementation below
You can further customize the `graphql-ws` implementation by creating a custom client instance and providing it as the `wsClient` parameter

@@ -93,5 +89,5 @@ ### Options

#### `legacyClient`
#### `legacyWsClient` or `legacyClient`
provide a legacy subscriptions client. bypasses `subscriptionUrl`. In theory, this could be any client using any transport, as long as it matches `subscriptions-transport-ws` `Client` signature.
provide a legacy subscriptions client using `subscriptions-transport-ws` protocol. bypasses `subscriptionUrl`. In theory, this could be any client using any transport, as long as it matches `subscriptions-transport-ws` `Client` signature.

@@ -108,3 +104,3 @@ #### `headers`

#### Custom `wsClient` Example
#### Custom `wsClient` Example using `graphql-ws`

@@ -139,2 +135,4 @@ Just by providing the `wsClient`

(not reccomended)
By providing the `legacyClient` you can support a `subscriptions-transport-ws` client implementation, or equivalent

@@ -155,3 +153,3 @@

url,
legacyClient: new SubscriptionsClient(subscriptionUrl),
legacyWsClient: new SubscriptionsClient(subscriptionUrl),
});

@@ -164,2 +162,14 @@

you will need to install the client seperately:
```bash
yarn add subscriptions-transport-ws
```
```bash
npm install --save subscriptions-transport-ws
```
and instantiate a client instance following their readme, and pass it as `legacyWsClient`.
#### Custom `fetcher` Example

@@ -166,0 +176,0 @@

@@ -119,9 +119,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

}
if (options.legacyClient) {
return createLegacyWebsocketsFetcher(options.legacyClient);
}
if (options.subscriptionUrl) {
return createWebsocketsFetcherFromUrl(options.subscriptionUrl, options.wsConnectionParams);
}
const legacyWebsocketsClient = options.legacyClient || options.legacyWsClient;
if (legacyWebsocketsClient) {
return createLegacyWebsocketsFetcher(legacyWebsocketsClient);
}
};
//# sourceMappingURL=lib.js.map
import type { DocumentNode, IntrospectionQuery } from 'graphql';
import type { Client, ClientOptions } from 'graphql-ws';
import type { SubscriptionClient } from 'subscriptions-transport-ws';
export declare type Observable<T> = {

@@ -49,3 +48,2 @@ subscribe(opts: {

export declare type Fetcher = (graphQLParams: FetcherParams, opts?: FetcherOpts) => FetcherReturnType;
export declare type WebsocketsClient = Client | SubscriptionClient;
export interface CreateFetcherOptions {

@@ -55,3 +53,4 @@ url: string;

wsClient?: Client;
legacyClient?: SubscriptionClient;
legacyWsClient?: any;
legacyClient?: any;
headers?: Record<string, string>;

@@ -58,0 +57,0 @@ wsConnectionParams?: ClientOptions['connectionParams'];

{
"name": "@graphiql/toolkit",
"version": "0.3.1",
"version": "0.3.2",
"description": "Utility to build a fetcher for GraphiQL",

@@ -5,0 +5,0 @@ "contributors": [

@@ -11,3 +11,3 @@ [Discord Channel](https://discord.gg/NP5vbPeUFp)

- **`createFetcher` [(Docs)](./docs/create-fetcher.md)** : a utility for creating a `fetcher` prop implementation for HTTP GET, POST including multipart, websockets fetcher
- **[`createFetcher`](./docs/create-fetcher.md)** : a utility for creating a `fetcher` prop implementation for HTTP GET, POST including multipart, websockets fetcher
- more to come!

@@ -14,0 +14,0 @@

@@ -118,2 +118,9 @@ import { DocumentNode, visit, GraphQLError } from 'graphql';

/**
* Allow legacy websockets protocol client, but no definitions for it,
* as the library is deprecated and has security issues
*
* @param legacyWsClient
* @returns
*/
export const createLegacyWebsocketsFetcher = (legacyWsClient: {

@@ -184,5 +191,2 @@ request: (params: FetcherParams) => unknown;

}
if (options.legacyClient) {
return createLegacyWebsocketsFetcher(options.legacyClient);
}
if (options.subscriptionUrl) {

@@ -194,2 +198,6 @@ return createWebsocketsFetcherFromUrl(

}
const legacyWebsocketsClient = options.legacyClient || options.legacyWsClient;
if (legacyWebsocketsClient) {
return createLegacyWebsocketsFetcher(legacyWebsocketsClient);
}
};
import type { DocumentNode, IntrospectionQuery } from 'graphql';
import type { Client, ClientOptions } from 'graphql-ws';
import type { SubscriptionClient } from 'subscriptions-transport-ws';

@@ -73,4 +72,2 @@ export type Observable<T> = {

export type WebsocketsClient = Client | SubscriptionClient;
/**

@@ -94,7 +91,11 @@ * Options for creating a simple, spec-compliant GraphiQL fetcher

/**
* `legacyClient` implementation that matches `subscriptions-transport-ws` signature,
* `legacyWsClient` implementation that matches `subscriptions-transport-ws` signature,
* whether via `new SubcriptionsClient()` itself or another client with a similar signature.
*/
legacyClient?: SubscriptionClient;
legacyWsClient?: any;
/**
* alias for `legacyWsClient`
*/
legacyClient?: any;
/**
* Headers you can provide statically.

@@ -101,0 +102,0 @@ *

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc