simple-graphql
Advanced tools
Comparing version 1.0.10 to 1.0.11
{ | ||
"name": "simple-graphql", | ||
"version": "1.0.10", | ||
"version": "1.0.11", | ||
"description": "The simple way to generates GraphQL schemas and Sequelize models from your models definition.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -17,2 +17,6 @@ 'use strict'; | ||
var _graphqlRelay = require('graphql-relay'); | ||
var relay = _interopRequireWildcard(_graphqlRelay); | ||
var _type = require('../type'); | ||
@@ -106,4 +110,38 @@ | ||
if (typeof fieldType === 'string') { | ||
if (fieldType.endsWith('Edge')) { | ||
if (fieldType.endsWith('Id')) { | ||
return { | ||
type: graphql.GraphQLID, | ||
resolve: function () { | ||
var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(root) { | ||
return regeneratorRuntime.wrap(function _callee2$(_context2) { | ||
while (1) { | ||
switch (_context2.prev = _context2.next) { | ||
case 0: | ||
if (!root[name]) { | ||
_context2.next = 4; | ||
break; | ||
} | ||
return _context2.abrupt('return', !relay.toGlobalId(fieldType.substr(0, fieldType.length - 'Id'.length), root[name])); | ||
case 4: | ||
return _context2.abrupt('return', null); | ||
case 5: | ||
case 'end': | ||
return _context2.stop(); | ||
} | ||
} | ||
}, _callee2, this); | ||
})); | ||
function resolve(_x3) { | ||
return _ref2.apply(this, arguments); | ||
} | ||
return resolve; | ||
}() | ||
}; | ||
} else if (fieldType.endsWith('Edge')) { | ||
return { | ||
type: context.edgeType(fieldType.substr(0, fieldType.length - 'Edge'.length)) | ||
@@ -140,7 +178,7 @@ }; | ||
resolve: function () { | ||
var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(root, args, context, info, models) { | ||
var _ref3 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(root, args, context, info, models) { | ||
var fieldName; | ||
return regeneratorRuntime.wrap(function _callee2$(_context2) { | ||
return regeneratorRuntime.wrap(function _callee3$(_context3) { | ||
while (1) { | ||
switch (_context2.prev = _context2.next) { | ||
switch (_context3.prev = _context3.next) { | ||
case 0: | ||
@@ -150,3 +188,3 @@ fieldName = name.split('.').slice(-1)[0]; | ||
if (!_lodash2.default.isFunction(root['get' + _StringHelper2.default.toInitialUpperCase(fieldName)])) { | ||
_context2.next = 7; | ||
_context3.next = 7; | ||
break; | ||
@@ -156,32 +194,32 @@ } | ||
if (!(root[fieldName] != null && root[fieldName].id != null)) { | ||
_context2.next = 6; | ||
_context3.next = 6; | ||
break; | ||
} | ||
return _context2.abrupt('return', root[fieldName]); | ||
return _context3.abrupt('return', root[fieldName]); | ||
case 6: | ||
return _context2.abrupt('return', root['get' + _StringHelper2.default.toInitialUpperCase(fieldName)]()); | ||
return _context3.abrupt('return', root['get' + _StringHelper2.default.toInitialUpperCase(fieldName)]()); | ||
case 7: | ||
if (!(root && root[fieldName] && (typeof root[fieldName] === 'number' || typeof root[fieldName] === 'string'))) { | ||
_context2.next = 9; | ||
_context3.next = 9; | ||
break; | ||
} | ||
return _context2.abrupt('return', models[fieldType].findOne({ where: { id: root[fieldName] } })); | ||
return _context3.abrupt('return', models[fieldType].findOne({ where: { id: root[fieldName] } })); | ||
case 9: | ||
return _context2.abrupt('return', root[fieldName]); | ||
return _context3.abrupt('return', root[fieldName]); | ||
case 10: | ||
case 'end': | ||
return _context2.stop(); | ||
return _context3.stop(); | ||
} | ||
} | ||
}, _callee2, this); | ||
}, _callee3, this); | ||
})); | ||
function resolve(_x3, _x4, _x5, _x6, _x7) { | ||
return _ref2.apply(this, arguments); | ||
function resolve(_x4, _x5, _x6, _x7, _x8) { | ||
return _ref3.apply(this, arguments); | ||
} | ||
@@ -250,19 +288,19 @@ | ||
resolve: function () { | ||
var _ref3 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(root) { | ||
return regeneratorRuntime.wrap(function _callee3$(_context3) { | ||
var _ref4 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4(root) { | ||
return regeneratorRuntime.wrap(function _callee4$(_context4) { | ||
while (1) { | ||
switch (_context3.prev = _context3.next) { | ||
switch (_context4.prev = _context4.next) { | ||
case 0: | ||
return _context3.abrupt('return', root[name.split('.').slice(-1)[0]]); | ||
return _context4.abrupt('return', root[name.split('.').slice(-1)[0]]); | ||
case 1: | ||
case 'end': | ||
return _context3.stop(); | ||
return _context4.stop(); | ||
} | ||
} | ||
}, _callee3, this); | ||
}, _callee4, this); | ||
})); | ||
function resolve(_x8) { | ||
return _ref3.apply(this, arguments); | ||
function resolve(_x9) { | ||
return _ref4.apply(this, arguments); | ||
} | ||
@@ -269,0 +307,0 @@ |
{ | ||
"name": "simple-graphql", | ||
"version": "1.0.10", | ||
"version": "1.0.11", | ||
"description": "The simple way to generates GraphQL schemas and Sequelize models from your models definition.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
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
303353
5248