-
-
Notifications
You must be signed in to change notification settings - Fork 31
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
New client APIs #447
Comments
Also, should we keep the old API? Or should we write a new generator to complete the new API. Actually, I don’t want to keep the old API because it will generate a lot of boilerplate code. |
I believe that developing a new API would be a significant step toward enhancing the user experience of the package. The current API code appears too cluttered compared to the rest of the codebase, and a new API would align the coding style more closely with that used in Dart. Eliminating the However, the transition from the old API poses a considerable challenge since developers have written a substantial amount of code that would need to be manually rewritten. To address this, we could develop a migration utility similar to the one that facilitated the transition to Dart's null safety. It would be beneficial to retain the old API for a transitional period by allowing its usage through a generator argument and marking it as deprecated, while making the new API the default. This approach would provide developers with ample time to migrate. |
@mocki-toki My idea is to keep the original typed inputs and then make a new generator to enable the new API. That is to say, the new API and typed inputs are retained at the same time, and all typed inputs are marked as deprecated, allowing existing programs to be migrated gradually. |
TL;DR:
In previous versions, in order to avoid the learning cost of Prisma, we always used the API of Prisma TS client as the reference implementation.
Obviously, this is not applicable in Dart. For Type-safety, we have to write a lot of boilerplate code:
to new fluent API:
In the new API design, we keep Type-safe inputs and add several new requirements:
fromJson()
: You can pass in a JSON as a parameter like the Prisma TS client, which is completely consistent with the TS client. But using Map in Dart will completely lose safety.serialize()
: This is an interface that allows you to customize the serialization return data. In the v5 version, nullable Model entities are always returned, which is inconvenient for users to always check whether it is a null value. The newserialize
allows you to fully control the serialization. You can simplyextension type xxx impl Map
to implement the type packaging of data.PrismaUnion
and promote the parameters to the outside. We also need to be extra careful to avoid type errors. Fluent API splits it up. You can gradually pass in parameters according to the type builder to prevent external promotion from causing incorrect type signatures. In addition, it may also provide some auxiliary functions to help you more easily promote external conditional logic.This is a discussion. Do we really need to add these new APIs?
The text was updated successfully, but these errors were encountered: