babel-plugin-graphql-js-client-transform
Advanced tools
Comparing version 1.1.0 to 1.1.1
@@ -24,3 +24,3 @@ /** | ||
* | ||
* Version: 1.1.0 Commit: e5f3eb1 | ||
* Version: 1.1.0 Commit: e8b1fa8 | ||
**/'use strict'; | ||
@@ -35,3 +35,3 @@ | ||
visitor: { | ||
ImportSpecifier: function ImportSpecifier(path, state) { | ||
ImportSpecifier(path, state) { | ||
// Find the gql import | ||
@@ -43,3 +43,4 @@ if (path.node.imported.name === 'gql') { | ||
}, | ||
TaggedTemplateExpression: function TaggedTemplateExpression(path, state) { | ||
TaggedTemplateExpression(path, state) { | ||
if (path.node.tag.callee && path.node.tag.callee.name === state.tag) { | ||
@@ -55,33 +56,18 @@ path.traverse(templateElementVisitor, { parentPath: path, clientId: path.node.tag.arguments[0] }); | ||
var _language = require('graphql/language'); | ||
var _graphqlToJsClientBuilder = require('graphql-to-js-client-builder'); | ||
var _babelTypes = require('babel-types'); | ||
const templateElementVisitor = { | ||
TemplateElement(path) { | ||
const statementParentPath = path.getStatementParent(); | ||
const clientVar = this.clientId.name; | ||
const documentVar = statementParentPath.scope.generateUidIdentifier('document').name; | ||
const spreadsVar = statementParentPath.scope.generateUidIdentifier('spreads').name; | ||
var t = _interopRequireWildcard(_babelTypes); | ||
const graphQlCode = path.node.value.raw; | ||
var _parseDocument = require('./parse-document'); | ||
const jsAst = (0, _graphqlToJsClientBuilder.transformToAst)(graphQlCode, clientVar, documentVar, spreadsVar); | ||
var _parseDocument2 = _interopRequireDefault(_parseDocument); | ||
statementParentPath.insertBefore(jsAst); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } | ||
var templateElementVisitor = { | ||
TemplateElement: function TemplateElement(path) { | ||
var statementParentPath = path.getStatementParent(); | ||
var documentId = statementParentPath.scope.generateUidIdentifier('document'); | ||
// Create the document to be sent | ||
statementParentPath.insertBefore(t.variableDeclaration('const', [t.variableDeclarator(documentId, t.callExpression(t.memberExpression(this.clientId, t.identifier('document')), []))])); | ||
// Parse the document into a GraphQL AST | ||
var document = (0, _language.parse)(path.node.value.raw); | ||
// Convert the GraphQL AST into a list of Babel AST nodes of the query building | ||
var babelAstNodes = (0, _parseDocument2.default)(document, documentId, statementParentPath.scope, this.clientId); | ||
statementParentPath.insertBefore(babelAstNodes); | ||
this.parentPath.replaceWith(documentId); | ||
this.parentPath.replaceWithSourceString(documentVar); | ||
} | ||
@@ -96,3 +82,4 @@ }; | ||
function gql() { | ||
throw new Error('This function should not be invoked. It should be used to tag template literals that will be\n transcompiled into graphql-js-client\'s query builder syntax.'); | ||
throw new Error(`This function should not be invoked. It should be used to tag template literals that will be | ||
transcompiled into graphql-js-client's query builder syntax.`); | ||
} |
{ | ||
"name": "babel-plugin-graphql-js-client-transform", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "Babel plugin for transforming raw GraphQL queries into graphql-js-client query builder syntax", | ||
@@ -9,15 +9,13 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"babel-types": "6.23.0", | ||
"graphql": "0.9.1" | ||
"graphql-to-js-client-builder": "0.0.1" | ||
}, | ||
"devDependencies": { | ||
"babel": "6.5.2", | ||
"babel-cli": "6.11.4", | ||
"babel-core": "6.13.2", | ||
"babel-cli": "6.24.1", | ||
"babel-core": "6.24.1", | ||
"babel-plugin-add-shopify-header": "1.0.5", | ||
"babel-preset-shopify": "13.0.0", | ||
"babel-register": "6.11.6", | ||
"babel-preset-shopify": "16.0.2", | ||
"babel-register": "6.24.1", | ||
"eslint": "3.3.1", | ||
"eslint-plugin-shopify": "14.0.0", | ||
"mocha": "3.0.2" | ||
"mocha": "3.4.2" | ||
}, | ||
@@ -24,0 +22,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
1
8
121355
13
84
1
+ Addedbabel-generator@6.24.1(transitive)
+ Addedbabel-messages@6.23.0(transitive)
+ Addedbabel-types@6.24.1(transitive)
+ Addeddetect-indent@4.0.0(transitive)
+ Addedgraphql@0.9.6(transitive)
+ Addedgraphql-to-js-client-builder@0.0.1(transitive)
+ Addedis-finite@1.1.0(transitive)
+ Addediterall@1.3.0(transitive)
+ Addedjsesc@1.3.0(transitive)
+ Addedrepeating@2.0.1(transitive)
+ Addedsource-map@0.5.7(transitive)
+ Addedtrim-right@1.0.1(transitive)
- Removedbabel-types@6.23.0
- Removedgraphql@0.9.1
- Removedbabel-types@6.23.0(transitive)
- Removedgraphql@0.9.1(transitive)
- Removediterall@1.0.3(transitive)