Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

db.idField settings are not reflected in generated types #8846

Open
pc-erin opened this issue Oct 4, 2023 · 1 comment
Open

db.idField settings are not reflected in generated types #8846

pc-erin opened this issue Oct 4, 2023 · 1 comment
Assignees
Labels
🐛 bug Unresolved bug

Comments

@pc-erin
Copy link

pc-erin commented Oct 4, 2023

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..

@dcousens dcousens added the 🐛 bug Unresolved bug label Oct 4, 2023
@dcousens dcousens self-assigned this Oct 4, 2023
@dcousens
Copy link
Member

dcousens commented Oct 4, 2023

Thanks for reporting this @pc-erin, I have seen this too

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Unresolved bug
Projects
None yet
Development

No branches or pull requests

2 participants