Skip to content

Commit 1840bb3

Browse files
Alan-ChaErikWittern
authored andcommitted
Add queryString option to the CLI
Signed-off-by: Alan Cha <[email protected]>
1 parent 7007bb9 commit 1840bb3

File tree

8 files changed

+111
-70
lines changed

8 files changed

+111
-70
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
},
77
"devDependencies": {
88
"@types/jest": "^24.0.16",
9-
"graphql": "^14.0.2",
9+
"graphql": "^14.5.0",
1010
"jest": "^24.8.0",
1111
"lerna": "^3.4.3",
1212
"ts-jest": "^24.0.2",

packages/openapi-to-graphql-cli/README.md

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,25 +22,26 @@ npm i -g openapi-to-graphql-cli
2222
Usage: openapi-to-graphql <OAS JSON file path(s) and/or remote url(s)> [options]
2323
2424
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
2828
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)
3232
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
3636
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: [])
3839
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
4041
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
4445
```
4546

4647
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
7374

7475
---
7576

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+
7685
To learn more about the other options, please refer [here](https://github.com/IBM/openapi-to-graphql/tree/master/packages/openapi-to-graphql#options).
7786

7887
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.

packages/openapi-to-graphql-cli/lib/openapi-to-graphql.js

Lines changed: 35 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/openapi-to-graphql-cli/lib/openapi-to-graphql.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)