feat(graphql): add DateTime support instead of String

This commit is contained in:
Johann Pinson 2018-06-19 11:13:32 +02:00
parent dfca7d9580
commit 1d4a193f7e
2 changed files with 11 additions and 5 deletions

View File

@ -27,7 +27,8 @@
"graphql-depth-limit": "^1.1.0",
"graphql-playground-middleware-koa": "^1.6.1",
"graphql-tools": "^2.23.1",
"graphql-type-json": "^0.2.0",
"graphql-type-json": "^0.2.1",
"graphql-type-datetime": "^0.2.1",
"pluralize": "^7.0.0",
"strapi-utils": "3.0.0-alpha.12.4"
},

View File

@ -14,6 +14,7 @@ const pluralize = require('pluralize');
const graphql = require('graphql');
const { makeExecutableSchema } = require('graphql-tools');
const GraphQLJSON = require('graphql-type-json');
const GraphQLDateTime = require('graphql-type-datetime');
const policyUtils = require('strapi-utils').policy;
module.exports = {
@ -170,6 +171,9 @@ module.exports = {
case 'float':
type = 'Float';
break;
case 'date':
type = 'DateTime';
break;
case 'enumeration':
type = this.convertEnumType(definition, modelName, attributeName);
break;
@ -453,8 +457,8 @@ module.exports = {
// Add timestamps attributes.
if (_.get(model, 'options.timestamps') === true) {
Object.assign(initialState, {
createdAt: 'String!',
updatedAt: 'String!'
createdAt: 'DateTime!',
updatedAt: 'DateTime!'
});
Object.assign(acc.resolver[globalId], {
@ -777,10 +781,11 @@ module.exports = {
addCustomScalar: (resolvers) => {
Object.assign(resolvers, {
JSON: GraphQLJSON
JSON: GraphQLJSON,
DateTime: GraphQLDateTime,
});
return 'scalar JSON';
return 'scalar JSON \n scalar DateTime';
},
/**