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
-- Now `Executor` can receive `AsyncIterable` and subscriptions will also be handled by `Executor`. This is a future-proof change for defer, stream and live queries
Copy file name to clipboardexpand all lines: website/docs/remote-schemas.md
+7-26
Original file line number
Diff line number
Diff line change
@@ -10,18 +10,16 @@ There two ways to create remote schemas;
10
10
11
11
## Use Loaders to load schemas easily
12
12
13
-
Check out [Schema Loading](/docs/schema-loading) to load schemas from an URL and/or different sources easily without implementing an executor or subscriber.
13
+
Check out [Schema Loading](/docs/schema-loading) to load schemas from an URL and/or different sources easily without implementing an executor.
14
14
15
-
## Create a remote executable schema with custom executor and subscriber methods
15
+
## Create a remote executable schema with custom executor methods
16
16
17
17
Generally, to create a remote schema, you generally need just three steps:
18
18
19
19
1. Create a [executor](#creating-an-executor) that can retrieve results from that schema
20
20
2. Use [`introspectSchema`](#introspectschemaexecutor-context) to get the non-executable schema of the remote server
21
21
3. Use [`wrapSchema`](#wrapschemaschemaconfig) to create a schema that uses the executor to delegate requests to the underlying service
22
22
23
-
You can optionally also include a [subscriber](#creating-a-subscriber) that can retrieve real time subscription results from the remote schema (only if you are using GraphQL Subscriptions)
24
-
25
23
### Creating an executor
26
24
27
25
You can use an executor with an HTTP Client implementation (like cross-fetch). An executor is a function capable of retrieving GraphQL results. It is the same way that a GraphQL Client handles fetching data and is used by several `graphql-tools` features to do introspection or fetch results during execution.
@@ -99,21 +97,17 @@ export default async () => {
99
97
};
100
98
```
101
99
102
-
### Creating a subscriber
103
-
104
-
For subscriptions, we need to define a subscriber that returns `AsyncIterator`. Other than that, it has the similar API with `executor`.
For subscriptions, we need to extend our executor by returning `AsyncIterator`.
109
103
110
104
#### Using `graphql-ws`
111
105
112
106
For the following example to work, the server must implement the [library's transport protocol](https://github.com/enisdenjo/graphql-ws/blob/master/PROTOCOL.md). Learn more about [`graphql-ws`](https://github.com/enisdenjo/graphql-ws).
Note that within the `defaultCreateProxyingResolver` function, `delegateToSchema` receives `executor`and `subscriber` functions stored on the subschema config object originally passed to `wrapSchema`. As above, use of the the `createProxyingResolver` option is helpful when you want to customize additional functionality at resolver creation time. If you just want to customize how things are proxied at the time that they are proxied, you can make do just with custom executors and subscribers.
244
+
Note that within the `defaultCreateProxyingResolver` function, `delegateToSchema` receives `executor`function stored on the subschema config object originally passed to `wrapSchema`. As above, use of the the `createProxyingResolver` option is helpful when you want to customize additional functionality at resolver creation time. If you just want to customize how things are proxied at the time that they are proxied, you can make do just with custom executors.
@@ -109,7 +108,7 @@ Also note that these subschema config objects may need to be referenced again in
109
108
110
109
## Stitching remote schemas
111
110
112
-
To include a remote schema in the combined gateway, you must provide at least the `schema` and `executor` subschema config options, and an optional `subscriber` for subscriptions:
111
+
To include a remote schema in the combined gateway, you must provide at least the `schema` and `executor` subschema config options.
-`schema`: this is a non-executable schema representing the remote API. The remote schema may be obtained using [introspection](/docs/remote-schemas/#introspectschemaexecutor-context), or fetched as a flat SDL string (from a server or repo) and built into a schema using [`buildSchema`](https://graphql.org/graphql-js/utilities/#buildschema). Note that not all GraphQL servers enable introspection, and those that do will not include custom directives.
137
135
-`executor`: is a generic method that performs requests to a remote schema. It's quite simple to [write your own](/docs/remote-schemas#creating-an-executor). Subschema config uses the executor for query and mutation operations. See [handbook example](https://github.com/gmac/schema-stitching-handbook/tree/master/combining-local-and-remote-schemas).
138
-
-`subscriber`: to enable subscription operations, include a [subscriber function](/docs/remote-schemas#creating-a-subscriber) that returns an AsyncIterator. See [handbook example](https://github.com/gmac/schema-stitching-handbook/tree/master/mutations-and-subscriptions).
0 commit comments