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/openapi-to-graphql/README.md
+4-1
Original file line number
Diff line number
Diff line change
@@ -173,10 +173,13 @@ Schema options:
173
173
Resolver options:
174
174
175
175
-`headers` (type: `object` | `function`, default: `{}`): Headers to be sent in every request to the API. Parameters defined in the OpenAPI Specification and set by these headers will be ignored by OpenAPI-to-GraphQL. If used as a function, the following parameters will be exposed per-request: the operation's `method`, the operation's `path`, the API `title`, and `resolverParams` (the [GraphQL resolver's parameters](https://graphql.org/learn/execution/#root-fields-resolvers)). The function should return the desired headers.
176
+
_Note: If used as a function, this will be used to modify resolvers AND the schema. For example, if a `foo` header is set, then the resolver call will append the `foo` header, and the `foo` parameter will be removed from the GraphQL schema. In `resolver_builder.ts`, the function will be called with all arguments, but in `schema_builder.ts`, only the `method`, `path`, and `title` will be provided (because `resolverParams` and `generatedRequestOptions` are only available during execution). Therefore, for query, path, header, and cookie parameters, a value must be provided without `resolverParam` and `generatedRequestOptions` or else the schema will not have the right parameters._
176
177
177
178
-`qs` (type: `object`, default: `{}`): Query parameters to be sent in every request to the API. Parameters defined in the OpenAPI Specification and set by these query parameters will be ignored by OpenAPI-to-GraphQL.
178
179
179
-
- `requestOptions` (type: `object` | `function`, default: `{}`): Additional [options](https://github.com/request/request#requestoptions-callback), provided by the [`Request` module](https://github.com/request/request), that can be used to configure the HTTP calls that powers the generated GraphQL resolvers. A common use case for this option is to set up a web proxy with the `proxy` field. Parameters defined in the OpenAPI Specification and set by this option will be ignored by OpenAPI-to-GraphQL. Additionally, the `headers` field has the feature of being used as a function. If used as a function, the following parameters will be exposed per-request: the operation's `method`, the operation's `path`, the API `title`, and `resolverParams` (the [GraphQL resolver's parameters](https://graphql.org/learn/execution/#root-fields-resolvers)). The function should return the desired headers. If `requestOptions` is used as a function, the following parameters will be exposed per-request: the operation's `method`, the operation's `path`, the API `title`, and `resolverParams` (the [GraphQL resolver's parameters](https://graphql.org/learn/execution/#root-fields-resolvers)). It should return object of type [options](https://github.com/request/request#requestoptions-callback). If `requestOptions` is used as a function `url` and `method` can also be set.
180
+
- `requestOptions` (type: `object` | `function`, default: `{}`): Additional [options](https://github.com/request/request#requestoptions-callback), provided by the [`Request` module](https://github.com/request/request), that can be used to configure the HTTP calls that powers the generated GraphQL resolvers. A common use case for this option is to add headers or query string parameters to every request or to set up a web proxy with the `proxy` field. Parameters defined in the OpenAPI Specification and set by this option will be ignored by OpenAPI-to-GraphQL. If `requestOptions` is used as a function, the following parameters will be exposed per request: the operation's `method`, the operation's `path`, the API `title`, and `resolverParams` (the [GraphQL resolver's parameters](https://graphql.org/learn/execution/#root-fields-resolvers)). The function should return an [options](https://github.com/request/request#requestoptions-callback) object. _Note: If used as a function, this will be used to modify resolvers AND the schema. For example, if a `foo` header is set, then the resolver call will append the `foo` header, and the `foo` parameter will be removed from the GraphQL schema. In `resolver_builder.ts`, the function will be called with all arguments, but in `schema_builder.ts`, only the `method`, `path`, and `title` will be provided (because `resolverParams` and `generatedRequestOptions` are only available during execution). Therefore, for query, path, header, and cookie parameters, a value must be provided without `resolverParam` and `generatedRequestOptions` or else the schema will not have the right parameters._
181
+
182
+
-`connectOptions` (type: `object`, default: `{}`): Allows to override or add options to the PubSub connect object used to make publish/subscribe to the API backend, e.g. setup the web proxy to use.
180
183
181
184
-`baseUrl` (type: `string`): Used to manually specify the base URL which all paths will be built on. Normally, OpenAPI-to-GraphQL will select a base URL from the [server object](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#serverObject) defined in the OAS. However, if the server object contains multiple URLs, OpenAPI-to-GraphQL will randomly select one. The purpose of this option is to provide greater control over the base URL in these situations, especially when the OAS cannot be modified. This option may also prove to be useful in testing and development.
0 commit comments