forked from rmosolgo/graphql-ruby
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.js
More file actions
executable file
·61 lines (54 loc) · 2.17 KB
/
Copy pathcli.js
File metadata and controls
executable file
·61 lines (54 loc) · 2.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env node
var parseArgs = require('minimist')
var argv = parseArgs(process.argv.slice(2))
if (argv.help || argv.h) {
console.log(`usage: graphql-ruby-client sync <options>
Read .graphql files and push the contained
operations to a GraphQL::Pro::OperationStore
required arguments:
--url=<endpoint-url> URL where data should be POSTed
--client=<client-name> Identifier for this client application
optional arguments:
--path=<path> Path to .graphql files (default is "./**/*.graphql")
--outfile=<generated-filename> Target file for generated code
--outfile-type=<type> Target type for generated code (default is "js")
--key=<key> HMAC authentication key
--mode=<mode> Treat files like a certain kind of project:
relay: treat files like relay-compiler output
project: treat files like a cohesive project (fragments are shared, names must be unique)
file: treat each file like a stand-alone operation
By default, this flag is set to:
- "relay" if "__generated__" in the path
- otherwise, "project"
--add-typename Automatically adds the "__typename" field to your queries
--quiet Suppress status logging
--help Print this message
`)
} else {
var commandName = argv._[0]
if (commandName !== "sync") {
console.log("Only `graphql-ruby-client sync` is supported")
} else {
var sync = require("./sync")
var result = sync({
path: argv.path,
url: argv.url,
client: argv.client,
outfile: argv.outfile,
outfileType: argv["outfile-type"],
secret: argv.secret,
mode: argv.mode,
addTypename: argv["add-typename"],
quiet: argv.hasOwnProperty("quiet"),
})
if (result instanceof Promise){
result.then(function(res) {
if (res === false) {
process.exit(1)
}
})
} else if (result === false) {
process.exit(1)
}
}
}