Hey guys I'm trying to add a new scalar with `Grap...
# orm-help
g
Hey guys I'm trying to add a new scalar with
GraphQLScalarType
in schema.graphql
Copy code
scalar DateTime

type User {
  id: ID!
  registered: DateTime
}
types.ts
Copy code
type DateTime = string 

export interface User {
    id: string
    registered: DateTime
}
scalars/DateTime.ts
Copy code
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
Copy code
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
) ?
h
OMG, I was looking for a that, have you found a solution ?
h
Hey @guille Can you please tell me how you are generating that Resolver type? This looks like a typescript error to me. If you cast the resolver object to any it should work. But do let me know what you are using for type generation
g
@Harshit I'm using the
graphqlgen
command, my
graphqlgen.yml
looks exactly like this https://github.com/prisma/graphqlgen/blob/master/packages/graphqlgen-templates/typescript-yoga/graphqlgen.yml
h
This is a known issue in graphqlgen: https://github.com/prisma/graphqlgen/issues/165
g
Thanks, I shouldn't expect a solution any time soon, so I'll try with resolvers as any, thanks @Harshit!