@@ -22,25 +22,26 @@ npm i -g openapi-to-graphql-cli
22
22
Usage: openapi-to-graphql <OAS JSON file path(s) and/or remote url(s)> [options]
23
23
24
24
Options:
25
- -V, --version output the version number
26
- -s, --strict throw an error if OpenAPI-to-GraphQL cannot run without compensating for errors or missing data in the OAS
27
- --save <file path> save schema to path and do not start server
25
+ -V, --version output the version number
26
+ -s, --strict throw an error if OpenAPI-to-GraphQL cannot run without compensating for errors or missing data in the OAS
27
+ --save <file path> save schema to path and do not start server
28
28
29
- -p, --port <port> select the port where the server will start
30
- -u, --url <url> select the base url which paths will be built on
31
- --cors enable Cross-origin resource sharing (CORS)
29
+ -p, --port <port> select the port where the server will start
30
+ -u, --url <url> select the base url which paths will be built on
31
+ --cors enable Cross-origin resource sharing (CORS)
32
32
33
- -o, --operationIdFieldNames create field names based on the operationId
34
- -f, --fillEmptyResponses create placeholder schemas for operations with no response body rather than ignore them
35
- -a, --addLimitArgument add a limit argument on fields returning lists of objects/lists to control the data size
33
+ -o, --operationIdFieldNames create field names based on the operationId
34
+ -f, --fillEmptyResponses create placeholder schemas for operations with no response body rather than ignore them
35
+ -a, --addLimitArgument add a limit argument on fields returning lists of objects/lists to control the data size
36
36
37
- -H, --header <key:value> add headers to every request; repeatable flag; set using key:value notation (default: [])
37
+ -H, --header <key:value> add headers to every request; repeatable flag; set using key:value notation (default: [])
38
+ -Q, --queryString <key:value> add query parameters to every request; repeatable flag; set using key:value notation (default: [])
38
39
39
- --no-viewer do not create GraphQL viewer objects for passing authentication credentials
40
+ --no-viewer do not create GraphQL viewer objects for passing authentication credentials
40
41
41
- --no-extensions do not add extentions, containing information about failed REST calls, to the GraphQL errors objects
42
- --no-equivalentToMessages do not append information about the underlying REST operations to the description of fields
43
- -h, --help output usage information
42
+ --no-extensions do not add extentions, containing information about failed REST calls, to the GraphQL errors objects
43
+ --no-equivalentToMessages do not append information about the underlying REST operations to the description of fields
44
+ -h, --help output usage information
44
45
```
45
46
46
47
The basic usage of the CLI takes the specified OAS, creates a GraphQL interface for it, and starts a server to host the GraphQL interface.
@@ -73,6 +74,14 @@ openapi-to-graphql oas.json --save schema.graphql
73
74
74
75
---
75
76
77
+ You can use multiple ` header ` and ` queryString ` to add headers and query strings to the resolvers. Use the syntax: ` {key}:{value} ` .
78
+
79
+ ``` sh
80
+ openapi-to-graphql oas.json -H someHeader:someValue -H anotherHeader:anotherValue -Q " exampleQueryString:This one contains spaces!"
81
+ ```
82
+
83
+ ---
84
+
76
85
To learn more about the other options, please refer [ here] ( https://github.com/IBM/openapi-to-graphql/tree/master/packages/openapi-to-graphql#options ) .
77
86
78
87
Please note that the CLI tool is mainly used for quick testing and does not offer all the features that [ ` createGraphQlSchema(oas, options) ` ] ( https://github.com/IBM/openapi-to-graphql/tree/master/packages/openapi-to-graphql#usage ) does.
0 commit comments