simple-graphql
Advanced tools
Comparing version 0.1.9 to 0.2.0
@@ -6,2 +6,3 @@ 'use strict'; | ||
}); | ||
exports.EdgeType = exports.ConnectionType = undefined; | ||
@@ -22,21 +23,36 @@ var _sequelize = require('sequelize'); | ||
var ConnectionType = exports.ConnectionType = function ConnectionType(nodeType) { | ||
_classCallCheck(this, ConnectionType); | ||
this.nodeType = nodeType; | ||
}; | ||
var EdgeType = exports.EdgeType = function EdgeType(nodeType) { | ||
_classCallCheck(this, EdgeType); | ||
this.nodeType = nodeType; | ||
}; | ||
/** | ||
*dd | ||
* Relay Connection Helper | ||
*/ | ||
exports.default = { | ||
ConnectionType: function ConnectionType(nodeType) { | ||
_classCallCheck(this, ConnectionType); | ||
this.nodeType = nodeType; | ||
}, | ||
ConnectionType: ConnectionType, | ||
EdgeType: function EdgeType(nodeType) { | ||
_classCallCheck(this, EdgeType); | ||
EdgeType: EdgeType, | ||
this.nodeType = nodeType; | ||
}, | ||
/** | ||
* Reference to relay ConnectionType with specify node | ||
*/ | ||
connectionType: function connectionType(nodeType) { | ||
return new this.ConnectionType(nodeType); | ||
}, | ||
/** | ||
* Reference to Relay EdgeType with specify node | ||
*/ | ||
edgeType: function edgeType(nodeType) { | ||
@@ -47,2 +63,5 @@ return new this.EdgeType(nodeType); | ||
/** | ||
* Return Relay Connection args definition. | ||
*/ | ||
args: { | ||
@@ -65,2 +84,5 @@ after: { | ||
/** | ||
* Query the model with specify args and return the connection data | ||
*/ | ||
resolve: function () { | ||
@@ -67,0 +89,0 @@ var _ref = _asyncToGenerator(regeneratorRuntime.mark(function _callee(model, args) { |
@@ -58,2 +58,3 @@ 'use strict'; | ||
/** | ||
* @public | ||
* 入口 | ||
@@ -72,3 +73,3 @@ * TODO | ||
* Define a Model | ||
* @access public | ||
* | ||
* @param name | ||
@@ -131,3 +132,3 @@ * @param options | ||
resolve: function () { | ||
var _ref = _asyncToGenerator(regeneratorRuntime.mark(function _callee(args, info, models, invoker) { | ||
var _ref = _asyncToGenerator(regeneratorRuntime.mark(function _callee(args, context, info, models, invoker) { | ||
var id, record; | ||
@@ -140,3 +141,3 @@ return regeneratorRuntime.wrap(function _callee$(_context) { | ||
if (context.models[id.type]) { | ||
if (models[id.type]) { | ||
_context.next = 3; | ||
@@ -168,3 +169,3 @@ break; | ||
function resolve(_x2, _x3, _x4, _x5) { | ||
function resolve(_x2, _x3, _x4, _x5, _x6) { | ||
return _ref.apply(this, arguments); | ||
@@ -171,0 +172,0 @@ } |
{ | ||
"name": "simple-graphql", | ||
"version": "0.1.9", | ||
"version": "0.2.0", | ||
"description": "The simple way to build GraphQL style API with MySQL/PostreSQL", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -23,2 +23,6 @@ 'use strict'; | ||
var _ModelRef = require('../../ModelRef'); | ||
var _ModelRef2 = _interopRequireDefault(_ModelRef); | ||
var _type = require('../../type'); | ||
@@ -163,2 +167,7 @@ | ||
_.forOwn(model.config.fields, function (value, key) { | ||
if (value instanceof _ModelRef2.default || value && value.$type instanceof _ModelRef2.default) { | ||
if (!key.endsWith('Id')) { | ||
key = key + 'Id'; | ||
} | ||
} | ||
if (!value['$type'] || value['searchable'] !== false && value['hidden'] !== true && !value['resolve']) { | ||
@@ -220,2 +229,3 @@ if (value['required']) { | ||
var _ref = _asyncToGenerator(regeneratorRuntime.mark(function _callee(args, context, info, models) { | ||
var dbModel, condition; | ||
return regeneratorRuntime.wrap(function _callee$(_context) { | ||
@@ -226,4 +236,4 @@ while (1) { | ||
conditionFieldKeys.forEach(function (fieldKey) { | ||
if (args['condition'] && args['condition'][fieldKey]) { | ||
args['condition'][fieldKey] = _.mapKeys(args['condition'][fieldKey], function (value, key) { | ||
if (args.condition && args.condition[fieldKey]) { | ||
args.condition[fieldKey] = _.mapKeys(args.condition[fieldKey], function (value, key) { | ||
return '$' + key; | ||
@@ -234,5 +244,26 @@ }); | ||
return _context.abrupt('return', _index2.default.Connection.resolve(models[model.name], args)); | ||
dbModel = models[model.name]; | ||
condition = {}; | ||
case 2: | ||
_.forOwn(model.config.fields, function (value, key) { | ||
if (value instanceof _ModelRef2.default || value && value.$type instanceof _ModelRef2.default) { | ||
if (!key.endsWith('Id')) { | ||
key = key + 'Id'; | ||
} | ||
if (typeof args.condition[key] !== 'undefined') { | ||
if (dbModel.options.underscored) { | ||
condition[key.replace(/([A-Z])/g, '_$1').replace(/^_/, '').toLocaleLowerCase()] = args.condition[key]; | ||
} else { | ||
condition[key] = args.condition[key]; | ||
} | ||
} | ||
} else if (typeof args.condition[key] !== 'undefined') { | ||
condition[key] = args.condition[key]; | ||
} | ||
}); | ||
args.condition = condition; | ||
return _context.abrupt('return', _index2.default.Connection.resolve(dbModel, args)); | ||
case 6: | ||
case 'end': | ||
@@ -239,0 +270,0 @@ return _context.stop(); |
@@ -14,3 +14,2 @@ 'use strict'; | ||
*/ | ||
function mutationWithClientMutationId(config) { | ||
@@ -17,0 +16,0 @@ var name = config.name, |
@@ -113,3 +113,3 @@ 'use strict'; | ||
resolve: function () { | ||
var _ref2 = _asyncToGenerator(regeneratorRuntime.mark(function _callee2(root, args, info, models) { | ||
var _ref2 = _asyncToGenerator(regeneratorRuntime.mark(function _callee2(root, args, context, info, models) { | ||
var fieldName; | ||
@@ -149,3 +149,3 @@ return regeneratorRuntime.wrap(function _callee2$(_context2) { | ||
function resolve(_x3, _x4, _x5, _x6) { | ||
function resolve(_x3, _x4, _x5, _x6, _x7) { | ||
return _ref2.apply(this, arguments); | ||
@@ -227,3 +227,3 @@ } | ||
function resolve(_x7) { | ||
function resolve(_x8) { | ||
return _ref3.apply(this, arguments); | ||
@@ -230,0 +230,0 @@ } |
{ | ||
"name": "simple-graphql", | ||
"version": "0.1.9", | ||
"version": "0.2.0", | ||
"description": "The simple way to build GraphQL style API with MySQL/PostreSQL", | ||
@@ -5,0 +5,0 @@ "main": "lib/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
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
1884497
5207