You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/graphiql-toolkit/README.md
+1-10Lines changed: 1 addition & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,18 +2,9 @@
2
2
3
3
# `@graphiql/toolkit`
4
4
5
-
General purpose library as a dependency of GraphiQL.
6
-
7
-
A core dependency of the GraphiQL 2.0.0 initiative.
5
+
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.
8
6
9
7
## Docs
10
8
11
9
-**[`createFetcher`](./docs/create-fetcher.md)** : a utility for creating a `fetcher` prop implementation for HTTP GET, POST including multipart, websockets fetcher
12
10
- more to come!
13
-
14
-
## Todo
15
-
16
-
-[x] Begin porting common type definitions used by GraphiQL and it's dependencies
17
-
-[x]`createGraphiQLFetcher` utility for an easier `fetcher`
18
-
-[ ] Migrate over general purpose `graphiql/src/utilities`
19
-
-[ ] Utility to generate json schema spec from `getQueryFacts` for monaco, vscode, etc
Copy file name to clipboardExpand all lines: packages/graphiql-toolkit/docs/create-fetcher.md
+32-48Lines changed: 32 additions & 48 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,28 +1,22 @@
1
-
## Create Fetcher
1
+
#`createGraphiQLFetcher`
2
2
3
-
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
3
+
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.
4
4
5
-
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
5
+
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.
6
6
7
-
###Setup
7
+
## Setup
8
8
9
-
[`graphiql`](https://npmjs.com/package/graphiql) and thus `react` and `react-dom` should already be installed.
10
-
11
-
you'll need to install `@graphiql/toolkit`
9
+
You can install `@graphiql/toolkit` using your favorite package manager:
12
10
13
11
```bash
14
12
npm install --save @graphiql/toolkit
15
13
```
16
14
17
-
```bash
18
-
yarn add @graphiql/toolkit
19
-
```
20
-
21
-
### Getting Started
15
+
## Getting Started
22
16
23
17
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.
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!).
first you'll need to install `graphql-ws` as a peer dependency:
40
+
First you'll need to install `graphql-ws` as a peer dependency:
47
41
48
42
```bash
49
43
npm install --save graphql-ws
50
44
```
51
45
52
-
```bash
53
-
yarn add graphql-ws
54
-
```
55
-
56
-
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
46
+
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.
You can further customize the `graphql-ws` implementation by creating a custom client instance and providing it as the `wsClient` parameter
68
+
You can further customize the `graphql-ws` implementation by creating a custom client instance and providing it as the `wsClient` parameter.
79
69
80
-
###Options
70
+
## Options
81
71
82
-
####`url` (_required_)
72
+
### `url` (_required_)
83
73
84
74
This is url used for all `HTTP` requests, and for schema introspection.
85
75
86
-
####`subscriptionUrl`
76
+
### `subscriptionUrl`
87
77
88
78
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.
89
79
90
-
####`wsClient`
80
+
### `wsClient`
91
81
92
-
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.
82
+
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.
93
83
94
-
###`wsConnectionParams`
84
+
## `wsConnectionParams`
95
85
96
-
provide your initial connection params.
86
+
Provide your initial connection params.
97
87
98
88
```ts
99
89
@@ -108,23 +98,23 @@ const App () {
108
98
}
109
99
```
110
100
111
-
#### `legacyWsClient` or `legacyClient`
101
+
### `legacyWsClient` or `legacyClient`
112
102
113
-
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.
103
+
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.
114
104
115
-
#### `headers`
105
+
### `headers`
116
106
117
-
Pass headers to any and all requests
107
+
Specify headers that will be passed to all requests.
118
108
119
-
#### `fetch`
109
+
### `fetch`
120
110
121
-
Pass a custom fetch implementation such as `isomorphic-fetch`
111
+
Pass a custom fetch implementation such as `isomorphic-fetch`.
122
112
123
-
### Customization Examples
113
+
## Customization Examples
124
114
125
-
#### Custom `wsClient` Example using `graphql-ws`
115
+
### Custom `wsClient` Example using `graphql-ws`
126
116
127
-
Just by providing the `wsClient`
117
+
This example passes a `graphql-ws` client to the `wsClient` option:
0 commit comments