graphql-query-complexity
Advanced tools
Comparing version 0.1.1 to 0.1.2
@@ -46,3 +46,2 @@ 'use strict'; | ||
this.options = options; | ||
this.fragments = this.getFragments(context); | ||
@@ -56,13 +55,2 @@ this.OperationDefinition = { | ||
(0, _createClass3.default)(QueryComplexity, [{ | ||
key: 'getFragments', | ||
value: function getFragments(context) { | ||
return context.getDocument().definitions.reduce(function (map, definition) { | ||
if (definition.kind === _graphql.Kind.FRAGMENT_DEFINITION) { | ||
map[definition.name.value] = definition; | ||
} | ||
return map; | ||
}, {}); | ||
} | ||
}, { | ||
key: 'onOperationDefinitionEnter', | ||
@@ -121,3 +109,8 @@ value: function onOperationDefinitionEnter(operation) { | ||
// Get arguments | ||
var args = (0, _values.getArgumentValues)(field, childNode, _this.options.variables || {}); | ||
var args = void 0; | ||
try { | ||
args = (0, _values.getArgumentValues)(field, childNode, _this.options.variables || {}); | ||
} catch (e) { | ||
return _this.context.reportError(e); | ||
} | ||
@@ -147,3 +140,3 @@ // Check if we have child complexity | ||
{ | ||
var fragment = _this.fragments[childNode.name.value]; | ||
var fragment = _this.context.getFragment(childNode.name.value); | ||
var fragmentType = _this.context.getSchema().getType(fragment.typeCondition.name.value); | ||
@@ -150,0 +143,0 @@ nodeComplexity = _this.nodeComplexity(fragment, fragmentType); |
{ | ||
"name": "graphql-query-complexity", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "Validation rule for GraphQL query complexity analysis", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
20910
170