graphile-build
Advanced tools
Comparing version 0.1.0-alpha.32 to 0.1.0-alpha.36
@@ -7,2 +7,6 @@ "use strict"; | ||
var _assign = require("babel-runtime/core-js/object/assign"); | ||
var _assign2 = _interopRequireDefault(_assign); | ||
var _isFrozen = require("babel-runtime/core-js/object/is-frozen"); | ||
@@ -12,6 +16,2 @@ | ||
var _assign = require("babel-runtime/core-js/object/assign"); | ||
var _assign2 = _interopRequireDefault(_assign); | ||
var _map = require("babel-runtime/core-js/map"); | ||
@@ -45,2 +45,6 @@ | ||
var _extend = require("./extend"); | ||
var _extend2 = _interopRequireDefault(_extend); | ||
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; } } | ||
@@ -53,3 +57,2 @@ | ||
}; | ||
var isDev = ["test", "development"].indexOf(process.env.NODE_ENV) >= 0; | ||
@@ -200,34 +203,3 @@ var debug = (0, _debug2.default)("graphile-build"); | ||
}, | ||
extend(base, extra) { | ||
var keysA = (0, _keys2.default)(base); | ||
var keysB = (0, _keys2.default)(extra); | ||
var _iteratorNormalCompletion3 = true; | ||
var _didIteratorError3 = false; | ||
var _iteratorError3 = undefined; | ||
try { | ||
for (var _iterator3 = (0, _getIterator3.default)(keysB), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) { | ||
var key = _step3.value; | ||
if (keysA.indexOf(key) >= 0) { | ||
throw new Error(`Overwriting key '${key}' is not allowed!`); | ||
} | ||
} | ||
} catch (err) { | ||
_didIteratorError3 = true; | ||
_iteratorError3 = err; | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion3 && _iterator3.return) { | ||
_iterator3.return(); | ||
} | ||
} finally { | ||
if (_didIteratorError3) { | ||
throw _iteratorError3; | ||
} | ||
} | ||
} | ||
return (0, _assign2.default)({}, base, extra); | ||
}, | ||
extend: _extend2.default, | ||
newWithHooks(Type, spec, inScope) { | ||
@@ -279,9 +251,9 @@ var _this = this; | ||
var typeFields = StrippedType.getFields(); | ||
var _iteratorNormalCompletion4 = true; | ||
var _didIteratorError4 = false; | ||
var _iteratorError4 = undefined; | ||
var _iteratorNormalCompletion3 = true; | ||
var _didIteratorError3 = false; | ||
var _iteratorError3 = undefined; | ||
try { | ||
for (var _iterator4 = (0, _getIterator3.default)((0, _keys2.default)(fields)), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) { | ||
var alias = _step4.value; | ||
for (var _iterator3 = (0, _getIterator3.default)((0, _keys2.default)(fields)), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) { | ||
var alias = _step3.value; | ||
@@ -292,9 +264,9 @@ var field = fields[alias]; | ||
if (gens) { | ||
var _iteratorNormalCompletion5 = true; | ||
var _didIteratorError5 = false; | ||
var _iteratorError5 = undefined; | ||
var _iteratorNormalCompletion4 = true; | ||
var _didIteratorError4 = false; | ||
var _iteratorError4 = undefined; | ||
try { | ||
for (var _iterator5 = (0, _getIterator3.default)(gens), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) { | ||
var gen = _step5.value; | ||
for (var _iterator4 = (0, _getIterator3.default)(gens), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) { | ||
var gen = _step4.value; | ||
@@ -307,12 +279,12 @@ var local = ensureArray(gen.apply(undefined, [field, typeFields[field.name].type].concat(rest))); | ||
} catch (err) { | ||
_didIteratorError5 = true; | ||
_iteratorError5 = err; | ||
_didIteratorError4 = true; | ||
_iteratorError4 = err; | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion5 && _iterator5.return) { | ||
_iterator5.return(); | ||
if (!_iteratorNormalCompletion4 && _iterator4.return) { | ||
_iterator4.return(); | ||
} | ||
} finally { | ||
if (_didIteratorError5) { | ||
throw _iteratorError5; | ||
if (_didIteratorError4) { | ||
throw _iteratorError4; | ||
} | ||
@@ -324,12 +296,12 @@ } | ||
} catch (err) { | ||
_didIteratorError4 = true; | ||
_iteratorError4 = err; | ||
_didIteratorError3 = true; | ||
_iteratorError3 = err; | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion4 && _iterator4.return) { | ||
_iterator4.return(); | ||
if (!_iteratorNormalCompletion3 && _iterator3.return) { | ||
_iterator3.return(); | ||
} | ||
} finally { | ||
if (_didIteratorError4) { | ||
throw _iteratorError4; | ||
if (_didIteratorError3) { | ||
throw _iteratorError3; | ||
} | ||
@@ -375,8 +347,9 @@ } | ||
GraphQLObjectType: rawSpec, | ||
fieldWithHooks: function (fieldName, spec) { | ||
var fieldScope = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
fieldWithHooks: function (fieldName, spec, fieldScope) { | ||
if (!isString(fieldName)) { | ||
throw new Error("It looks like you forgot to pass the fieldName to `fieldWithHooks`, we're sorry this is current necessary."); | ||
} | ||
if (!fieldScope) { | ||
throw new Error("All calls to `fieldWithHooks` must specify a `fieldScope` " + "argument that gives additional context about the field so " + "that further plugins may more easily understand the field. " + "Keys within this object should contain the phrase 'field' " + "since they will be merged into the parent objects scope and " + "are not allowed to clash. If you really have no additional " + "information to give, please just pass `{}`."); | ||
} | ||
var argDataGenerators = []; | ||
@@ -404,9 +377,9 @@ | ||
var _iteratorNormalCompletion6 = true; | ||
var _didIteratorError6 = false; | ||
var _iteratorError6 = undefined; | ||
var _iteratorNormalCompletion5 = true; | ||
var _didIteratorError5 = false; | ||
var _iteratorError5 = undefined; | ||
try { | ||
for (var _iterator6 = (0, _getIterator3.default)(argDataGenerators), _step6; !(_iteratorNormalCompletion6 = (_step6 = _iterator6.next()).done); _iteratorNormalCompletion6 = true) { | ||
var gen = _step6.value; | ||
for (var _iterator5 = (0, _getIterator3.default)(argDataGenerators), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) { | ||
var gen = _step5.value; | ||
@@ -423,12 +396,12 @@ try { | ||
} catch (err) { | ||
_didIteratorError6 = true; | ||
_iteratorError6 = err; | ||
_didIteratorError5 = true; | ||
_iteratorError5 = err; | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion6 && _iterator6.return) { | ||
_iterator6.return(); | ||
if (!_iteratorNormalCompletion5 && _iterator5.return) { | ||
_iterator5.return(); | ||
} | ||
} finally { | ||
if (_didIteratorError6) { | ||
throw _iteratorError6; | ||
if (_didIteratorError5) { | ||
throw _iteratorError5; | ||
} | ||
@@ -444,9 +417,9 @@ } | ||
var typeFields = Type.getFields(); | ||
var _iteratorNormalCompletion7 = true; | ||
var _didIteratorError7 = false; | ||
var _iteratorError7 = undefined; | ||
var _iteratorNormalCompletion6 = true; | ||
var _didIteratorError6 = false; | ||
var _iteratorError6 = undefined; | ||
try { | ||
for (var _iterator7 = (0, _getIterator3.default)((0, _keys2.default)(fields)), _step7; !(_iteratorNormalCompletion7 = (_step7 = _iterator7.next()).done); _iteratorNormalCompletion7 = true) { | ||
var alias = _step7.value; | ||
for (var _iterator6 = (0, _getIterator3.default)((0, _keys2.default)(fields)), _step6; !(_iteratorNormalCompletion6 = (_step6 = _iterator6.next()).done); _iteratorNormalCompletion6 = true) { | ||
var alias = _step6.value; | ||
@@ -457,9 +430,9 @@ var field = fields[alias]; | ||
var FieldReturnType = typeFields[field.name].type; | ||
var _iteratorNormalCompletion8 = true; | ||
var _didIteratorError8 = false; | ||
var _iteratorError8 = undefined; | ||
var _iteratorNormalCompletion7 = true; | ||
var _didIteratorError7 = false; | ||
var _iteratorError7 = undefined; | ||
try { | ||
for (var _iterator8 = (0, _getIterator3.default)(gens), _step8; !(_iteratorNormalCompletion8 = (_step8 = _iterator8.next()).done); _iteratorNormalCompletion8 = true) { | ||
var _gen = _step8.value; | ||
for (var _iterator7 = (0, _getIterator3.default)(gens), _step7; !(_iteratorNormalCompletion7 = (_step7 = _iterator7.next()).done); _iteratorNormalCompletion7 = true) { | ||
var _gen = _step7.value; | ||
@@ -469,12 +442,12 @@ mergeData(data, _gen, FieldReturnType, field); | ||
} catch (err) { | ||
_didIteratorError8 = true; | ||
_iteratorError8 = err; | ||
_didIteratorError7 = true; | ||
_iteratorError7 = err; | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion8 && _iterator8.return) { | ||
_iterator8.return(); | ||
if (!_iteratorNormalCompletion7 && _iterator7.return) { | ||
_iterator7.return(); | ||
} | ||
} finally { | ||
if (_didIteratorError8) { | ||
throw _iteratorError8; | ||
if (_didIteratorError7) { | ||
throw _iteratorError7; | ||
} | ||
@@ -486,12 +459,12 @@ } | ||
} catch (err) { | ||
_didIteratorError7 = true; | ||
_iteratorError7 = err; | ||
_didIteratorError6 = true; | ||
_iteratorError6 = err; | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion7 && _iterator7.return) { | ||
_iterator7.return(); | ||
if (!_iteratorNormalCompletion6 && _iterator6.return) { | ||
_iterator6.return(); | ||
} | ||
} finally { | ||
if (_didIteratorError7) { | ||
throw _iteratorError7; | ||
if (_didIteratorError6) { | ||
throw _iteratorError6; | ||
} | ||
@@ -503,5 +476,5 @@ } | ||
}, | ||
scope: (0, _assign2.default)({}, scope, { | ||
scope: (0, _extend2.default)((0, _extend2.default)(scope, { | ||
fieldName | ||
}, fieldScope) | ||
}), fieldScope) | ||
}); | ||
@@ -534,3 +507,5 @@ if (typeof newSpec === "function") { | ||
// We've not processed this yet; process it now! | ||
fieldsSpec[_fieldName] = fieldsContext.fieldWithHooks(_fieldName, fieldSpec); | ||
fieldsSpec[_fieldName] = fieldsContext.fieldWithHooks(_fieldName, fieldSpec, { | ||
autoField: true // We don't have any additional information | ||
}); | ||
} | ||
@@ -563,5 +538,5 @@ } | ||
var context = (0, _assign2.default)({}, _commonContext, { | ||
scope: (0, _assign2.default)({}, scope, { | ||
scope: (0, _extend2.default)((0, _extend2.default)(scope, { | ||
fieldName | ||
}, fieldScope) | ||
}), fieldScope) | ||
}); | ||
@@ -588,3 +563,5 @@ var newSpec = spec; | ||
// We've not processed this yet; process it now! | ||
fieldsSpec[_fieldName2] = fieldsContext.fieldWithHooks(_fieldName2, fieldSpec); | ||
fieldsSpec[_fieldName2] = fieldsContext.fieldWithHooks(_fieldName2, fieldSpec, { | ||
autoField: true // We don't have any additional information | ||
}); | ||
} | ||
@@ -591,0 +568,0 @@ } |
@@ -230,2 +230,4 @@ "use strict"; | ||
}; | ||
}, { | ||
isRootNodeField: true | ||
}) | ||
@@ -232,0 +234,0 @@ }); |
@@ -62,3 +62,3 @@ "use strict"; | ||
}; | ||
}), | ||
}, { isPageInfoHasNextPageField: true }), | ||
hasPreviousPage: fieldWithHooks("hasPreviousPage", function (_ref4) { | ||
@@ -76,3 +76,3 @@ var addDataGenerator = _ref4.addDataGenerator; | ||
}; | ||
}) | ||
}, { isPageInfoHasPreviousPageField: true }) | ||
}; | ||
@@ -79,0 +79,0 @@ } |
@@ -7,2 +7,6 @@ "use strict"; | ||
var _assign = require("babel-runtime/core-js/object/assign"); | ||
var _assign2 = _interopRequireDefault(_assign); | ||
var _isFrozen = require("babel-runtime/core-js/object/is-frozen"); | ||
@@ -12,6 +16,2 @@ | ||
var _assign = require("babel-runtime/core-js/object/assign"); | ||
var _assign2 = _interopRequireDefault(_assign); | ||
var _map = require("babel-runtime/core-js/map"); | ||
@@ -37,2 +37,6 @@ | ||
var _extend = require("./extend"); | ||
var _extend2 = _interopRequireDefault(_extend); | ||
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; } } | ||
@@ -43,3 +47,2 @@ | ||
const isString = str => typeof str === "string"; | ||
const isDev = ["test", "development"].indexOf(process.env.NODE_ENV) >= 0; | ||
@@ -146,12 +149,3 @@ const debug = (0, _debug2.default)("graphile-build"); | ||
}, | ||
extend(base, extra) { | ||
const keysA = (0, _keys2.default)(base); | ||
const keysB = (0, _keys2.default)(extra); | ||
for (const key of keysB) { | ||
if (keysA.indexOf(key) >= 0) { | ||
throw new Error(`Overwriting key '${key}' is not allowed!`); | ||
} | ||
} | ||
return (0, _assign2.default)({}, base, extra); | ||
}, | ||
extend: _extend2.default, | ||
newWithHooks(Type, spec, inScope, returnNullOnInvalid = false) { | ||
@@ -243,6 +237,9 @@ const scope = inScope || {}; | ||
GraphQLObjectType: rawSpec, | ||
fieldWithHooks: (fieldName, spec, fieldScope = {}) => { | ||
fieldWithHooks: (fieldName, spec, fieldScope) => { | ||
if (!isString(fieldName)) { | ||
throw new Error("It looks like you forgot to pass the fieldName to `fieldWithHooks`, we're sorry this is current necessary."); | ||
} | ||
if (!fieldScope) { | ||
throw new Error("All calls to `fieldWithHooks` must specify a `fieldScope` " + "argument that gives additional context about the field so " + "that further plugins may more easily understand the field. " + "Keys within this object should contain the phrase 'field' " + "since they will be merged into the parent objects scope and " + "are not allowed to clash. If you really have no additional " + "information to give, please just pass `{}`."); | ||
} | ||
let argDataGenerators = []; | ||
@@ -298,5 +295,5 @@ | ||
}, | ||
scope: (0, _assign2.default)({}, scope, { | ||
scope: (0, _extend2.default)((0, _extend2.default)(scope, { | ||
fieldName | ||
}, fieldScope) | ||
}), fieldScope) | ||
}); | ||
@@ -329,3 +326,5 @@ if (typeof newSpec === "function") { | ||
// We've not processed this yet; process it now! | ||
fieldsSpec[fieldName] = fieldsContext.fieldWithHooks(fieldName, fieldSpec); | ||
fieldsSpec[fieldName] = fieldsContext.fieldWithHooks(fieldName, fieldSpec, { | ||
autoField: true // We don't have any additional information | ||
}); | ||
} | ||
@@ -356,5 +355,5 @@ } | ||
let context = (0, _assign2.default)({}, commonContext, { | ||
scope: (0, _assign2.default)({}, scope, { | ||
scope: (0, _extend2.default)((0, _extend2.default)(scope, { | ||
fieldName | ||
}, fieldScope) | ||
}), fieldScope) | ||
}); | ||
@@ -381,3 +380,5 @@ let newSpec = spec; | ||
// We've not processed this yet; process it now! | ||
fieldsSpec[fieldName] = fieldsContext.fieldWithHooks(fieldName, fieldSpec); | ||
fieldsSpec[fieldName] = fieldsContext.fieldWithHooks(fieldName, fieldSpec, { | ||
autoField: true // We don't have any additional information | ||
}); | ||
} | ||
@@ -384,0 +385,0 @@ } |
@@ -161,3 +161,5 @@ "use strict"; | ||
} | ||
})) | ||
}), { | ||
isRootNodeField: true | ||
}) | ||
}); | ||
@@ -164,0 +166,0 @@ }); |
@@ -49,3 +49,3 @@ "use strict"; | ||
}; | ||
}), | ||
}, { isPageInfoHasNextPageField: true }), | ||
hasPreviousPage: fieldWithHooks("hasPreviousPage", ({ addDataGenerator }) => { | ||
@@ -61,3 +61,3 @@ addDataGenerator(() => { | ||
}; | ||
}) | ||
}, { isPageInfoHasPreviousPageField: true }) | ||
}) | ||
@@ -64,0 +64,0 @@ }, { |
{ | ||
"name": "graphile-build", | ||
"version": "0.1.0-alpha.32", | ||
"version": "0.1.0-alpha.36", | ||
"description": "Build a GraphQL schema from plugins", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
338196
65
2583