@graphql-inspector/cli 0.0.0-PLACEHOLDER
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +264 -0
- package/demo.gif +0 -0
- package/index.d.ts +1 -0
- package/index.js +65 -0
- package/index.mjs +60 -0
- package/package.json +64 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2018 Kamil Kisiela
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
# GraphQL Inspector
|
|
2
|
+
|
|
3
|
+
[](https://npmjs.com/package/@graphql-inspector/cli)
|
|
4
|
+
|
|
5
|
+
**GraphQL Inspector** ouputs a list of changes between two GraphQL schemas. Every change is precisely explained and marked as breaking, non-breaking or dangerous.
|
|
6
|
+
It helps you validate documents and fragments against a schema and even find similar or duplicated types.
|
|
7
|
+
|
|
8
|
+

|
|
9
|
+
|
|
10
|
+
## Features
|
|
11
|
+
|
|
12
|
+
Major features:
|
|
13
|
+
|
|
14
|
+
- **Compares schemas**
|
|
15
|
+
- **Finds breaking or dangerous changes**
|
|
16
|
+
- **Validates documents against a schema**
|
|
17
|
+
- **Finds similar / duplicated types**
|
|
18
|
+
- **Schema coverage based on documents**
|
|
19
|
+
- **Serves a GraphQL server with faked data and GraphQL Playground**
|
|
20
|
+
- **GitHub Bot**
|
|
21
|
+
- **GitHub Actions**
|
|
22
|
+
|
|
23
|
+
GraphQL Inspector has a **CLI** and also a **programatic API**, so you can use it however you want to and even build tools on top of it.
|
|
24
|
+
|
|
25
|
+
## Installation
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
# CLI
|
|
29
|
+
yarn add @graphql-inspector/cli
|
|
30
|
+
|
|
31
|
+
# Core API for programatic usage
|
|
32
|
+
yarn add @graphql-inspector/core
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Compare schemas
|
|
36
|
+
|
|
37
|
+
Compares schemas and finds breaking or dangerous changes.
|
|
38
|
+
|
|
39
|
+
**CLI:**
|
|
40
|
+
|
|
41
|
+
$ graphql-inspector diff OLD_SCHEMA NEW_SCHEMA
|
|
42
|
+
|
|
43
|
+
**API:**
|
|
44
|
+
|
|
45
|
+
```typescript
|
|
46
|
+
import { diff, Change } from '@graphql-inspector/core'
|
|
47
|
+
|
|
48
|
+
const changes: Change[] = diff(schemaA, schemaB)
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+

|
|
52
|
+
|
|
53
|
+
### Find similar types
|
|
54
|
+
|
|
55
|
+
Finds similar / duplicated types.
|
|
56
|
+
|
|
57
|
+
**CLI:**
|
|
58
|
+
|
|
59
|
+
$ graphql-inspector similar SCHEMA
|
|
60
|
+
|
|
61
|
+
**API:**
|
|
62
|
+
|
|
63
|
+
```typescript
|
|
64
|
+
import { similar, SimilarMap } from '@graphql-inspector/core'
|
|
65
|
+
|
|
66
|
+
const similar: SimilarMap = similar(schema, typename, threshold)
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+

|
|
70
|
+
|
|
71
|
+
### Check coverage
|
|
72
|
+
|
|
73
|
+
Schema coverage based on documents. Find out how many times types and fields are used in your application.
|
|
74
|
+
|
|
75
|
+
**CLI:**
|
|
76
|
+
|
|
77
|
+
$ graphql-inspector coverage DOCUMENTS SCHEMA
|
|
78
|
+
|
|
79
|
+
**API:**
|
|
80
|
+
|
|
81
|
+
```typescript
|
|
82
|
+
import { coverage, SchemaCoverage } from '@graphql-inspector/core'
|
|
83
|
+
|
|
84
|
+
const schemaCoverage: SchemaCoverage = coverage(schema, documents)
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+

|
|
88
|
+
|
|
89
|
+
### Validate documents
|
|
90
|
+
|
|
91
|
+
Validates documents against a schema and looks for deprecated usage.
|
|
92
|
+
|
|
93
|
+
**CLI:**
|
|
94
|
+
|
|
95
|
+
$ graphql-inspector validate DOCUMENTS SCHEMA
|
|
96
|
+
|
|
97
|
+
**API:**
|
|
98
|
+
|
|
99
|
+
```typescript
|
|
100
|
+
import { validate, InvalidDocument } from '@graphql-inspector/core'
|
|
101
|
+
|
|
102
|
+
const invalid: InvalidDocument[] = validate(documentsGlob, schema)
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+

|
|
106
|
+
|
|
107
|
+
### Serve faked GraphQL API
|
|
108
|
+
|
|
109
|
+
Serves a GraphQL server with faked data and GraphQL Playground
|
|
110
|
+
|
|
111
|
+
**CLI:**
|
|
112
|
+
|
|
113
|
+
$ graphql-inspector serve SCHEMA
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
✅ Serving the GraphQL API on http://localhost:4000/
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Introspect GraphQL server
|
|
120
|
+
|
|
121
|
+
Introspects a GraphQL Server and writes the result to a file
|
|
122
|
+
|
|
123
|
+
**CLI:**
|
|
124
|
+
|
|
125
|
+
$ graphql-inspector introspect SCHEMA --write schema.json
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
✅ Introspection result saved to schema.json
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### GitHub Bot and GitHub Actions
|
|
132
|
+
|
|
133
|
+
Have a per-repository, self-hosted GraphQL Inspector service or deploy it with Docker.
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
# install
|
|
137
|
+
yarn global add @graphql-inspector/actions
|
|
138
|
+
|
|
139
|
+
# use
|
|
140
|
+
|
|
141
|
+
$ graphql-inspector-github
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
```json
|
|
145
|
+
{
|
|
146
|
+
"name": "app",
|
|
147
|
+
"scripts": {
|
|
148
|
+
"precommit": "graphql-inspector introspect schema.js --write schema.graphql && git add schema.graphql"
|
|
149
|
+
},
|
|
150
|
+
"graphql-inspector": {
|
|
151
|
+
"diff": true,
|
|
152
|
+
"schema": {
|
|
153
|
+
"ref": "master",
|
|
154
|
+
"path": "schema.graphql"
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
Get GitHub annotations in your PRs.
|
|
161
|
+
|
|
162
|
+

|
|
163
|
+
|
|
164
|
+
### CLI in more details
|
|
165
|
+
|
|
166
|
+
### `SCHEMA`
|
|
167
|
+
|
|
168
|
+
**Path to a CommonJS or ES Module that exports an object**
|
|
169
|
+
|
|
170
|
+
Example:
|
|
171
|
+
|
|
172
|
+
graphql-inspector coverage ./src/schema.js
|
|
173
|
+
|
|
174
|
+
Example with TypeScript:
|
|
175
|
+
|
|
176
|
+
graphql-inspector coverage ./src/schema.ts --require ts-node/register
|
|
177
|
+
|
|
178
|
+
```typescript
|
|
179
|
+
// String
|
|
180
|
+
export default `
|
|
181
|
+
type Query {
|
|
182
|
+
hello: String
|
|
183
|
+
}
|
|
184
|
+
`
|
|
185
|
+
|
|
186
|
+
// GraphQLSchema
|
|
187
|
+
export default makeExecutableSchema({...});
|
|
188
|
+
|
|
189
|
+
// GraphQL Document
|
|
190
|
+
export default gql`
|
|
191
|
+
type Query {
|
|
192
|
+
hello: String
|
|
193
|
+
}
|
|
194
|
+
`
|
|
195
|
+
|
|
196
|
+
// IntrospectionQuery result
|
|
197
|
+
export default {
|
|
198
|
+
data: {
|
|
199
|
+
__schema: {
|
|
200
|
+
...
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
**Pointer to a Git repository**
|
|
207
|
+
|
|
208
|
+
Example:
|
|
209
|
+
|
|
210
|
+
graphql-inspector diff git:origin/master:schema.graphql
|
|
211
|
+
|
|
212
|
+
Pattern:
|
|
213
|
+
|
|
214
|
+
git:ref:path/to/file
|
|
215
|
+
|
|
216
|
+
**Pointer to a GitHub repository**
|
|
217
|
+
|
|
218
|
+
Example:
|
|
219
|
+
|
|
220
|
+
graphql-inspector coverage github:kamilkisiela/graphql-inspector-example#master:schema.graphql
|
|
221
|
+
|
|
222
|
+
Pattern:
|
|
223
|
+
|
|
224
|
+
github:owner/name#ref:path/to/file
|
|
225
|
+
|
|
226
|
+
**GraphQL File**
|
|
227
|
+
|
|
228
|
+
Example:
|
|
229
|
+
|
|
230
|
+
graphql-inspector coverage schema.graphql
|
|
231
|
+
graphql-inspector coverage schema.gql
|
|
232
|
+
|
|
233
|
+
**JSON File**
|
|
234
|
+
|
|
235
|
+
Example:
|
|
236
|
+
|
|
237
|
+
graphql-inspector coverage introspected-schema.json
|
|
238
|
+
|
|
239
|
+
**URL to a GraphQL endpoint**
|
|
240
|
+
|
|
241
|
+
Example:
|
|
242
|
+
|
|
243
|
+
graphql-inspector coverage https://localhost:3000/graphql
|
|
244
|
+
|
|
245
|
+
### `DOCUMENTS`
|
|
246
|
+
|
|
247
|
+
**Glob pattern**
|
|
248
|
+
|
|
249
|
+
Example:
|
|
250
|
+
|
|
251
|
+
graphql-inspector validate ./src/**/*.{js,jsx,tsx,graphql} https://localhost:3000/graphql
|
|
252
|
+
|
|
253
|
+
Supports TypeScript, JavaScript and GraphQL Files (_Extensions: ts,tsx,js,jsx,graphql,gql,graphqls_).
|
|
254
|
+
|
|
255
|
+
### Help
|
|
256
|
+
|
|
257
|
+
Find out what the CLI is capable of:
|
|
258
|
+
|
|
259
|
+
graphql-inspector --help
|
|
260
|
+
graphql-inspector similar --help
|
|
261
|
+
|
|
262
|
+
## License
|
|
263
|
+
|
|
264
|
+
[MIT](https://github.com/kamilkisiela/graphql-inspector/blob/master/LICENSE) © Kamil Kisiela
|
package/demo.gif
ADDED
|
Binary file
|
package/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/index.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
|
5
|
+
|
|
6
|
+
const tslib = require('tslib');
|
|
7
|
+
const commands = require('@graphql-inspector/commands');
|
|
8
|
+
const loaders = require('@graphql-inspector/loaders');
|
|
9
|
+
const yargs = _interopDefault(require('yargs'));
|
|
10
|
+
|
|
11
|
+
function main() {
|
|
12
|
+
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
13
|
+
const config = {
|
|
14
|
+
loaders: ['code', 'git', 'github', 'graphql', 'json', 'url'],
|
|
15
|
+
commands: [
|
|
16
|
+
'docs',
|
|
17
|
+
'serve',
|
|
18
|
+
'diff',
|
|
19
|
+
'validate',
|
|
20
|
+
'coverage',
|
|
21
|
+
'introspect',
|
|
22
|
+
'similar',
|
|
23
|
+
],
|
|
24
|
+
};
|
|
25
|
+
const loaders$1 = loaders.useLoaders(config);
|
|
26
|
+
const commands$1 = commands.useCommands({ config, loaders: loaders$1 });
|
|
27
|
+
const root = yargs
|
|
28
|
+
.scriptName('graphql-inspector')
|
|
29
|
+
.detectLocale(false)
|
|
30
|
+
.epilog('Visit https://graphql-inspector.com for more information')
|
|
31
|
+
.version()
|
|
32
|
+
.options({
|
|
33
|
+
r: {
|
|
34
|
+
alias: 'require',
|
|
35
|
+
describe: 'Require modules',
|
|
36
|
+
type: 'array',
|
|
37
|
+
},
|
|
38
|
+
t: {
|
|
39
|
+
alias: 'token',
|
|
40
|
+
describe: 'Access Token',
|
|
41
|
+
type: 'string',
|
|
42
|
+
},
|
|
43
|
+
h: {
|
|
44
|
+
alias: 'header',
|
|
45
|
+
describe: 'Http Header',
|
|
46
|
+
type: 'array',
|
|
47
|
+
},
|
|
48
|
+
hl: {
|
|
49
|
+
alias: 'left-header',
|
|
50
|
+
describe: 'Http Header - Left',
|
|
51
|
+
type: 'array',
|
|
52
|
+
},
|
|
53
|
+
hr: {
|
|
54
|
+
alias: 'right-header',
|
|
55
|
+
describe: 'Http Header - Right',
|
|
56
|
+
type: 'array',
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
commands$1
|
|
60
|
+
.reduce((cli, cmd) => cli.command(cmd), root)
|
|
61
|
+
.help()
|
|
62
|
+
.showHelpOnFail(false).argv;
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
main();
|
package/index.mjs
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { __awaiter } from 'tslib';
|
|
2
|
+
import { useCommands } from '@graphql-inspector/commands';
|
|
3
|
+
import { useLoaders } from '@graphql-inspector/loaders';
|
|
4
|
+
import yargs from 'yargs';
|
|
5
|
+
|
|
6
|
+
function main() {
|
|
7
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
8
|
+
const config = {
|
|
9
|
+
loaders: ['code', 'git', 'github', 'graphql', 'json', 'url'],
|
|
10
|
+
commands: [
|
|
11
|
+
'docs',
|
|
12
|
+
'serve',
|
|
13
|
+
'diff',
|
|
14
|
+
'validate',
|
|
15
|
+
'coverage',
|
|
16
|
+
'introspect',
|
|
17
|
+
'similar',
|
|
18
|
+
],
|
|
19
|
+
};
|
|
20
|
+
const loaders = useLoaders(config);
|
|
21
|
+
const commands = useCommands({ config, loaders });
|
|
22
|
+
const root = yargs
|
|
23
|
+
.scriptName('graphql-inspector')
|
|
24
|
+
.detectLocale(false)
|
|
25
|
+
.epilog('Visit https://graphql-inspector.com for more information')
|
|
26
|
+
.version()
|
|
27
|
+
.options({
|
|
28
|
+
r: {
|
|
29
|
+
alias: 'require',
|
|
30
|
+
describe: 'Require modules',
|
|
31
|
+
type: 'array',
|
|
32
|
+
},
|
|
33
|
+
t: {
|
|
34
|
+
alias: 'token',
|
|
35
|
+
describe: 'Access Token',
|
|
36
|
+
type: 'string',
|
|
37
|
+
},
|
|
38
|
+
h: {
|
|
39
|
+
alias: 'header',
|
|
40
|
+
describe: 'Http Header',
|
|
41
|
+
type: 'array',
|
|
42
|
+
},
|
|
43
|
+
hl: {
|
|
44
|
+
alias: 'left-header',
|
|
45
|
+
describe: 'Http Header - Left',
|
|
46
|
+
type: 'array',
|
|
47
|
+
},
|
|
48
|
+
hr: {
|
|
49
|
+
alias: 'right-header',
|
|
50
|
+
describe: 'Http Header - Right',
|
|
51
|
+
type: 'array',
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
commands
|
|
55
|
+
.reduce((cli, cmd) => cli.command(cmd), root)
|
|
56
|
+
.help()
|
|
57
|
+
.showHelpOnFail(false).argv;
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
main();
|
package/package.json
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@graphql-inspector/cli",
|
|
3
|
+
"version": "0.0.0-PLACEHOLDER",
|
|
4
|
+
"description": "Tooling for GraphQL. Compare GraphQL Schemas, check documents, find breaking changes, find similar types.",
|
|
5
|
+
"sideEffects": false,
|
|
6
|
+
"peerDependencies": {
|
|
7
|
+
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0"
|
|
8
|
+
},
|
|
9
|
+
"dependencies": {
|
|
10
|
+
"@graphql-inspector/code-loader": "0.0.0-PLACEHOLDER",
|
|
11
|
+
"@graphql-inspector/commands": "0.0.0-PLACEHOLDER",
|
|
12
|
+
"@graphql-inspector/coverage-command": "0.0.0-PLACEHOLDER",
|
|
13
|
+
"@graphql-inspector/diff-command": "0.0.0-PLACEHOLDER",
|
|
14
|
+
"@graphql-inspector/docs-command": "0.0.0-PLACEHOLDER",
|
|
15
|
+
"@graphql-inspector/git-loader": "0.0.0-PLACEHOLDER",
|
|
16
|
+
"@graphql-inspector/github-loader": "0.0.0-PLACEHOLDER",
|
|
17
|
+
"@graphql-inspector/graphql-loader": "0.0.0-PLACEHOLDER",
|
|
18
|
+
"@graphql-inspector/introspect-command": "0.0.0-PLACEHOLDER",
|
|
19
|
+
"@graphql-inspector/json-loader": "0.0.0-PLACEHOLDER",
|
|
20
|
+
"@graphql-inspector/loaders": "0.0.0-PLACEHOLDER",
|
|
21
|
+
"@graphql-inspector/serve-command": "0.0.0-PLACEHOLDER",
|
|
22
|
+
"@graphql-inspector/similar-command": "0.0.0-PLACEHOLDER",
|
|
23
|
+
"@graphql-inspector/url-loader": "0.0.0-PLACEHOLDER",
|
|
24
|
+
"@graphql-inspector/validate-command": "0.0.0-PLACEHOLDER",
|
|
25
|
+
"tslib": "^2.0.0",
|
|
26
|
+
"yargs": "17.2.1"
|
|
27
|
+
},
|
|
28
|
+
"repository": {
|
|
29
|
+
"type": "git",
|
|
30
|
+
"url": "kamilkisiela/graphql-inspector",
|
|
31
|
+
"directory": "packages/cli"
|
|
32
|
+
},
|
|
33
|
+
"keywords": [
|
|
34
|
+
"graphql",
|
|
35
|
+
"graphql-inspector",
|
|
36
|
+
"tools",
|
|
37
|
+
"cli"
|
|
38
|
+
],
|
|
39
|
+
"author": {
|
|
40
|
+
"name": "Kamil Kisiela",
|
|
41
|
+
"email": "kamil.kisiela@gmail.com",
|
|
42
|
+
"url": "https://github.com/kamilkisiela"
|
|
43
|
+
},
|
|
44
|
+
"license": "MIT",
|
|
45
|
+
"main": "index.js",
|
|
46
|
+
"module": "index.mjs",
|
|
47
|
+
"typings": "index.d.ts",
|
|
48
|
+
"typescript": {
|
|
49
|
+
"definition": "index.d.ts"
|
|
50
|
+
},
|
|
51
|
+
"exports": {
|
|
52
|
+
".": {
|
|
53
|
+
"require": "./index.js",
|
|
54
|
+
"import": "./index.mjs"
|
|
55
|
+
},
|
|
56
|
+
"./*": {
|
|
57
|
+
"require": "./*.js",
|
|
58
|
+
"import": "./*.mjs"
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
"bin": {
|
|
62
|
+
"graphql-inspector": "index.js"
|
|
63
|
+
}
|
|
64
|
+
}
|