Fixed small bugs
This commit is contained in:
@@ -1,43 +0,0 @@
|
||||
import { GraphQLScalarType } from 'graphql';
|
||||
import { Kind } from 'graphql/language';
|
||||
|
||||
// possible switch to https://github.com/Urigo/graphql-scalars
|
||||
const DateTimeScalar = new GraphQLScalarType({
|
||||
name: 'DateTime',
|
||||
description: 'Date time custom scalar type',
|
||||
parseValue(value) {
|
||||
return new Date(value); // value from the client
|
||||
},
|
||||
serialize(value) {
|
||||
return new Date(value).toISOString(); // value sent to the client
|
||||
},
|
||||
parseLiteral(ast) {
|
||||
if (ast.kind === Kind.INT) {
|
||||
return parseInt(ast.value, 10); // ast value is always in string format
|
||||
}
|
||||
return null;
|
||||
},
|
||||
});
|
||||
|
||||
const DateScalar = new GraphQLScalarType({
|
||||
name: 'DateTime',
|
||||
description: 'Date custom scalar type',
|
||||
parseValue(value) {
|
||||
console.log('FROM CLIENT:', value);
|
||||
return new Date(value); // value from the client
|
||||
},
|
||||
serialize(value) {
|
||||
return new Date(value).toISOString().split('T')[0]; // value sent to the client
|
||||
},
|
||||
parseLiteral(ast) {
|
||||
if (ast.kind === Kind.INT) {
|
||||
return parseInt(ast.value, 10); // ast value is always in string format
|
||||
}
|
||||
return null;
|
||||
},
|
||||
});
|
||||
|
||||
export const CustomTypes = {
|
||||
DateTime: DateTimeScalar,
|
||||
Date: DateScalar,
|
||||
};
|
||||
@@ -13,7 +13,8 @@ const Order: IResolverObject = {
|
||||
async rows({ id }, args, { dataSources }) {
|
||||
return (<OrderAPI>dataSources.orderApi).getOrderRowsByOrderId(id);
|
||||
},
|
||||
async marketObject({ market }, args, { dataSources }) {
|
||||
// TODO change to market
|
||||
async market({ market }, args, { dataSources }) {
|
||||
return (<OrderAPI>dataSources.orderApi).getMarketByName(market);
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user