0

I adopted scalarType (datetime) following the code from this question GraphQL Nexus asNexusMethod showing type error

import { DateTimeResolver } from "graphql-scalars";
const DateTime = asNexusMethod(DateTimeResolver, "datetime");
const schema = makeSchema({
    types: [Query, DateTime]
});

It runs fine. The date is returned in ISO date formats successfully. But the TypeScript compiler still complains in code where the type is used.

export const CourseTemplateType = objectType({
   name: "CourseTemplate",
   definition(t) {
   t.id("id");
   t.string("courseNo");
   t.datetime("createdAt");  //Red line here
 },
});

Normally the nexus project should run with the command below which solve the type checking issue.

ts-node --transpile-only ./src/app.ts

But I don't know how to do that in Next.js. Because the project is already run with npm run dev. Is there any way to do it?

Chayanin
  • 281
  • 1
  • 5
  • 11

0 Answers0