graphql-tag
Advanced tools
Comparing version 1.2.2 to 1.2.3
21
index.js
@@ -26,7 +26,12 @@ var parse = require('./parser').parse; | ||
// Take a unstripped parsed document (query/mutation or even fragment), and | ||
// check all fragment definitions, checking for name->source uniqueness | ||
// check all fragment definitions, checking for name->source uniqueness. | ||
// We also want to make sure only unique fragments exist in the document. | ||
var printFragmentWarnings = true; | ||
function checkFragments(ast) { | ||
function processFragments(ast) { | ||
var astFragmentMap = {}; | ||
var definitions = []; | ||
for (var i = 0; i < ast.definitions.length; i++) { | ||
var fragmentDefinition = ast.definitions[i]; | ||
if (fragmentDefinition.kind === 'FragmentDefinition') { | ||
@@ -54,4 +59,14 @@ var fragmentName = fragmentDefinition.name.value; | ||
} | ||
if (!astFragmentMap[sourceKey]) { | ||
astFragmentMap[sourceKey] = true; | ||
definitions.push(fragmentDefinition); | ||
} | ||
} else { | ||
definitions.push(fragmentDefinition); | ||
} | ||
} | ||
ast.definitions = definitions; | ||
return ast; | ||
} | ||
@@ -113,3 +128,3 @@ | ||
// existing fragments of the same name | ||
checkFragments(parsed); | ||
parsed = processFragments(parsed); | ||
parsed = stripLoc(parsed, false); | ||
@@ -116,0 +131,0 @@ docCache[cacheKey] = parsed; |
{ | ||
"name": "graphql-tag", | ||
"version": "1.2.2", | ||
"version": "1.2.3", | ||
"description": "A JavaScript template literal tag that parses GraphQL queries", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
115141
3239