babel-relay-plugin
Advanced tools
Comparing version 0.7.0 to 0.7.1
@@ -56,2 +56,3 @@ // @generated | ||
file: { | ||
code: state.code != null ? state.code : state.file.code, | ||
opts: { | ||
@@ -58,0 +59,0 @@ basename: path.basename(filename, path.extname(filename)), |
@@ -22,5 +22,7 @@ // @generated | ||
var babelAdapter = require('./babelAdapter'); | ||
var generateHash = require('./generateHash'); | ||
var invariant = require('./invariant'); | ||
var util = require('util'); | ||
var HASH_LENGTH = 12; | ||
var PROVIDES_MODULE = 'providesModule'; | ||
@@ -101,2 +103,13 @@ | ||
var _path$node$loc$start = path.node.loc.start; | ||
var line = _path$node$loc$start.line; | ||
var column = _path$node$loc$start.column; | ||
var fragmentLocationID = generateHash(JSON.stringify({ | ||
filename: state.file.filename, | ||
code: state.file.code, | ||
line: line, | ||
column: column | ||
})).substring(0, HASH_LENGTH); | ||
var p = path; | ||
@@ -112,3 +125,8 @@ var propName = null; | ||
try { | ||
result = transformer.transform(t, node.quasi, documentName, tagName, propName); | ||
result = transformer.transform(t, node.quasi, { | ||
documentName: documentName, | ||
fragmentLocationID: fragmentLocationID, | ||
tagName: tagName, | ||
propName: propName | ||
}); | ||
} catch (error) { | ||
@@ -115,0 +133,0 @@ // Print a console warning and replace the code with a function |
@@ -40,2 +40,4 @@ // @generated | ||
var _nextFragmentID = 0; | ||
var RelayQLNode = (function () { | ||
@@ -150,2 +152,3 @@ function RelayQLNode(context, ast) { | ||
_get(Object.getPrototypeOf(RelayQLFragment.prototype), 'constructor', this).call(this, _extends({}, context, { isPattern: isPattern }), ast); | ||
this.fragmentID = null; | ||
this.parentType = parentType; | ||
@@ -155,2 +158,14 @@ } | ||
_createClass(RelayQLFragment, [{ | ||
key: 'getFragmentID', | ||
value: function getFragmentID() { | ||
if (this.fragmentID == null) { | ||
var suffix = (_nextFragmentID++).toString(32); | ||
// The fragmentLocationID is the same for all inline/nested fragments | ||
// within each Relay.QL tagged template expression; the auto-incrementing | ||
// suffix distinguishes these fragments from each other. | ||
this.fragmentID = this.context.fragmentLocationID + ':' + suffix; | ||
} | ||
return this.fragmentID; | ||
} | ||
}, { | ||
key: 'getType', | ||
@@ -157,0 +172,0 @@ value: function getType() { |
@@ -190,2 +190,3 @@ // @generated | ||
directives: this.printDirectives(fragment.getDirectives()), | ||
id: t.valueToNode(fragment.getFragmentID()), | ||
kind: t.valueToNode('Fragment'), | ||
@@ -192,0 +193,0 @@ metadata: metadata, |
@@ -59,4 +59,4 @@ // @generated | ||
value: function transform(t, // Babel | ||
node, documentName, tagName, propName) { | ||
var _processTemplateLiteral = this.processTemplateLiteral(node, documentName); | ||
node, options) { | ||
var _processTemplateLiteral = this.processTemplateLiteral(node, options.documentName); | ||
@@ -67,7 +67,7 @@ var substitutions = _processTemplateLiteral.substitutions; | ||
var documentText = this.processTemplateText(templateText, documentName, propName); | ||
var definition = this.processDocumentText(documentText, documentName); | ||
var documentText = this.processTemplateText(templateText, options); | ||
var definition = this.processDocumentText(documentText, options); | ||
var Printer = RelayQLPrinter(t, this.options); | ||
return new Printer(tagName, variableNames).print(definition, substitutions); | ||
return new Printer(options.tagName, variableNames).print(definition, substitutions); | ||
} | ||
@@ -112,3 +112,6 @@ | ||
key: 'processTemplateText', | ||
value: function processTemplateText(templateText, documentName, propName) { | ||
value: function processTemplateText(templateText, _ref) { | ||
var documentName = _ref.documentName; | ||
var propName = _ref.propName; | ||
var pattern = /^(fragment|mutation|query|subscription)\s*(\w*)?([\s\S]*)/; | ||
@@ -134,3 +137,6 @@ var matches = pattern.exec(templateText); | ||
key: 'processDocumentText', | ||
value: function processDocumentText(documentText, documentName) { | ||
value: function processDocumentText(documentText, _ref2) { | ||
var documentName = _ref2.documentName; | ||
var fragmentLocationID = _ref2.fragmentLocationID; | ||
var document = parser.parse(new Source(documentText, documentName)); | ||
@@ -149,3 +155,5 @@ var validationErrors = this.validateDocument(document); | ||
isPattern: false, | ||
schema: this.schema | ||
nodeIndex: 0, | ||
schema: this.schema, | ||
fragmentLocationID: fragmentLocationID | ||
}; | ||
@@ -152,0 +160,0 @@ if (definition.kind === 'FragmentDefinition') { |
{ | ||
"name": "babel-relay-plugin", | ||
"version": "0.7.0", | ||
"version": "0.7.1", | ||
"description": "Babel Relay Plugin for transpiling GraphQL queries for use with Relay.", | ||
@@ -10,2 +10,3 @@ "license": "BSD-3-Clause", | ||
"build": "scripts/build-lib", | ||
"lint": "eslint .", | ||
"prepublish": "npm run build", | ||
@@ -25,6 +26,8 @@ "test": "f() { EXIT=0; npm run typecheck || EXIT=$?; NODE_ENV=test jest $@ || EXIT=$?; exit $EXIT; }; f", | ||
"babel-core": "^5.8.35", | ||
"babel-eslint": "^4.1.1", | ||
"babel-jest": "^5.3.0", | ||
"eslint": "^1.3.1", | ||
"flow-bin": "0.21.0", | ||
"glob": "^5.0.15", | ||
"jest-cli": "^0.8.2", | ||
"jest-cli": "0.9.0-fb1", | ||
"minimist": "^1.1.3", | ||
@@ -35,3 +38,3 @@ "mkdirp": "^0.5.1", | ||
"dependencies": { | ||
"graphql": "0.4.17" | ||
"graphql": "^0.4.17" | ||
}, | ||
@@ -38,0 +41,0 @@ "jest": { |
Sorry, the diff of this file is not supported yet
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
89146
19
2025
10
+ Addedgraphql@0.4.18(transitive)
- Removedgraphql@0.4.17(transitive)
Updatedgraphql@^0.4.17