Skip to content

Commit 71b93a3

Browse files
Alan-ChaErikWittern
authored andcommitted
Categorize options
Signed-off-by: Alan Cha <[email protected]>
1 parent 185cb34 commit 71b93a3

File tree

10 files changed

+384
-286
lines changed

10 files changed

+384
-286
lines changed

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,21 @@ Usage: openapi-to-graphql <OAS JSON file path(s) and/or remote url(s)> [options]
2323
2424
Options:
2525
-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+
2629
-p, --port <port> select the port where the server will start
2730
-u, --url <url> select the base url which paths will be built on
28-
-s, --strict throw an error if OpenAPI-to-GraphQL cannot run without compensating for errors or missing data in the OAS
31+
--cors enable Cross-origin resource sharing (CORS)
32+
33+
-o, --operationIdFieldNames create field names based on the operationId
2934
-f, --fillEmptyResponses create placeholder schemas for operations with no response body rather than ignore them
3035
-a, --addLimitArgument add a limit argument on fields returning lists of objects/lists to control the data size
31-
-o, --operationIdFieldNames create field names based on the operationId
32-
--cors enable Cross-origin resource sharing (CORS)
36+
3337
--no-viewer do not create GraphQL viewer objects for passing authentication credentials
38+
3439
--no-extensions do not add extentions, containing information about failed REST calls, to the GraphQL errors objects
3540
--no-equivalentToMessages do not append information about the underlying REST operations to the description of fields
36-
--save <file path> save schema to path and do not start server
3741
-h, --help output usage information
3842
```
3943

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

Lines changed: 15 additions & 7 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.

packages/openapi-to-graphql-cli/src/openapi-to-graphql.ts

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,25 @@ program
1818
.version(require('../package.json').version)
1919
.usage('<OAS JSON file path(s) and/or remote url(s)> [options]')
2020
.arguments('<path(s) and/or url(s)>')
21+
.option(
22+
'-s, --strict',
23+
'throw an error if OpenAPI-to-GraphQL cannot run without compensating for errors or missing data in the OAS'
24+
)
25+
.option('--save <file path>', 'save schema to path and do not start server')
26+
27+
// Resolver options
2128
.option(
2229
'-p, --port <port>',
2330
'select the port where the server will start',
2431
parseInt
2532
)
2633
.option('-u, --url <url>', 'select the base url which paths will be built on')
34+
.option('--cors', 'enable Cross-origin resource sharing (CORS)')
35+
36+
// Schema options
2737
.option(
28-
'-s, --strict',
29-
'throw an error if OpenAPI-to-GraphQL cannot run without compensating for errors or missing data in the OAS'
38+
'-o, --operationIdFieldNames',
39+
'create field names based on the operationId'
3040
)
3141
.option(
3242
'-f, --fillEmptyResponses',
@@ -36,15 +46,14 @@ program
3646
'-a, --addLimitArgument',
3747
'add a limit argument on fields returning lists of objects/lists to control the data size'
3848
)
39-
.option(
40-
'-o, --operationIdFieldNames',
41-
'create field names based on the operationId'
42-
)
43-
.option('--cors', 'enable Cross-origin resource sharing (CORS)')
49+
50+
// Authentication options
4451
.option(
4552
'--no-viewer',
4653
'do not create GraphQL viewer objects for passing authentication credentials'
4754
)
55+
56+
// Logging options
4857
.option(
4958
'--no-extensions',
5059
'do not add extentions, containing information about failed REST calls, to the GraphQL errors objects'
@@ -53,7 +62,6 @@ program
5362
'--no-equivalentToMessages',
5463
'do not append information about the underlying REST operations to the description of fields'
5564
)
56-
.option('--save <file path>', 'save schema to path and do not start server')
5765
.parse(process.argv)
5866

5967
// Select the port on which to host the GraphQL server
@@ -161,12 +169,20 @@ function startGraphQLServer(oas, port) {
161169
// Create GraphQL interface
162170
createGraphQlSchema(oas, {
163171
strict: program.strict,
164-
viewer: program.viewer,
165-
fillEmptyResponses: program.fillEmptyResponses,
172+
173+
// Resolver options
166174
baseUrl: program.url,
175+
176+
// Schema options
167177
operationIdFieldNames: program.operationIdFieldNames,
168-
provideErrorExtensions: program.extensions,
178+
fillEmptyResponses: program.fillEmptyResponses,
169179
addLimitArgument: program.addLimitArgument,
180+
181+
// Authentication options
182+
viewer: program.viewer,
183+
184+
// Logging options
185+
provideErrorExtensions: program.extensions,
170186
equivalentToMessages: program.equivalentToMessages
171187
})
172188
.then(({ schema, report }) => {

0 commit comments

Comments
 (0)