graphql-language-service-interface
Advanced tools
Comparing version 0.1.12 to 0.1.13
@@ -8,2 +8,3 @@ 'use strict'; | ||
exports.getDiagnostics = getDiagnostics; | ||
exports.validateQuery = validateQuery; | ||
exports.getRange = getRange; | ||
@@ -40,3 +41,3 @@ | ||
function getDiagnostics(ast) { | ||
function getDiagnostics(query) { | ||
var schema = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; | ||
@@ -46,2 +47,23 @@ var customRules = arguments[2]; | ||
var ast = null; | ||
try { | ||
ast = (0, _graphql.parse)(query); | ||
} catch (error) { | ||
var range = getRange(error.locations[0], query); | ||
return [{ | ||
severity: SEVERITY.ERROR, | ||
message: error.message, | ||
source: 'GraphQL: Syntax', | ||
range: range | ||
}]; | ||
} | ||
return validateQuery(ast, schema, customRules, isRelayCompatMode); | ||
} | ||
function validateQuery(ast) { | ||
var schema = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; | ||
var customRules = arguments[2]; | ||
var isRelayCompatMode = arguments[3]; | ||
// We cannot validate the query unless a schema is provided. | ||
@@ -48,0 +70,0 @@ if (!schema) { |
@@ -145,3 +145,3 @@ 'use strict'; | ||
return _context.abrupt('return', (0, _getDiagnostics.getDiagnostics)(validationAst, schema, customRules, isRelayCompatMode)); | ||
return _context.abrupt('return', (0, _getDiagnostics.validateQuery)(validationAst, schema, customRules, isRelayCompatMode)); | ||
@@ -148,0 +148,0 @@ case 38: |
@@ -78,2 +78,8 @@ 'use strict'; | ||
}); | ||
Object.defineProperty(exports, 'validateQuery', { | ||
enumerable: true, | ||
get: function get() { | ||
return _getDiagnostics.validateQuery; | ||
} | ||
}); | ||
@@ -80,0 +86,0 @@ var _getOutline = require('./getOutline'); |
{ | ||
"name": "graphql-language-service-interface", | ||
"repository": "https://github.com/graphql/graphql-language-service", | ||
"version": "0.1.12", | ||
"version": "0.1.13", | ||
"description": "Interface to the GraphQL Language Service", | ||
@@ -6,0 +6,0 @@ "contributors": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
94484
1270