@graphql-inspector/core
Advanced tools
Comparing version 1.19.0 to 1.20.0
@@ -17,3 +17,3 @@ "use strict"; | ||
var parent = typeInfo.getParentType(); | ||
if (parent && fieldDef) { | ||
if (parent && fieldDef && fieldDef.name !== '__typename') { | ||
var locations = coverage.types[parent.name].children[fieldDef.name].locations[source.name]; | ||
@@ -20,0 +20,0 @@ coverage.types[parent.name].hits++; |
@@ -7,2 +7,6 @@ import { GraphQLSchema, GraphQLError, Source } from 'graphql'; | ||
} | ||
export declare function validate(schema: GraphQLSchema, sources: Source[]): InvalidDocument[]; | ||
export interface ValidateOptions { | ||
strictFragments?: boolean; | ||
strictDeprecated?: boolean; | ||
} | ||
export declare function validate(schema: GraphQLSchema, sources: Source[], options?: ValidateOptions): InvalidDocument[]; |
"use strict"; | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -7,3 +18,4 @@ var graphql_1 = require("graphql"); | ||
var graphql_2 = require("../utils/graphql"); | ||
function validate(schema, sources) { | ||
function validate(schema, sources, options) { | ||
var config = __assign({ strictDeprecated: true, strictFragments: true }, options); | ||
var invalidDocuments = []; | ||
@@ -55,4 +67,8 @@ // read documents | ||
var errors = graphql_1.validate(schema, merged); | ||
var deprecated = graphql_2.findDeprecatedUsages(schema, graphql_1.parse(doc.source.body)); | ||
var duplicatedFragments = findDuplicatedFragments(fragmentNames); | ||
var deprecated = config.strictDeprecated | ||
? graphql_2.findDeprecatedUsages(schema, graphql_1.parse(doc.source.body)) | ||
: []; | ||
var duplicatedFragments = config.strictFragments | ||
? findDuplicatedFragments(fragmentNames) | ||
: []; | ||
if (sumLengths(errors, duplicatedFragments, deprecated) > 0) { | ||
@@ -59,0 +75,0 @@ invalidDocuments.push({ |
{ | ||
"name": "@graphql-inspector/core", | ||
"version": "1.19.0", | ||
"version": "1.20.0", | ||
"description": "Tooling for GraphQL. Compare GraphQL Schemas, check documents, find breaking changes, find similar types.", | ||
@@ -41,4 +41,4 @@ "keywords": [ | ||
"ts-jest": "24.0.2", | ||
"typescript": "3.4.5" | ||
"typescript": "3.5.1" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
878527
1916