keystone
keystone copied to clipboard
`db.idField` settings are not reflected in generated types
To reproduce, create the following schema:
export const lists: Lists<Session> = {
testfield: list({
access: allowAll,
db: {
idField: {
kind: 'autoincrement',
type: 'Int',
},
},
fields: {},
}),
singleton: list({
access: allowAll,
isSingleton: true,
fields: {},
}),
}
This should result in the .keystone/types.ts file containing a type called testfieldWhereUniqueInput.
It does, but the type of the id field is incorrect:
export type testfieldWhereUniqueInput = {
readonly id?: Scalars['ID'] | null;
};
Scalars['ID'] is a string, but the id should be a number. I would expect it to be Scalars['Int'] instead.
This also happens for singletons, because isSingleton: true forces db.idField.type to be Int.
It's not super noticeable normally, but if you start using the generated types in your schema, you'll notice that there is a red squiggly on all your list definitions. The error you get will usually contain the string The types of 'context.db' are incompatible between these types..
Thanks for reporting this @pc-erin, I have seen this too