@graphql-inspector/introspect-command 0.0.0-canary.0fd8c6a → 0.0.0-canary.36b26d2

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/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { GlobalArgs, CommandFactory } from '@graphql-inspector/commands';
2
2
  import { GraphQLSchema } from 'graphql';
3
3
  export { CommandFactory };
4
- export declare function handler({ schema, output, comments, }: {
4
+ export declare function handler({ schema: unsortedSchema, output, comments, }: {
5
5
  schema: GraphQLSchema;
6
6
  output: string;
7
7
  comments: boolean;
@@ -9,7 +9,8 @@ const fs = require('fs');
9
9
  const path = require('path');
10
10
  const graphql = require('graphql');
11
11
 
12
- function handler({ schema, output, comments, }) {
12
+ function handler({ schema: unsortedSchema, output, comments, }) {
13
+ const schema = graphql.lexicographicSortSchema(unsortedSchema);
13
14
  const introspection = graphql.introspectionFromSchema(schema);
14
15
  const filepath = path.resolve(process.cwd(), output);
15
16
  let content;
@@ -33,7 +34,7 @@ function handler({ schema, output, comments, }) {
33
34
  });
34
35
  logger.Logger.success(`Saved to ${filepath}`);
35
36
  }
36
- const index = commands.createCommand((api) => {
37
+ const index = commands.createCommand(api => {
37
38
  const { loaders } = api;
38
39
  return {
39
40
  command: 'introspect <schema>',
@@ -59,14 +60,19 @@ const index = commands.createCommand((api) => {
59
60
  .default('w', 'graphql.schema.json');
60
61
  },
61
62
  handler(args) {
63
+ var _a;
62
64
  return tslib.__awaiter(this, void 0, void 0, function* () {
63
65
  const { headers, token } = commands.parseGlobalArgs(args);
64
66
  const output = args.write;
65
67
  const comments = args.comments || false;
68
+ const apolloFederation = args.federation || false;
69
+ const aws = args.aws || false;
70
+ const method = ((_a = args.method) === null || _a === void 0 ? void 0 : _a.toUpperCase()) || 'POST';
66
71
  const schema = yield loaders.loadSchema(args.schema, {
67
72
  token,
68
73
  headers,
69
- });
74
+ method,
75
+ }, apolloFederation, aws);
70
76
  return handler({ schema, output, comments });
71
77
  });
72
78
  },
@@ -75,4 +81,3 @@ const index = commands.createCommand((api) => {
75
81
 
76
82
  exports.default = index;
77
83
  exports.handler = handler;
78
- //# sourceMappingURL=index.cjs.js.map
@@ -3,9 +3,10 @@ import { createCommand, parseGlobalArgs } from '@graphql-inspector/commands';
3
3
  import { Logger } from '@graphql-inspector/logger';
4
4
  import { writeFileSync } from 'fs';
5
5
  import { resolve, extname } from 'path';
6
- import { introspectionFromSchema, printSchema } from 'graphql';
6
+ import { lexicographicSortSchema, introspectionFromSchema, printSchema } from 'graphql';
7
7
 
8
- function handler({ schema, output, comments, }) {
8
+ function handler({ schema: unsortedSchema, output, comments, }) {
9
+ const schema = lexicographicSortSchema(unsortedSchema);
9
10
  const introspection = introspectionFromSchema(schema);
10
11
  const filepath = resolve(process.cwd(), output);
11
12
  let content;
@@ -29,7 +30,7 @@ function handler({ schema, output, comments, }) {
29
30
  });
30
31
  Logger.success(`Saved to ${filepath}`);
31
32
  }
32
- const index = createCommand((api) => {
33
+ const index = createCommand(api => {
33
34
  const { loaders } = api;
34
35
  return {
35
36
  command: 'introspect <schema>',
@@ -55,14 +56,19 @@ const index = createCommand((api) => {
55
56
  .default('w', 'graphql.schema.json');
56
57
  },
57
58
  handler(args) {
59
+ var _a;
58
60
  return __awaiter(this, void 0, void 0, function* () {
59
61
  const { headers, token } = parseGlobalArgs(args);
60
62
  const output = args.write;
61
63
  const comments = args.comments || false;
64
+ const apolloFederation = args.federation || false;
65
+ const aws = args.aws || false;
66
+ const method = ((_a = args.method) === null || _a === void 0 ? void 0 : _a.toUpperCase()) || 'POST';
62
67
  const schema = yield loaders.loadSchema(args.schema, {
63
68
  token,
64
69
  headers,
65
- });
70
+ method,
71
+ }, apolloFederation, aws);
66
72
  return handler({ schema, output, comments });
67
73
  });
68
74
  },
@@ -71,4 +77,3 @@ const index = createCommand((api) => {
71
77
 
72
78
  export default index;
73
79
  export { handler };
74
- //# sourceMappingURL=index.esm.js.map
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@graphql-inspector/introspect-command",
3
- "version": "0.0.0-canary.0fd8c6a",
3
+ "version": "0.0.0-canary.36b26d2",
4
4
  "description": "Introspects GraphQL Schema",
5
5
  "sideEffects": false,
6
6
  "peerDependencies": {
7
- "graphql": "^0.13.0 || ^14.0.0 || ^15.0.0"
7
+ "graphql": "^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0"
8
8
  },
9
9
  "dependencies": {
10
- "@graphql-inspector/commands": "0.0.0-canary.0fd8c6a",
11
- "@graphql-inspector/core": "0.0.0-canary.0fd8c6a",
12
- "@graphql-inspector/logger": "0.0.0-canary.0fd8c6a",
10
+ "@graphql-inspector/commands": "0.0.0-canary.36b26d2",
11
+ "@graphql-inspector/core": "0.0.0-canary.36b26d2",
12
+ "@graphql-inspector/logger": "0.0.0-canary.36b26d2",
13
13
  "tslib": "^2.0.0"
14
14
  },
15
15
  "repository": {
@@ -29,10 +29,20 @@
29
29
  "url": "https://github.com/kamilkisiela"
30
30
  },
31
31
  "license": "MIT",
32
- "main": "index.cjs.js",
33
- "module": "index.esm.js",
32
+ "main": "index.js",
33
+ "module": "index.mjs",
34
34
  "typings": "index.d.ts",
35
35
  "typescript": {
36
36
  "definition": "index.d.ts"
37
+ },
38
+ "exports": {
39
+ ".": {
40
+ "require": "./index.js",
41
+ "import": "./index.mjs"
42
+ },
43
+ "./*": {
44
+ "require": "./*.js",
45
+ "import": "./*.mjs"
46
+ }
37
47
  }
38
48
  }
package/index.cjs.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.cjs.js","sources":["../../dist/commands/introspect/src/index.js"],"sourcesContent":["import { __awaiter } from \"tslib\";\nimport { createCommand, parseGlobalArgs, } from '@graphql-inspector/commands';\nimport { Logger } from '@graphql-inspector/logger';\nimport { writeFileSync } from 'fs';\nimport { resolve, extname } from 'path';\nimport { introspectionFromSchema, printSchema } from 'graphql';\nexport function handler({ schema, output, comments, }) {\n const introspection = introspectionFromSchema(schema);\n const filepath = resolve(process.cwd(), output);\n let content;\n switch (extname(output.toLowerCase())) {\n case '.graphql':\n case '.gql':\n case '.gqls':\n case '.graphqls':\n content = printSchema(schema, {\n commentDescriptions: comments,\n });\n break;\n case '.json':\n content = JSON.stringify(introspection, null, 2);\n break;\n default:\n throw new Error('Only .graphql, .gql and .json files are supported');\n }\n writeFileSync(output, content, {\n encoding: 'utf-8',\n });\n Logger.success(`Saved to ${filepath}`);\n}\nexport default createCommand((api) => {\n const { loaders } = api;\n return {\n command: 'introspect <schema>',\n describe: 'Introspect a schema',\n builder(yargs) {\n return yargs\n .positional('schema', {\n describe: 'Point to a schema',\n type: 'string',\n demandOption: true,\n })\n .options({\n w: {\n alias: 'write',\n describe: 'Write to a file',\n type: 'string',\n },\n comments: {\n describe: 'Use preceding comments as the description',\n type: 'boolean',\n },\n })\n .default('w', 'graphql.schema.json');\n },\n handler(args) {\n return __awaiter(this, void 0, void 0, function* () {\n const { headers, token } = parseGlobalArgs(args);\n const output = args.write;\n const comments = args.comments || false;\n const schema = yield loaders.loadSchema(args.schema, {\n token,\n headers,\n });\n return handler({ schema, output, comments });\n });\n },\n };\n});\n//# sourceMappingURL=index.js.map"],"names":["introspectionFromSchema","resolve","extname","printSchema","writeFileSync","Logger","createCommand","__awaiter","parseGlobalArgs"],"mappings":";;;;;;;;;;;AAMO,SAAS,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,GAAG,EAAE;AACvD,IAAI,MAAM,aAAa,GAAGA,+BAAuB,CAAC,MAAM,CAAC,CAAC;AAC1D,IAAI,MAAM,QAAQ,GAAGC,YAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,MAAM,CAAC,CAAC;AACpD,IAAI,IAAI,OAAO,CAAC;AAChB,IAAI,QAAQC,YAAO,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;AACzC,QAAQ,KAAK,UAAU,CAAC;AACxB,QAAQ,KAAK,MAAM,CAAC;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,EAAE,2CAA2C;AACzE,oBAAoB,IAAI,EAAE,SAAS;AACnC,iBAAiB;AACjB,aAAa,CAAC;AACd,iBAAiB,OAAO,CAAC,GAAG,EAAE,qBAAqB,CAAC,CAAC;AACrD,SAAS;AACT,QAAQ,OAAO,CAAC,IAAI,EAAE;AACtB,YAAY,OAAOC,eAAS,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,KAAK,CAAC,EAAE,aAAa;AAChE,gBAAgB,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,GAAGC,wBAAe,CAAC,IAAI,CAAC,CAAC;AACjE,gBAAgB,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC;AAC1C,gBAAgB,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,IAAI,KAAK,CAAC;AACxD,gBAAgB,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,EAAE;AACrE,oBAAoB,KAAK;AACzB,oBAAoB,OAAO;AAC3B,iBAAiB,CAAC,CAAC;AACnB,gBAAgB,OAAO,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;AAC7D,aAAa,CAAC,CAAC;AACf,SAAS;AACT,KAAK,CAAC;AACN,CAAC,CAAC;;;;;"}
package/index.esm.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.esm.js","sources":["../../dist/commands/introspect/src/index.js"],"sourcesContent":["import { __awaiter } from \"tslib\";\nimport { createCommand, parseGlobalArgs, } from '@graphql-inspector/commands';\nimport { Logger } from '@graphql-inspector/logger';\nimport { writeFileSync } from 'fs';\nimport { resolve, extname } from 'path';\nimport { introspectionFromSchema, printSchema } from 'graphql';\nexport function handler({ schema, output, comments, }) {\n const introspection = introspectionFromSchema(schema);\n const filepath = resolve(process.cwd(), output);\n let content;\n switch (extname(output.toLowerCase())) {\n case '.graphql':\n case '.gql':\n case '.gqls':\n case '.graphqls':\n content = printSchema(schema, {\n commentDescriptions: comments,\n });\n break;\n case '.json':\n content = JSON.stringify(introspection, null, 2);\n break;\n default:\n throw new Error('Only .graphql, .gql and .json files are supported');\n }\n writeFileSync(output, content, {\n encoding: 'utf-8',\n });\n Logger.success(`Saved to ${filepath}`);\n}\nexport default createCommand((api) => {\n const { loaders } = api;\n return {\n command: 'introspect <schema>',\n describe: 'Introspect a schema',\n builder(yargs) {\n return yargs\n .positional('schema', {\n describe: 'Point to a schema',\n type: 'string',\n demandOption: true,\n })\n .options({\n w: {\n alias: 'write',\n describe: 'Write to a file',\n type: 'string',\n },\n comments: {\n describe: 'Use preceding comments as the description',\n type: 'boolean',\n },\n })\n .default('w', 'graphql.schema.json');\n },\n handler(args) {\n return __awaiter(this, void 0, void 0, function* () {\n const { headers, token } = parseGlobalArgs(args);\n const output = args.write;\n const comments = args.comments || false;\n const schema = yield loaders.loadSchema(args.schema, {\n token,\n headers,\n });\n return handler({ schema, output, comments });\n });\n },\n };\n});\n//# sourceMappingURL=index.js.map"],"names":[],"mappings":";;;;;;;AAMO,SAAS,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,GAAG,EAAE;AACvD,IAAI,MAAM,aAAa,GAAG,uBAAuB,CAAC,MAAM,CAAC,CAAC;AAC1D,IAAI,MAAM,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,MAAM,CAAC,CAAC;AACpD,IAAI,IAAI,OAAO,CAAC;AAChB,IAAI,QAAQ,OAAO,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;AACzC,QAAQ,KAAK,UAAU,CAAC;AACxB,QAAQ,KAAK,MAAM,CAAC;AACpB,QAAQ,KAAK,OAAO,CAAC;AACrB,QAAQ,KAAK,WAAW;AACxB,YAAY,OAAO,GAAG,WAAW,CAAC,MAAM,EAAE;AAC1C,gBAAgB,mBAAmB,EAAE,QAAQ;AAC7C,aAAa,CAAC,CAAC;AACf,YAAY,MAAM;AAClB,QAAQ,KAAK,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