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

Improve support for entities with id: number #944

Open
queicherius opened this issue Sep 5, 2024 · 1 comment
Open

Improve support for entities with id: number #944

queicherius opened this issue Sep 5, 2024 · 1 comment
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@queicherius
Copy link
Member

queicherius commented Sep 5, 2024

You can currently use numeric IDs / cursors, but you have to manually pass the generic: https://github.com/devoxa/prisma-relay-cursor-connection/blob/master/tests/index.spec.ts#L194

//                                            v Model type
const result = await findManyCursorConnection<User, { id: number }>(
//                                                    ^ Cursor generic

You can also not use select or include, because of the manually provided generics.

With some TS magic (that I could not figure out so far) it might be possible to make this automatically infer the correct types.

If someone want to take a stab at it, I provided some additional tests & type checks on the https://github.com/devoxa/prisma-relay-cursor-connection/tree/fix-generics-with-number-id-2 branch. The tests already pass (as expected) but the type checks in the test file do not.

@queicherius queicherius added enhancement New feature or request help wanted Extra attention is needed labels Sep 5, 2024
@queicherius queicherius changed the title Improve generics for numeric cursors Improve support for entities with id: number Sep 7, 2024
@rjhilgefort
Copy link

I know GitHub links it in the issue references / activity, but I wanted to explicitly call out the original issue I raised for this effort. It has some context that might be helpful for others arriving at this issue down the road.

#938

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants