@graphiql/toolkit
Advanced tools
Comparing version 0.7.2-canary-ec0b9bc2.0 to 0.7.2
# @graphiql/toolkit | ||
## 0.7.2-canary-ec0b9bc2.0 | ||
## 0.7.2 | ||
### Patch Changes | ||
- [#2751](https://github.com/graphql/graphiql/pull/2751) [`9257d3ef`](https://github.com/graphql/graphiql/commit/9257d3ef903e63d71d2ddd8d2a20c3bf5f81e6df) Thanks [@thomasheyenbrock](https://github.com/thomasheyenbrock)! - Correctly handle `null` in type-guard functions for `Promise` and `Observable` | ||
- [#2753](https://github.com/graphql/graphiql/pull/2753) [`bfa90f24`](https://github.com/graphql/graphiql/commit/bfa90f249be4f68049c1bb81abfb524ae623313f) Thanks [@thomasheyenbrock](https://github.com/thomasheyenbrock)! - Mark the `graphql-ws` peer dependency as optional (as it's only needed when the fetcher needs to support subscriptions) | ||
* [#2751](https://github.com/graphql/graphiql/pull/2751) [`8ab5fcd0`](https://github.com/graphql/graphiql/commit/8ab5fcd0a8399a0f8eb1b569751dd0e8390b9679) Thanks [@thomasheyenbrock](https://github.com/thomasheyenbrock)! - Correctly handle `null` in type-guard functions for `Promise` and `Observable` | ||
## 0.7.1 | ||
@@ -10,0 +12,0 @@ |
@@ -1,13 +0,11 @@ | ||
## Create Fetcher | ||
# `createGraphiQLFetcher` | ||
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 | ||
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) 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 | ||
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. | ||
### Setup | ||
## Setup | ||
[`graphiql`](https://npmjs.com/package/graphiql) and thus `react` and `react-dom` should already be installed. | ||
You can install `@graphiql/toolkit` using your favorite package manager: | ||
you'll need to install `@graphiql/toolkit` | ||
```bash | ||
@@ -17,11 +15,7 @@ npm install --save @graphiql/toolkit | ||
```bash | ||
yarn add @graphiql/toolkit | ||
``` | ||
## Getting Started | ||
### Getting Started | ||
We have a few flexible options to get you started with the client. It's meant to cover the majority of common use cases with a simple encapsulation. | ||
#### Default HTTP/Multipart IncrementalDelivery Usage | ||
### Default HTTP/Multipart IncrementalDelivery Usage | ||
@@ -45,5 +39,5 @@ 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!). | ||
#### Adding `graphql-ws` websockets subscriptions | ||
### Adding `graphql-ws` websockets subscriptions | ||
first you'll need to install `graphql-ws` as a peer dependency: | ||
First you'll need to install `graphql-ws` as a peer dependency: | ||
@@ -54,8 +48,4 @@ ```bash | ||
```bash | ||
yarn add graphql-ws | ||
``` | ||
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. | ||
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 | ||
```ts | ||
@@ -81,21 +71,21 @@ import * as React from 'react'; | ||
You can further customize the `graphql-ws` implementation by creating a custom client instance and providing it as the `wsClient` parameter | ||
You can further customize the `graphql-ws` implementation by creating a custom client instance and providing it as the `wsClient` parameter. | ||
### Options | ||
## Options | ||
#### `url` (_required_) | ||
### `url` (_required_) | ||
This is url used for all `HTTP` requests, and for schema introspection. | ||
#### `subscriptionUrl` | ||
### `subscriptionUrl` | ||
This generates a `graphql-ws` client using the provided url. Note that a server must be compatible with the new `graphql-ws` subscriptions spec for this to work. | ||
#### `wsClient` | ||
### `wsClient` | ||
provide your own subscriptions client. bypasses `subscriptionUrl`. In theory, this could be any client using any transport, as long as it matches `graphql-ws` `Client` signature. | ||
Provide your own subscriptions client. Using this option bypasses `subscriptionUrl`. In theory, this could be any client using any transport, as long as it matches `graphql-ws` `Client` signature. | ||
### `wsConnectionParams` | ||
## `wsConnectionParams` | ||
provide your initial connection params. | ||
Provide your initial connection params. | ||
@@ -115,19 +105,19 @@ ```ts | ||
#### `legacyWsClient` or `legacyClient` | ||
### `legacyWsClient` or `legacyClient` | ||
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. | ||
Provide a legacy subscriptions client using `subscriptions-transport-ws` protocol. Using this option bypasses `subscriptionUrl`. In theory, this could be any client using any transport, as long as it matches `subscriptions-transport-ws` `Client` signature. | ||
#### `headers` | ||
### `headers` | ||
Pass headers to any and all requests | ||
Specify headers that will be passed to all requests. | ||
#### `fetch` | ||
### `fetch` | ||
Pass a custom fetch implementation such as `isomorphic-fetch` | ||
Pass a custom fetch implementation such as `isomorphic-fetch`. | ||
### Customization Examples | ||
## Customization Examples | ||
#### Custom `wsClient` Example using `graphql-ws` | ||
### Custom `wsClient` Example using `graphql-ws` | ||
Just by providing the `wsClient` | ||
This example passes a `graphql-ws` client to the `wsClient` option: | ||
@@ -158,7 +148,7 @@ ```ts | ||
#### Custom `legacyClient` Example | ||
### Custom `legacyClient` Example | ||
(not recommended) | ||
By providing the `legacyClient` you can support a `subscriptions-transport-ws` client implementation, or equivalent | ||
By providing the `legacyClient` you can support a `subscriptions-transport-ws` client implementation, or equivalent: | ||
@@ -186,18 +176,12 @@ ```ts | ||
you will need to install the client separately: | ||
Note that you will need to install the client separately: | ||
```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 | ||
#### Custom `fetcher` Example | ||
For SSR, we might want to use something like `isomorphic-fetch`: | ||
For SSR, we might want to use something like `isomorphic-fetch` | ||
```ts | ||
@@ -204,0 +188,0 @@ import * as React from 'react'; |
{ | ||
"name": "@graphiql/toolkit", | ||
"version": "0.7.2-canary-ec0b9bc2.0", | ||
"version": "0.7.2", | ||
"description": "Utility to build a fetcher for GraphiQL", | ||
@@ -36,2 +36,7 @@ "contributors": [ | ||
}, | ||
"peerDependenciesMeta": { | ||
"graphql-ws": { | ||
"optional": true | ||
} | ||
}, | ||
"keywords": [ | ||
@@ -38,0 +43,0 @@ "graphql", |
@@ -5,6 +5,4 @@ [Changelog](https://github.com/graphql/graphiql/blob/main/packages/graphql-toolkit/CHANGELOG.md) | [API Docs](https://graphiql-test.netlify.app/typedoc/modules/graphiql_toolkit.html) | [NPM](https://www.npmjs.com/package/@graphiql/toolkit) | [Discord](https://discord.gg/NP5vbPeUFp) | ||
General purpose library as a dependency of GraphiQL. | ||
This is a general purpose library for building GraphQL IDEs. It's being used by other packages like `graphiql` and `@graphiql/react` and also provides utilities that are useful when working with these packages. | ||
A core dependency of the GraphiQL 2.0.0 initiative. | ||
## Docs | ||
@@ -14,8 +12,1 @@ | ||
- more to come! | ||
## Todo | ||
- [x] Begin porting common type definitions used by GraphiQL and it's dependencies | ||
- [x] `createGraphiQLFetcher` utility for an easier `fetcher` | ||
- [ ] Migrate over general purpose `graphiql/src/utilities` | ||
- [ ] Utility to generate json schema spec from `getQueryFacts` for monaco, vscode, etc |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
299890
11