graphql-language-service-interface
Advanced tools
Comparing version 0.0.3 to 0.0.4
@@ -6,2 +6,3 @@ 'use strict'; | ||
}); | ||
exports.SEVERITY = undefined; | ||
exports.getDiagnostics = getDiagnostics; | ||
@@ -21,3 +22,3 @@ | ||
var SEVERITY = { | ||
var SEVERITY = exports.SEVERITY = { | ||
ERROR: 1, | ||
@@ -55,6 +56,16 @@ WARNING: 2, | ||
var errors = schema ? (0, _graphqlLanguageServiceUtils.validateWithCustomRules)(schema, ast, customRules) : []; | ||
return mapCat(errors, function (error) { | ||
return errorAnnotations(error); | ||
// We cannot validate the query unless a schema is provided. | ||
if (!schema) { | ||
return []; | ||
} | ||
var validationErrorAnnotations = mapCat((0, _graphqlLanguageServiceUtils.validateWithCustomRules)(schema, ast, customRules), function (error) { | ||
return annotations(error, SEVERITY.ERROR, 'Validation'); | ||
}); | ||
// Note: findDeprecatedUsages was added in graphql@0.9.0, but we want to | ||
// support older versions of graphql-js. | ||
var deprecationWarningAnnotations = !_graphql.findDeprecatedUsages ? [] : mapCat((0, _graphql.findDeprecatedUsages)(schema, ast), function (error) { | ||
return annotations(error, SEVERITY.WARNING, 'Deprecation'); | ||
}); | ||
return validationErrorAnnotations.concat(deprecationWarningAnnotations); | ||
} | ||
@@ -67,3 +78,3 @@ | ||
function errorAnnotations(error) { | ||
function annotations(error, severity, type) { | ||
if (!error.nodes) { | ||
@@ -79,5 +90,5 @@ return []; | ||
return { | ||
source: 'GraphQL: Validation', | ||
source: 'GraphQL: ' + type, | ||
message: error.message, | ||
severity: SEVERITY.ERROR, | ||
severity: severity, | ||
range: new _graphqlLanguageServiceUtils.Range(new _graphqlLanguageServiceUtils.Position(loc.line - 1, loc.column - 1), new _graphqlLanguageServiceUtils.Position(loc.line - 1, end)) | ||
@@ -84,0 +95,0 @@ }; |
{ | ||
"name": "graphql-language-service-interface", | ||
"repository": "https://github.com/graphql/graphql-language-service", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "Interface to the GraphQL Language Service", | ||
@@ -6,0 +6,0 @@ "contributors": [ |
Sorry, the diff of this file is not supported yet
88349
1146