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: README.md
+19-7Lines changed: 19 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -147,7 +147,7 @@ If the server that you are running GraphQL Rest Router on requires a proxy to co
147
147
### Advanced Configuration of GraphQL Rest Router
148
148
GraphQL Rest Router takes an optional third parameter during initialization that allows you to control default cache, headers, authentication and proxies
149
149
150
-
```
150
+
```js
151
151
constoptions= {
152
152
defaultCacheTimeInMs:3000,
153
153
};
@@ -156,11 +156,20 @@ new GraphQLRestRouter(endpoint, schema, options);
156
156
```
157
157
158
158
A list of options and their default values is below:
159
-
**TODO TABLE HERE**
160
159
161
-
### Creating Endpoints
160
+
| Property | Type | Default | Description |
161
+
| --- | --- | --- | --- |
162
+
| defaultCacheTimeInMs | number | 0 | If a cache engine has been provided use this as a default value for all routes and endpoints. If a route level cache time has been provided this value will be ignored |
163
+
| defaultTimeoutInMs | number | 10000 | The amount of time to allow for a request to the GraphQL to wait before timing out an endpoint |
164
+
| autoDiscoverEndpoints | boolean | false | When set to true, GQL Rest Router will scan the provided client schema you provide and automatically mount an endpoint for each operation name / named query |
165
+
| optimizeQueryRequest | boolean | false | (BETA) When set to true, GQL Rest Router will split up the provided schema into the smallest fragment necessary to complete each request to the GraphQL server as opposed to sending the originally provided schema with each request|
166
+
| headers | object | {} | Any headers provided here will be sent with each request to GraphQL. If headers are also set at the route level, they will be combined with these headers (Route Headers take priority over Global Headers) |
167
+
| passThroughHeaders | array<string> |[]| An array of strings that indicate which headers to pass through from the request to GraphQL Rest Router to the GraphQL Server. (Example: ['x-context-jwt']) |
168
+
| auth |[AxiosBasicCredentials](https://github.com/axios/axios/blob/master/index.d.ts#L9-L12)| null | If the GraphQL server is protected with basic auth provide the basic auth credentials here to allow GQL Rest Router to connect. (Example: { username: 'pesto', password: 'foobar' } |
169
+
| proxy |[AxiosProxyConfig](https://github.com/axios/axios/blob/master/index.d.ts#L14-L22)| null | If a proxy is required to communicate with your GraphQL server from the server that GQL Rest Router is running on, provide it here. |
170
+
| cacheEngine | ICacheEngine | null | Either a cache engine that [ships default](#Caching) with GQL Rest Router or adheres to the [ICacheEngine interface](#Custom-Cache-Engine)|
162
171
163
-
### GET / POST
172
+
### Creating Endpoints
164
173
165
174
## Caching
166
175
GraphQL Rest Router ships with two cache interfaces stock and supports any number of custom or third party caching interfaces as long as they adhere to `ICacheInterface`
As of the time of this writing, a REDIS interface for GQL Rest Router is not yet available. Feel free to submit a PR.
189
198
199
+
### Custom Cache Engine
200
+
If you have a unique cache situation, or use a cache that does not ship by default with GQL Rest Router, you may implement a custom cache as long as it adheres to the ICacheEngine interface.
201
+
202
+
Simply said, provide an object that contains `get` and `set` functions. See `InMemoryCache.ts` as an example.
203
+
190
204
## Swagger / Open API
191
205
As GraphQL Rest Router exposes your API with new routes that aren't covered by GraphQL's internal documentation or introspection queries, GraphQL Rest Router ships with support for Swagger (Open Api V2), Open API (V3) and API Blueprint (planned). When mounting a documentation on GraphQL Rest Router, it will automatically inspect all queries in the schema you provided and run an introspection query on your GraphQL server to dynamically assemble and document the types / endpoints.
Currently GQL Rest Router only supports Express out of the box. Please submit a PR or an Issue if you would like to see GQL Rest Router support additional frameworks.
234
246
@@ -258,7 +270,7 @@ app.listen(3000);
258
270
```
259
271
260
272
### Usage with KOA
261
-
As of the time of this writing, a KOA extension for GQL Rest Router is not yet available. Feel free to submit a PR.
273
+
As of the time of this writing, a KOA extension for GQL Rest Router is not available. Feel free to submit a PR.
262
274
263
275
### Code Examples
264
276
See the [examples folder](/examples) in this repo for code examples.
0 commit comments