babel-plugin-graphql-js-client-transform
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -24,3 +24,3 @@ /** | ||
* | ||
* Version: 1.0.1 Commit: d00fbde | ||
* Version: 1.0.3 Commit: 08b7df7 | ||
**/'use strict'; | ||
@@ -27,0 +27,0 @@ |
@@ -17,15 +17,16 @@ 'use strict'; | ||
if (argValue.kind === 'StringValue') { | ||
return t.stringLiteral(argValue.value); | ||
} else if (argValue.kind === 'EnumValue') { | ||
return t.callExpression(t.memberExpression(clientId, t.identifier('enum')), [t.stringLiteral(argValue.value)]); | ||
} else if (argValue.kind === 'IntValue') { | ||
return t.numericLiteral(parseInt(argValue.value, 10)); | ||
} else if (argValue.kind === 'FloatValue') { | ||
return t.numericLiteral(parseFloat(argValue.value)); | ||
} else if (argValue.kind === 'BooleanValue') { | ||
return t.booleanLiteral(argValue.value); | ||
} else { | ||
throw Error('Unrecognized type "' + argValue.kind + '"'); | ||
switch (argValue.kind) { | ||
case 'StringValue': | ||
return t.stringLiteral(argValue.value); | ||
case 'EnumValue': | ||
return t.callExpression(t.memberExpression(clientId, t.identifier('enum')), [t.stringLiteral(argValue.value)]); | ||
case 'IntValue': | ||
return t.numericLiteral(parseInt(argValue.value, 10)); | ||
case 'FloatValue': | ||
return t.numericLiteral(parseFloat(argValue.value)); | ||
case 'BooleanValue': | ||
return t.booleanLiteral(argValue.value); | ||
default: | ||
throw Error('Unrecognized type "' + argValue.kind + '"'); | ||
} | ||
} |
@@ -21,3 +21,11 @@ 'use strict'; | ||
function extractVariableType(variable) { | ||
return variable.type.kind === 'NonNullType' ? variable.type.type.name.value + '!' : variable.type.name.value; | ||
switch (variable.kind) { | ||
case 'NonNullType': | ||
return extractVariableType(variable.type) + '!'; | ||
case 'ListType': | ||
return '[' + extractVariableType(variable.type) + ']'; | ||
default: | ||
// NamedType | ||
return variable.name.value; | ||
} | ||
} | ||
@@ -30,3 +38,3 @@ | ||
var args = [t.stringLiteral(variable.variable.name.value), t.stringLiteral(extractVariableType(variable))]; | ||
var args = [t.stringLiteral(variable.variable.name.value), t.stringLiteral(extractVariableType(variable.type))]; | ||
@@ -33,0 +41,0 @@ if (variable.defaultValue) { |
{ | ||
"name": "babel-plugin-graphql-js-client-transform", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "Babel plugin for transforming raw GraphQL queries into graphql-js-client query builder syntax", | ||
@@ -5,0 +5,0 @@ "main": "lib/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
136925
321