@graphql-inspector/core
Advanced tools
Comparing version 0.6.2 to 0.6.3
@@ -1,2 +0,2 @@ | ||
import { GraphQLInputType, GraphQLOutputType, GraphQLNamedType } from 'graphql'; | ||
import { GraphQLInputType, GraphQLOutputType, GraphQLNamedType, GraphQLSchema, GraphQLError, DocumentNode } from 'graphql'; | ||
export declare function safeChangeForField(oldType: GraphQLOutputType, newType: GraphQLOutputType): boolean; | ||
@@ -7,1 +7,2 @@ export declare function safeChangeForInputValue(oldType: GraphQLInputType, newType: GraphQLInputType): boolean; | ||
export declare function isForIntrospection(type: GraphQLNamedType | string): boolean; | ||
export declare function findDeprecatedUsages(schema: GraphQLSchema, ast: DocumentNode): Array<GraphQLError>; |
@@ -65,2 +65,30 @@ "use strict"; | ||
exports.isForIntrospection = isForIntrospection; | ||
function findDeprecatedUsages(schema, ast) { | ||
var errors = []; | ||
var typeInfo = new graphql_1.TypeInfo(schema); | ||
graphql_1.visit(ast, graphql_1.visitWithTypeInfo(typeInfo, { | ||
Field: function (node) { | ||
var fieldDef = typeInfo.getFieldDef(); | ||
if (fieldDef && fieldDef.isDeprecated) { | ||
var parentType = typeInfo.getParentType(); | ||
if (parentType) { | ||
var reason = fieldDef.deprecationReason; | ||
errors.push(new graphql_1.GraphQLError("The field '" + parentType.name + "." + fieldDef.name + "' is deprecated." + (reason ? ' ' + reason : ''), [node])); | ||
} | ||
} | ||
}, | ||
EnumValue: function (node) { | ||
var enumVal = typeInfo.getEnumValue(); | ||
if (enumVal && enumVal.isDeprecated) { | ||
var type = graphql_1.getNamedType(typeInfo.getInputType()); | ||
if (type) { | ||
var reason = enumVal.deprecationReason; | ||
errors.push(new graphql_1.GraphQLError("The enum value '" + type.name + "." + enumVal.name + "' is deprecated." + (reason ? ' ' + reason : ''), [node])); | ||
} | ||
} | ||
}, | ||
})); | ||
return errors; | ||
} | ||
exports.findDeprecatedUsages = findDeprecatedUsages; | ||
//# sourceMappingURL=graphql.js.map |
@@ -5,3 +5,4 @@ import { GraphQLSchema, GraphQLError, Source } from 'graphql'; | ||
errors: GraphQLError[]; | ||
deprecated: GraphQLError[]; | ||
} | ||
export declare function validate(schema: GraphQLSchema, sources: Source[]): InvalidDocument[]; |
@@ -5,2 +5,3 @@ "use strict"; | ||
var document_1 = require("../ast/document"); | ||
var graphql_2 = require("../utils/graphql"); | ||
function validate(schema, sources) { | ||
@@ -22,6 +23,8 @@ var invalidDocuments = []; | ||
graphql_1.parse("\n " + doc.source.body + "\n\n " + fragments.map(graphql_1.print).join('\n\n') + "\n ")); | ||
if (errors) { | ||
var deprecated = graphql_2.findDeprecatedUsages(schema, graphql_1.parse(doc.source.body)); | ||
if (errors || deprecated) { | ||
invalidDocuments.push({ | ||
source: doc.source, | ||
errors: errors, | ||
deprecated: deprecated, | ||
}); | ||
@@ -28,0 +31,0 @@ } |
{ | ||
"name": "@graphql-inspector/core", | ||
"version": "0.6.2", | ||
"version": "0.6.3", | ||
"description": "Tooling for GraphQL. Compare GraphQL Schemas, check documents, find breaking changes, find similar types.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
133067
1626