-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
'use strict'; | ||
|
||
var _Object$keys = require('babel-runtime/core-js/object/keys')['default']; | ||
|
||
var _interopRequireWildcard = require('babel-runtime/helpers/interop-require-wildcard')['default']; | ||
|
||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
}); | ||
|
||
var _typeMapper = require('./typeMapper'); | ||
|
||
var typeMapper = _interopRequireWildcard(_typeMapper); | ||
|
||
var _graphql = require('graphql'); | ||
|
||
exports['default'] = function (config, opts) { | ||
var options = opts || {}; | ||
|
||
return _Object$keys(config.schema).reduce(function (memo, key) { | ||
if (options.exclude && ~options.exclude.indexOf(key)) { | ||
return memo; | ||
} | ||
|
||
var attribute = key; | ||
var type = config.schema[key]; | ||
|
||
memo[key] = { | ||
type: typeMapper.toGraphQL(type) | ||
}; | ||
|
||
if (attribute === config.hashKey) { | ||
memo[key].type = new _graphql.GraphQLNonNull(memo[key].type); | ||
} | ||
|
||
return memo; | ||
}, {}); | ||
}; | ||
|
||
module.exports = exports['default']; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
'use strict'; | ||
|
||
var _interopRequireDefault = require('babel-runtime/helpers/interop-require-default')['default']; | ||
|
||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
}); | ||
|
||
var _attributeFieldsJs = require('./attributeFields.js'); | ||
|
||
var _attributeFieldsJs2 = _interopRequireDefault(_attributeFieldsJs); | ||
|
||
exports['default'] = { | ||
attributeFields: _attributeFieldsJs2['default'] | ||
}; | ||
module.exports = exports['default']; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
'use strict'; | ||
|
||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
}); | ||
exports.toGraphQL = toGraphQL; | ||
|
||
var _graphql = require('graphql'); | ||
|
||
function toGraphQL(vogelsType) { | ||
if (vogelsType._type === 'boolean') { | ||
return _graphql.GraphQLBoolean; | ||
} else if (vogelsType._type === 'number') { | ||
return _graphql.GraphQLInt; | ||
} else if (vogelsType._type === 'array') { | ||
return _graphql.GraphQLList; | ||
} else if (vogelsType._type === 'object') { | ||
return _graphql.GraphQLObjectType; | ||
} else if (vogelsType._type === 'string' || vogelsType._type === 'date' || vogelsType._type === 'uuid') { | ||
return _graphql.GraphQLString; | ||
} else { | ||
return new Error('Not handled vogelType ' + vogelsType._type); | ||
} | ||
} |