@graphql-inspector/validate-command
Advanced tools
Comparing version 1.30.0-rc.0 to 1.30.1
'use strict'; | ||
const tslib = require('tslib'); | ||
const commands = require('@graphql-inspector/commands'); | ||
@@ -52,48 +53,50 @@ const logger = require('@graphql-inspector/logger'); | ||
}, | ||
async handler(args) { | ||
const { loaders } = api; | ||
const schema = await loaders.loadSchema(args.schema, { | ||
token: args.token, | ||
headers: args.headers, | ||
}); | ||
const documents = await loaders.loadDocuments(args.documents); | ||
const invalidDocuments = core.validate(schema, documents.map((doc) => new graphql.Source(graphql.print(doc.document), doc.location)), { | ||
strictFragments: !args.noStrictFragments, | ||
maxDepth: args.maxDepth || undefined, | ||
apollo: args.apollo || false, | ||
keepClientFields: args.keepClientFields || false, | ||
}); | ||
if (!invalidDocuments.length) { | ||
logger.Logger.success('All documents are valid'); | ||
} | ||
else { | ||
const errorsCount = countErrors(invalidDocuments); | ||
const deprecated = countDeprecated(invalidDocuments); | ||
if (errorsCount) { | ||
logger.Logger.log(`\nDetected ${errorsCount} invalid document${errorsCount > 1 ? 's' : ''}:\n`); | ||
invalidDocuments.forEach((doc) => { | ||
if (doc.errors.length) { | ||
renderInvalidDocument(doc).forEach((line) => { | ||
logger.Logger.log(line); | ||
}); | ||
} | ||
}); | ||
} | ||
else if (!args.deprecated) { | ||
handler(args) { | ||
return tslib.__awaiter(this, void 0, void 0, function* () { | ||
const { loaders } = api; | ||
const schema = yield loaders.loadSchema(args.schema, { | ||
token: args.token, | ||
headers: args.headers, | ||
}); | ||
const documents = yield loaders.loadDocuments(args.documents); | ||
const invalidDocuments = core.validate(schema, documents.map((doc) => new graphql.Source(graphql.print(doc.document), doc.location)), { | ||
strictFragments: !args.noStrictFragments, | ||
maxDepth: args.maxDepth || undefined, | ||
apollo: args.apollo || false, | ||
keepClientFields: args.keepClientFields || false, | ||
}); | ||
if (!invalidDocuments.length) { | ||
logger.Logger.success('All documents are valid'); | ||
} | ||
if (deprecated) { | ||
logger.Logger.info(`\nDetected ${deprecated} document${deprecated > 1 ? 's' : ''} with deprecated fields:\n`); | ||
invalidDocuments.forEach((doc) => { | ||
if (doc.deprecated.length) { | ||
renderDeprecatedUsageInDocument(doc, args.deprecated).forEach((line) => { | ||
logger.Logger.log(line); | ||
}); | ||
} | ||
}); | ||
else { | ||
const errorsCount = countErrors(invalidDocuments); | ||
const deprecated = countDeprecated(invalidDocuments); | ||
if (errorsCount) { | ||
logger.Logger.log(`\nDetected ${errorsCount} invalid document${errorsCount > 1 ? 's' : ''}:\n`); | ||
invalidDocuments.forEach((doc) => { | ||
if (doc.errors.length) { | ||
renderInvalidDocument(doc).forEach((line) => { | ||
logger.Logger.log(line); | ||
}); | ||
} | ||
}); | ||
} | ||
else if (!args.deprecated) { | ||
logger.Logger.success('All documents are valid'); | ||
} | ||
if (deprecated) { | ||
logger.Logger.info(`\nDetected ${deprecated} document${deprecated > 1 ? 's' : ''} with deprecated fields:\n`); | ||
invalidDocuments.forEach((doc) => { | ||
if (doc.deprecated.length) { | ||
renderDeprecatedUsageInDocument(doc, args.deprecated).forEach((line) => { | ||
logger.Logger.log(line); | ||
}); | ||
} | ||
}); | ||
} | ||
if (errorsCount || (deprecated && args.deprecated)) { | ||
process.exit(1); | ||
} | ||
} | ||
if (errorsCount || (deprecated && args.deprecated)) { | ||
process.exit(1); | ||
} | ||
} | ||
}); | ||
}, | ||
@@ -100,0 +103,0 @@ }; |
@@ -0,1 +1,2 @@ | ||
import { __awaiter } from 'tslib'; | ||
import { createCommand } from '@graphql-inspector/commands'; | ||
@@ -50,48 +51,50 @@ import { Logger, chalk, bolderize } from '@graphql-inspector/logger'; | ||
}, | ||
async handler(args) { | ||
const { loaders } = api; | ||
const schema = await loaders.loadSchema(args.schema, { | ||
token: args.token, | ||
headers: args.headers, | ||
}); | ||
const documents = await loaders.loadDocuments(args.documents); | ||
const invalidDocuments = validate(schema, documents.map((doc) => new Source(print(doc.document), doc.location)), { | ||
strictFragments: !args.noStrictFragments, | ||
maxDepth: args.maxDepth || undefined, | ||
apollo: args.apollo || false, | ||
keepClientFields: args.keepClientFields || false, | ||
}); | ||
if (!invalidDocuments.length) { | ||
Logger.success('All documents are valid'); | ||
} | ||
else { | ||
const errorsCount = countErrors(invalidDocuments); | ||
const deprecated = countDeprecated(invalidDocuments); | ||
if (errorsCount) { | ||
Logger.log(`\nDetected ${errorsCount} invalid document${errorsCount > 1 ? 's' : ''}:\n`); | ||
invalidDocuments.forEach((doc) => { | ||
if (doc.errors.length) { | ||
renderInvalidDocument(doc).forEach((line) => { | ||
Logger.log(line); | ||
}); | ||
} | ||
}); | ||
} | ||
else if (!args.deprecated) { | ||
handler(args) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const { loaders } = api; | ||
const schema = yield loaders.loadSchema(args.schema, { | ||
token: args.token, | ||
headers: args.headers, | ||
}); | ||
const documents = yield loaders.loadDocuments(args.documents); | ||
const invalidDocuments = validate(schema, documents.map((doc) => new Source(print(doc.document), doc.location)), { | ||
strictFragments: !args.noStrictFragments, | ||
maxDepth: args.maxDepth || undefined, | ||
apollo: args.apollo || false, | ||
keepClientFields: args.keepClientFields || false, | ||
}); | ||
if (!invalidDocuments.length) { | ||
Logger.success('All documents are valid'); | ||
} | ||
if (deprecated) { | ||
Logger.info(`\nDetected ${deprecated} document${deprecated > 1 ? 's' : ''} with deprecated fields:\n`); | ||
invalidDocuments.forEach((doc) => { | ||
if (doc.deprecated.length) { | ||
renderDeprecatedUsageInDocument(doc, args.deprecated).forEach((line) => { | ||
Logger.log(line); | ||
}); | ||
} | ||
}); | ||
else { | ||
const errorsCount = countErrors(invalidDocuments); | ||
const deprecated = countDeprecated(invalidDocuments); | ||
if (errorsCount) { | ||
Logger.log(`\nDetected ${errorsCount} invalid document${errorsCount > 1 ? 's' : ''}:\n`); | ||
invalidDocuments.forEach((doc) => { | ||
if (doc.errors.length) { | ||
renderInvalidDocument(doc).forEach((line) => { | ||
Logger.log(line); | ||
}); | ||
} | ||
}); | ||
} | ||
else if (!args.deprecated) { | ||
Logger.success('All documents are valid'); | ||
} | ||
if (deprecated) { | ||
Logger.info(`\nDetected ${deprecated} document${deprecated > 1 ? 's' : ''} with deprecated fields:\n`); | ||
invalidDocuments.forEach((doc) => { | ||
if (doc.deprecated.length) { | ||
renderDeprecatedUsageInDocument(doc, args.deprecated).forEach((line) => { | ||
Logger.log(line); | ||
}); | ||
} | ||
}); | ||
} | ||
if (errorsCount || (deprecated && args.deprecated)) { | ||
process.exit(1); | ||
} | ||
} | ||
if (errorsCount || (deprecated && args.deprecated)) { | ||
process.exit(1); | ||
} | ||
} | ||
}); | ||
}, | ||
@@ -98,0 +101,0 @@ }; |
{ | ||
"name": "@graphql-inspector/validate-command", | ||
"version": "1.30.0-rc.0", | ||
"version": "1.30.1", | ||
"description": "Validate Documents in GraphQL Inspector", | ||
@@ -8,8 +8,2 @@ "peerDependencies": { | ||
}, | ||
"dependencies": { | ||
"@graphql-inspector/commands": "1.30.0-rc.0", | ||
"@graphql-inspector/core": "1.30.0-rc.0", | ||
"@graphql-inspector/logger": "1.30.0-rc.0", | ||
"tslib": "^1.11.1" | ||
}, | ||
"repository": { | ||
@@ -16,0 +10,0 @@ "type": "git", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
32888
1
286
1
- Removed@graphql-inspector/core@1.30.0-rc.0
- Removedtslib@^1.11.1
- Removed@babel/code-frame@7.24.7(transitive)
- Removed@babel/helper-validator-identifier@7.24.7(transitive)
- Removed@babel/highlight@7.24.7(transitive)
- Removed@graphql-inspector/commands@1.30.0-rc.0(transitive)
- Removed@graphql-inspector/config@1.30.0-rc.0(transitive)
- Removed@graphql-inspector/core@1.30.0-rc.0(transitive)
- Removed@graphql-inspector/loaders@1.30.0-rc.0(transitive)
- Removed@graphql-inspector/logger@1.30.0-rc.0(transitive)
- Removed@graphql-toolkit/common@0.10.2(transitive)
- Removed@graphql-toolkit/core@0.10.2(transitive)
- Removed@graphql-toolkit/schema-merging@0.10.2(transitive)
- Removed@nodelib/fs.scandir@2.1.5(transitive)
- Removed@nodelib/fs.stat@2.0.5(transitive)
- Removed@nodelib/fs.walk@1.2.8(transitive)
- Removed@types/parse-json@4.0.2(transitive)
- Removed@wry/equality@0.1.11(transitive)
- Removedaggregate-error@3.0.1(transitive)
- Removedansi-regex@5.0.1(transitive)
- Removedansi-styles@3.2.14.3.0(transitive)
- Removedapollo-link@1.2.14(transitive)
- Removedapollo-link-http-common@0.2.16(transitive)
- Removedapollo-utilities@1.3.4(transitive)
- Removedarray-union@2.1.0(transitive)
- Removedasynckit@0.4.0(transitive)
- Removedbraces@3.0.3(transitive)
- Removedcallsites@3.1.0(transitive)
- Removedcamel-case@4.1.1(transitive)
- Removedcamelcase@5.3.1(transitive)
- Removedchalk@2.4.23.0.0(transitive)
- Removedci-info@1.6.0(transitive)
- Removedclean-stack@2.2.0(transitive)
- Removedcliui@6.0.0(transitive)
- Removedcolor-convert@1.9.32.0.1(transitive)
- Removedcolor-name@1.1.31.1.4(transitive)
- Removedcombined-stream@1.0.8(transitive)
- Removedcosmiconfig@6.0.0(transitive)
- Removeddecamelize@1.2.0(transitive)
- Removeddeepmerge@4.2.2(transitive)
- Removeddelayed-stream@1.0.0(transitive)
- Removeddependency-graph@0.9.0(transitive)
- Removeddeprecated-decorator@0.1.6(transitive)
- Removeddir-glob@3.0.1(transitive)
- Removedemoji-regex@8.0.0(transitive)
- Removederror-ex@1.3.2(transitive)
- Removedescape-string-regexp@1.0.5(transitive)
- Removedextract-files@7.0.0(transitive)
- Removedfast-glob@3.3.2(transitive)
- Removedfast-json-stable-stringify@2.1.0(transitive)
- Removedfastq@1.17.1(transitive)
- Removedfigures@3.2.0(transitive)
- Removedfill-range@7.1.1(transitive)
- Removedfind-up@4.1.0(transitive)
- Removedform-data@3.0.1(transitive)
- Removedget-caller-file@2.0.5(transitive)
- Removedglob-parent@5.1.2(transitive)
- Removedglobby@11.0.0(transitive)
- Removedgraphql-tools-fork@9.0.1(transitive)
- Removedhas-flag@3.0.04.0.0(transitive)
- Removedignore@5.3.1(transitive)
- Removedimport-fresh@3.3.0(transitive)
- Removedimport-from@3.0.0(transitive)
- Removedindent-string@4.0.0(transitive)
- Removedis-arrayish@0.2.1(transitive)
- Removedis-extglob@2.1.1(transitive)
- Removedis-fullwidth-code-point@3.0.0(transitive)
- Removedis-glob@4.0.1(transitive)
- Removedis-number@7.0.0(transitive)
- Removediterall@1.3.0(transitive)
- Removedjs-tokens@4.0.0(transitive)
- Removedjson-parse-even-better-errors@2.3.1(transitive)
- Removedlines-and-columns@1.2.4(transitive)
- Removedlocate-path@5.0.0(transitive)
- Removedlodash@4.17.15(transitive)
- Removedlog-symbols@3.0.0(transitive)
- Removedlower-case@2.0.2(transitive)
- Removedmerge2@1.4.1(transitive)
- Removedmicromatch@4.0.7(transitive)
- Removedmime-db@1.52.0(transitive)
- Removedmime-types@2.1.35(transitive)
- Removedno-case@3.0.4(transitive)
- Removednode-fetch@2.7.0(transitive)
- Removednormalize-path@2.1.1(transitive)
- Removedp-limit@2.2.2(transitive)
- Removedp-locate@4.1.0(transitive)
- Removedp-try@2.2.0(transitive)
- Removedparent-module@1.0.1(transitive)
- Removedparse-json@5.2.0(transitive)
- Removedpascal-case@3.1.2(transitive)
- Removedpath-exists@4.0.0(transitive)
- Removedpath-type@4.0.0(transitive)
- Removedpicocolors@1.0.1(transitive)
- Removedpicomatch@2.3.1(transitive)
- Removedqueue-microtask@1.2.3(transitive)
- Removedremove-trailing-separator@1.1.0(transitive)
- Removedrequire-directory@2.1.1(transitive)
- Removedrequire-main-filename@2.0.0(transitive)
- Removedresolve-from@4.0.05.0.0(transitive)
- Removedreusify@1.0.4(transitive)
- Removedrun-parallel@1.2.0(transitive)
- Removedset-blocking@2.0.0(transitive)
- Removedslash@3.0.0(transitive)
- Removedstd-env@2.2.1(transitive)
- Removedstring-width@4.2.3(transitive)
- Removedstrip-ansi@6.0.1(transitive)
- Removedsupports-color@5.5.07.2.0(transitive)
- Removedto-regex-range@5.0.1(transitive)
- Removedtr46@0.0.3(transitive)
- Removedts-invariant@0.4.4(transitive)
- Removedtslib@1.11.11.14.12.6.3(transitive)
- Removedunixify@1.0.0(transitive)
- Removeduuid@7.0.3(transitive)
- Removedvalid-url@1.0.9(transitive)
- Removedwebidl-conversions@3.0.1(transitive)
- Removedwhatwg-url@5.0.0(transitive)
- Removedwhich-module@2.0.1(transitive)
- Removedwrap-ansi@6.2.0(transitive)
- Removedy18n@4.0.3(transitive)
- Removedyaml@1.10.2(transitive)
- Removedyargs@15.3.1(transitive)
- Removedyargs-parser@18.1.3(transitive)
- Removedzen-observable@0.8.15(transitive)
- Removedzen-observable-ts@0.8.21(transitive)