graphql-nexus / nexus

Code-First, Type-Safe, GraphQL Schema Construction
https://nexusjs.org
MIT License
3.4k stars 274 forks source link

Issue Deploying to Vercel: Type error: Property 'date' does not exist on type #1085

Open davevilela opened 2 years ago

davevilela commented 2 years ago

I'm trying to deploy my app to vercel, and i keep getting this error when building: Can someone help me?

Screen Shot 2022-05-03 at 14 43 22

my schema.ts

import { connectionPlugin, fieldAuthorizePlugin, makeSchema } from 'nexus';
import { join } from 'path';
import * as types from './types';
import * as mutations from './mutations';
import * as resolvers from './resolvers';

export const schema = makeSchema({
  types: { ...types, ...resolvers, ...mutations },
  sourceTypes: {
    modules: [
      {
        module: join(process.cwd(), 'src', 'lib', 'prisma.ts'),
        alias: 'PrismaClient',
      },
      {
        module: join(
          process.cwd(),
          'src',
          'graphql',
          'types',
          'CustomScalars.ts'
        ),
        alias: 'BackingScalars',
      },
    ],
  },
  outputs: {
    schema: join(
      process.cwd(),
      'src',
      'graphql',
      'generated',
      'schema.graphql'
    ),
    typegen: join(
      process.cwd(),
      'src',
      'graphql',
      'generated',
      'nexus-typegen.d.ts'
    ),
  },
  contextType: {
    export: 'Context',
    module: join(process.cwd(), 'src', 'graphql', 'context.ts'),
  },
  plugins: [fieldAuthorizePlugin(), connectionPlugin()],
  shouldExitAfterGenerateArtifacts: Boolean(
    process.env.NEXUS_SHOULD_EXIT_AFTER_REFLECTION
  ),
}) as unknown as GraphQLSchema;

build scripts on package.json:

    "dev": "next dev",
    "lint": "next lint",
    "start": "next start",
    "build": "yarn build:nexus-typegen && next build",
    "build:nexus-typegen": "ts-node -r tsconfig-paths/register --transpile-only -P nexus.tsconfig.json src/graphql/schema.ts",
    },
   ....
NathanLandsX commented 2 years ago

I have the same problem.

Bjoernstjerne commented 2 years ago

Have you tried adding your custom scalars to the types?

const TrueGraphQLScalar = new GraphQLScalarType({
    name: 'true',
    description: 'Represents true values',
    serialize: () => {
        return true;
    },
    parseValue: () => {
        return true;
    },
    parseLiteral: () => {
        return true;
    },
});

export const True = asNexusMethod(TrueGraphQLScalar, 'true', 'true');

I added this scalar to makeSchema({type: [..., Scalars], ...