@graphql-inspector/validate-command
Advanced tools
Comparing version 0.0.0-canary.57e2caa to 0.0.0-canary.6f0f272
@@ -10,16 +10,19 @@ 'use strict'; | ||
const index = commands.createCommand((api) => { | ||
const { loaders, interceptArguments, interceptPositional, interceptOptions, } = api; | ||
return { | ||
command: 'validate [documents] [schema]', | ||
command: 'validate <documents> <schema>', | ||
describe: 'Validate Fragments and Operations', | ||
builder(yargs) { | ||
return yargs | ||
.positional('schema', { | ||
.positional('schema', interceptPositional('schema', { | ||
describe: 'Point to a schema', | ||
type: 'string', | ||
}) | ||
.positional('documents', { | ||
demandOption: true, | ||
})) | ||
.positional('documents', interceptPositional('documents', { | ||
describe: 'Point to docuents', | ||
type: 'string', | ||
}) | ||
.options({ | ||
demandOption: true, | ||
})) | ||
.options(interceptOptions({ | ||
d: { | ||
@@ -31,7 +34,2 @@ alias: 'deprecated', | ||
}, | ||
c: { | ||
alias: 'config', | ||
describe: 'Use GraphQL Config to find schema and documents', | ||
type: 'boolean', | ||
}, | ||
noStrictFragments: { | ||
@@ -56,17 +54,13 @@ describe: 'Do not fail on duplicated fragment names', | ||
}, | ||
}); | ||
})); | ||
}, | ||
handler(args) { | ||
return tslib.__awaiter(this, void 0, void 0, function* () { | ||
const { loaders, pickPointers } = api; | ||
yield interceptArguments(args); | ||
const { headers, token } = commands.parseGlobalArgs(args); | ||
const pointer = yield pickPointers(args, { | ||
schema: true, | ||
documents: true, | ||
}); | ||
const schema = yield loaders.loadSchema(pointer.schema, { | ||
const schema = yield loaders.loadSchema(args.schema, { | ||
headers, | ||
token, | ||
}); | ||
const documents = yield loaders.loadDocuments(pointer.documents); | ||
const documents = yield loaders.loadDocuments(args.documents); | ||
const invalidDocuments = core.validate(schema, documents.map((doc) => new graphql.Source(graphql.print(doc.document), doc.location)), { | ||
@@ -73,0 +67,0 @@ strictFragments: !args.noStrictFragments, |
@@ -1,5 +0,6 @@ | ||
import { GlobalArgs } from '@graphql-inspector/commands'; | ||
declare const _default: import("../../commands/src").CommandFactory<{}, { | ||
schema?: string | undefined; | ||
documents?: string | undefined; | ||
import { GlobalArgs, CommandFactory } from '@graphql-inspector/commands'; | ||
export { CommandFactory }; | ||
declare const _default: CommandFactory<{}, { | ||
schema: string; | ||
documents: string; | ||
deprecated?: boolean | undefined; | ||
@@ -6,0 +7,0 @@ noStrictFragments: boolean; |
@@ -8,16 +8,19 @@ import { __awaiter } from 'tslib'; | ||
const index = createCommand((api) => { | ||
const { loaders, interceptArguments, interceptPositional, interceptOptions, } = api; | ||
return { | ||
command: 'validate [documents] [schema]', | ||
command: 'validate <documents> <schema>', | ||
describe: 'Validate Fragments and Operations', | ||
builder(yargs) { | ||
return yargs | ||
.positional('schema', { | ||
.positional('schema', interceptPositional('schema', { | ||
describe: 'Point to a schema', | ||
type: 'string', | ||
}) | ||
.positional('documents', { | ||
demandOption: true, | ||
})) | ||
.positional('documents', interceptPositional('documents', { | ||
describe: 'Point to docuents', | ||
type: 'string', | ||
}) | ||
.options({ | ||
demandOption: true, | ||
})) | ||
.options(interceptOptions({ | ||
d: { | ||
@@ -29,7 +32,2 @@ alias: 'deprecated', | ||
}, | ||
c: { | ||
alias: 'config', | ||
describe: 'Use GraphQL Config to find schema and documents', | ||
type: 'boolean', | ||
}, | ||
noStrictFragments: { | ||
@@ -54,17 +52,13 @@ describe: 'Do not fail on duplicated fragment names', | ||
}, | ||
}); | ||
})); | ||
}, | ||
handler(args) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const { loaders, pickPointers } = api; | ||
yield interceptArguments(args); | ||
const { headers, token } = parseGlobalArgs(args); | ||
const pointer = yield pickPointers(args, { | ||
schema: true, | ||
documents: true, | ||
}); | ||
const schema = yield loaders.loadSchema(pointer.schema, { | ||
const schema = yield loaders.loadSchema(args.schema, { | ||
headers, | ||
token, | ||
}); | ||
const documents = yield loaders.loadDocuments(pointer.documents); | ||
const documents = yield loaders.loadDocuments(args.documents); | ||
const invalidDocuments = validate(schema, documents.map((doc) => new Source(print(doc.document), doc.location)), { | ||
@@ -71,0 +65,0 @@ strictFragments: !args.noStrictFragments, |
{ | ||
"name": "@graphql-inspector/validate-command", | ||
"version": "0.0.0-canary.57e2caa", | ||
"version": "0.0.0-canary.6f0f272", | ||
"description": "Validate Documents in GraphQL Inspector", | ||
"sideEffects": false, | ||
"peerDependencies": { | ||
@@ -9,6 +10,6 @@ "graphql": "^0.13.0 || ^14.0.0 || ^15.0.0" | ||
"dependencies": { | ||
"@graphql-inspector/commands": "0.0.0-canary.57e2caa", | ||
"@graphql-inspector/core": "0.0.0-canary.57e2caa", | ||
"@graphql-inspector/logger": "0.0.0-canary.57e2caa", | ||
"tslib": "^1.11.1" | ||
"@graphql-inspector/commands": "0.0.0-canary.6f0f272", | ||
"@graphql-inspector/core": "0.0.0-canary.6f0f272", | ||
"@graphql-inspector/logger": "0.0.0-canary.6f0f272", | ||
"tslib": "^2.0.0" | ||
}, | ||
@@ -15,0 +16,0 @@ "repository": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
34488
291
+ Added@ardatan/aggregate-error@0.0.6(transitive)
+ Added@graphql-inspector/commands@0.0.0-canary.6f0f272(transitive)
+ Added@graphql-inspector/config@0.0.0-canary.6f0f272(transitive)
+ Added@graphql-inspector/core@0.0.0-canary.6f0f272(transitive)
+ Added@graphql-inspector/loaders@0.0.0-canary.6f0f272(transitive)
+ Added@graphql-inspector/logger@0.0.0-canary.6f0f272(transitive)
+ Added@graphql-tools/load@6.2.8(transitive)
+ Added@graphql-tools/merge@6.2.178.3.1(transitive)
+ Added@graphql-tools/schema@8.5.1(transitive)
+ Added@graphql-tools/utils@6.2.47.10.08.0.28.9.0(transitive)
+ Addedcamel-case@4.1.2(transitive)
+ Addedglobby@11.0.3(transitive)
+ Addedp-limit@3.1.0(transitive)
+ Addedtslib@2.0.32.2.02.3.1(transitive)
+ Addedvalue-or-promise@1.0.11(transitive)
+ Addedyocto-queue@0.1.0(transitive)
- Removed@babel/runtime@7.26.7(transitive)
- Removed@graphql-inspector/commands@0.0.0-canary.57e2caa(transitive)
- Removed@graphql-inspector/config@0.0.0-canary.57e2caa(transitive)
- Removed@graphql-inspector/core@0.0.0-canary.57e2caa(transitive)
- Removed@graphql-inspector/loaders@0.0.0-canary.57e2caa(transitive)
- Removed@graphql-inspector/logger@0.0.0-canary.57e2caa(transitive)
- Removed@graphql-toolkit/common@0.10.7(transitive)
- Removed@graphql-toolkit/core@0.10.7(transitive)
- Removed@graphql-toolkit/schema-merging@0.10.7(transitive)
- Removed@wry/equality@0.1.11(transitive)
- Removedaggregate-error@3.0.1(transitive)
- Removedapollo-link@1.2.14(transitive)
- Removedapollo-link-http-common@0.2.16(transitive)
- Removedapollo-upload-client@13.0.0(transitive)
- Removedapollo-utilities@1.3.4(transitive)
- Removedargparse@1.0.10(transitive)
- Removedasynckit@0.4.0(transitive)
- Removedbalanced-match@1.0.2(transitive)
- Removedbrace-expansion@1.1.11(transitive)
- Removedclean-stack@2.2.0(transitive)
- Removedcombined-stream@1.0.8(transitive)
- Removedconcat-map@0.0.1(transitive)
- Removeddeepmerge@4.2.2(transitive)
- Removeddelayed-stream@1.0.0(transitive)
- Removeddeprecated-decorator@0.1.6(transitive)
- Removedextract-files@8.1.0(transitive)
- Removedfast-json-stable-stringify@2.1.0(transitive)
- Removedform-data@3.0.2(transitive)
- Removedfs.realpath@1.0.0(transitive)
- Removedglob@7.2.3(transitive)
- Removedglobby@11.0.0(transitive)
- Removedgraphql-tools@5.0.0(transitive)
- Removedindent-string@4.0.0(transitive)
- Removedinflight@1.0.6(transitive)
- Removedinherits@2.0.4(transitive)
- Removediterall@1.3.0(transitive)
- Removedlodash@4.17.15(transitive)
- Removedmime-db@1.52.0(transitive)
- Removedmime-types@2.1.35(transitive)
- Removedminimatch@3.1.2(transitive)
- Removednode-fetch@2.7.0(transitive)
- Removedonce@1.4.0(transitive)
- Removedpath-is-absolute@1.0.1(transitive)
- Removedregenerator-runtime@0.14.1(transitive)
- Removedsprintf-js@1.0.3(transitive)
- Removedtr46@0.0.3(transitive)
- Removedts-invariant@0.4.4(transitive)
- Removedtslib@1.11.2(transitive)
- Removeduuid@7.0.3(transitive)
- Removedwebidl-conversions@3.0.1(transitive)
- Removedwhatwg-url@5.0.0(transitive)
- Removedwrappy@1.0.2(transitive)
- Removedyamljs@0.3.0(transitive)
- Removedzen-observable@0.8.15(transitive)
- Removedzen-observable-ts@0.8.21(transitive)
Updatedtslib@^2.0.0