guille
07/27/2019, 5:21 PMGraphQLScalarType
in schema.graphql
scalar DateTime
type User {
id: ID!
registered: DateTime
}
types.ts
type DateTime = string
export interface User {
id: string
registered: DateTime
}
scalars/DateTime.ts
export const DateTime = new GraphQLScalarType({
name: 'DateTime',
description: 'testing DateTime' ,
serialize: (value) => {
let result;
console.log(value);
return result;
},
parseValue: (value) => {
let result;
console.log(value);
return result;
},
parseLiteral: (ast) => {
console.log(ast);
},
});
In the resolvers.ts I've tried to import the DateTime
and added to
export const resolvers: Resolvers = {
DateTime,
User,
}
But I get the error Type '{ DateTime: GraphQLScalarType; User: Type; }' is not assignable to type 'Resolvers'.
How should I add the scalar to the server (graphql-yoga
) ?Herbert Pimentel
07/28/2019, 1:27 PMHarshit
07/29/2019, 12:06 PMguille
07/29/2019, 3:57 PMgraphqlgen
command, my graphqlgen.yml
looks exactly like this https://github.com/prisma/graphqlgen/blob/master/packages/graphqlgen-templates/typescript-yoga/graphqlgen.ymlHarshit
07/29/2019, 3:58 PMguille
07/29/2019, 4:05 PM