babel-relay-plugin
Advanced tools
Comparing version 0.7.1 to 0.7.2
@@ -18,6 +18,7 @@ // @generated | ||
var babel = require('babel-core'); | ||
var path = require('path'); | ||
function babelAdapter(Plugin, t, name, visitorsBuilder) { | ||
if (Plugin == null) { | ||
if (Plugin == null || /^6\./.test(babel.version)) { | ||
// Babel 6. | ||
@@ -24,0 +25,0 @@ return visitorsBuilder(t); |
@@ -165,3 +165,3 @@ // @generated | ||
} | ||
if (options.abortOnError) { | ||
if (state.opts && state.opts.enforceSchema) { | ||
throw new Error('Aborting due to GraphQL validation/transform error(s).'); | ||
@@ -168,0 +168,0 @@ } |
@@ -40,4 +40,2 @@ // @generated | ||
var _nextFragmentID = 0; | ||
var RelayQLNode = (function () { | ||
@@ -160,3 +158,3 @@ function RelayQLNode(context, ast) { | ||
if (this.fragmentID == null) { | ||
var suffix = (_nextFragmentID++).toString(32); | ||
var suffix = this.context.generateID(); | ||
// The fragmentLocationID is the same for all inline/nested fragments | ||
@@ -438,17 +436,9 @@ // within each Relay.QL tagged template expression; the auto-incrementing | ||
var value = this.ast.value; | ||
switch (value.kind) { | ||
case 'IntValue': | ||
return parseInt(value.value, 10); | ||
case 'FloatValue': | ||
return parseFloat(value.value); | ||
case 'StringValue': | ||
case 'BooleanValue': | ||
case 'EnumValue': | ||
return value.value; | ||
case 'ListValue': | ||
return value.values.map(function (value) { | ||
return new RelayQLArgument(_this6.context, _extends({}, _this6.ast, { value: value }), _this6.type.ofType()); | ||
}); | ||
if (value.kind === 'ListValue') { | ||
return value.values.map(function (value) { | ||
return new RelayQLArgument(_this6.context, _extends({}, _this6.ast, { value: value }), _this6.type.ofType()); | ||
}); | ||
} else { | ||
return getLiteralValue(value); | ||
} | ||
invariant(false, 'Unexpected argument kind: %s', value.kind); | ||
} | ||
@@ -823,2 +813,27 @@ }]); | ||
function getLiteralValue(value) { | ||
switch (value.kind) { | ||
case 'IntValue': | ||
return parseInt(value.value, 10); | ||
case 'FloatValue': | ||
return parseFloat(value.value); | ||
case 'StringValue': | ||
case 'BooleanValue': | ||
case 'EnumValue': | ||
return value.value; | ||
case 'ListValue': | ||
return value.values.map(getLiteralValue); | ||
case 'ObjectValue': | ||
var object = {}; | ||
value.fields.forEach(function (field) { | ||
object[field.name.value] = getLiteralValue(field.value); | ||
}); | ||
return object; | ||
case 'Variable': | ||
invariant(false, 'Unexpected nested variable `%s`; variables are supported as top-' + 'level arguments - `node(id: $id)` - or directly within lists - ' + '`nodes(ids: [$id])`.', value.name.value); | ||
default: | ||
invariant(false, 'Unexpected value kind: %s', value.kind); | ||
} | ||
} | ||
module.exports = { | ||
@@ -825,0 +840,0 @@ RelayQLArgument: RelayQLArgument, |
@@ -459,3 +459,3 @@ // @generated | ||
kind: t.valueToNode('CallValue'), | ||
callValue: t.valueToNode(value) | ||
callValue: printLiteralValue(value) | ||
}); | ||
@@ -621,2 +621,23 @@ } | ||
function printLiteralValue(value) { | ||
if (value == null) { | ||
return NULL; | ||
} else if (Array.isArray(value)) { | ||
return t.arrayExpression(value.map(printLiteralValue)); | ||
} else if (typeof value === 'object' && value != null) { | ||
var _ret2 = (function () { | ||
var objectValue = value; | ||
return { | ||
v: t.objectExpression(Object.keys(objectValue).map(function (key) { | ||
return property(key, printLiteralValue(objectValue[key])); | ||
})) | ||
}; | ||
})(); | ||
if (typeof _ret2 === 'object') return _ret2.v; | ||
} else { | ||
return t.valueToNode(value); | ||
} | ||
} | ||
function shallowFlatten(arr) { | ||
@@ -623,0 +644,0 @@ return t.callExpression(t.memberExpression(t.memberExpression(EMPTY_ARRAY, t.identifier('concat')), t.identifier('apply')), [EMPTY_ARRAY, arr]); |
@@ -151,3 +151,3 @@ // @generated | ||
isPattern: false, | ||
nodeIndex: 0, | ||
generateID: createIDGenerator(), | ||
schema: this.schema, | ||
@@ -209,2 +209,12 @@ fragmentLocationID: fragmentLocationID | ||
/** | ||
* Utility to generate locally scoped auto-incrementing IDs. | ||
*/ | ||
function createIDGenerator() { | ||
var _id = 0; | ||
return function () { | ||
return (_id++).toString(32); | ||
}; | ||
} | ||
module.exports = RelayQLTransformer; |
@@ -37,3 +37,2 @@ // @generated | ||
var plugin = getBabelRelayPlugin(getSchema(schemaPath), { | ||
abortOnError: false, | ||
debug: true, | ||
@@ -40,0 +39,0 @@ substituteVariables: true, |
{ | ||
"name": "babel-relay-plugin", | ||
"version": "0.7.1", | ||
"version": "0.7.2", | ||
"description": "Babel Relay Plugin for transpiling GraphQL queries for use with Relay.", | ||
@@ -9,3 +9,3 @@ "license": "BSD-3-Clause", | ||
"scripts": { | ||
"build": "scripts/build-lib", | ||
"build": "node scripts/build-lib", | ||
"lint": "eslint .", | ||
@@ -31,3 +31,3 @@ "prepublish": "npm run build", | ||
"glob": "^5.0.15", | ||
"jest-cli": "0.9.0-fb1", | ||
"jest-cli": "0.9.0-fb3", | ||
"minimist": "^1.1.3", | ||
@@ -38,3 +38,3 @@ "mkdirp": "^0.5.1", | ||
"dependencies": { | ||
"graphql": "^0.4.17" | ||
"graphql": "^0.4.18" | ||
}, | ||
@@ -41,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
90564
2068
Updatedgraphql@^0.4.18