Open emroot opened 2 months ago
That doesn't seem expected, can you share more about your setup (eg what options/types are passed to your builder) or a reproduction? I don't see anything wrong with your setup, but I also haven't seen this in any of the other APIs I've worked on, so there is probably some combination of settings or something that is off
yeah for sure.
it only happens in VS code, when I run my pnpm type-check
no ts errors there.
// builder.ts
import SchemaBuilder from '@pothos/core';
import WithInputPlugin from '@pothos/plugin-with-input';
import { DateTimeResolver, JSONResolver } from 'graphql-scalars';
import PrismaPlugin from '@pothos/plugin-prisma';
import PrismaUtilsPlugin from '@pothos/plugin-prisma-utils';
import RelayPlugin from '@pothos/plugin-relay';
import ScopeAuthPlugin from '@pothos/plugin-scope-auth';
import TracingPlugin, { isRootField } from '@pothos/plugin-tracing';
import ValidationPlugin from '@pothos/plugin-validation';
import { createSentryWrapper } from '@pothos/tracing-sentry';
import { Prisma } from '@prisma/client';
import { GraphqlContext } from '../pothos/context';
import type PrismaTypes from '../prisma/pothos-types';
import db from '../services/prisma';
const traceResolver = createSentryWrapper({
includeArgs: true,
includeSource: true,
});
const builder = new SchemaBuilder<{
AuthScopes: {
...
};
Context: GraphqlContext;
Objects: {
...
};
PrismaTypes: PrismaTypes;
Scalars: {
ID: {
Output: number | string;
Input: string;
};
DateTime: {
Output: Date;
Input: Date;
};
JSONObject: {
Input: any;
Output: any;
};
};
Tracing: boolean | { formatMessage: (duration: number) => string };
}>({
plugins: [
TracingPlugin,
WithInputPlugin,
RelayPlugin,
ScopeAuthPlugin,
PrismaPlugin,
PrismaUtilsPlugin,
ValidationPlugin,
],
relay: {
cursorType: 'ID',
},
scopeAuth: {
cacheKey: (value) => JSON.stringify(value),
authScopes: async (context) => ({
...
}),
},
prisma: {
client: db,
dmmf: Prisma.dmmf,
},
tracing: {
default: (config) => isRootField?.(config),
wrap: (resolver, options) => traceResolver(resolver, options),
},
});
builder.queryType();
builder.mutationType();
builder.addScalarType('DateTime', DateTimeResolver, {});
builder.addScalarType('JSONObject', JSONResolver, {});
export { builder };
// schema.prisma
generator pothos {
clientOutput = "@prisma/client"
provider = "prisma-pothos-types"
output = "./pothos-types.ts"
prismaUtils = true
}
Just tried upgrading my typescript from "typescript": "5.4.5" to "typescript": "5.5.4" and not I'm seeing this error when running pnpm type-check
Id recommend clearing out any tsbuildinfo files, and remove and reinstall node modules, and then restart vs code. If it's not showing up when you rub type checking via the cli, it might be a caching issue
Updated vs code to use my workspace version of typescript, instead of the default vs code (latest typescript) and it worked.
But looks like the issue is definitely with typescript 5.5.x
What version of ts are you using? Curious if this is just me or if other are having the same problem with ts 5.5.x
I've been using 5.5.4 without issues
ok thanks. I'll dig a little more on my end and see if I find anything.
We can leave this open for until we figure out whats going on. I just noticed you are using the validation plugin, which doesn't have a 4.0 version (its been renamed to plugin-zod)
Pushed up a repo with most of the code you provided on a branch of an old bug reproduction repo I had: https://github.com/hayes/pothos-prisma-alias-bug/tree/mh--expose-nullable-bug.
I wasn't able to reproduce the issue, but I am curious if this presents the same issue, or if you can expand it with whatever is missing that causes the issue
Hey,
I just upgraded to 4.x and I'm getting a bunch of ts errors on my prisma fields that are not null in my DB schema.
am I missing something?
I thought it was related to this (https://pothos-graphql.dev/docs/guide/changing-default-nullability), but changing to false didn't do much.
Thanks