prisma-client-go
prisma-client-go copied to clipboard
Improve experience for function arguments
Since the go client doesn't use structs and a functional API instead, editor completions won't be available for some cases, such as:
users, err := client.User.FindOne(|)
When the cursor is in the FindOne method, it may not be clear what the user is supposed to type.
One way to improve the user experience would be to provide go doc comments with examples.
Would we be able to improve this experience through the VS Code plug-in? Cc @carmenberndt
Wouldn't it be the most natural thing to solve this via the programming language and e.g. use a builder?
users, err := client.User.FindOne(User.ByEmail("[email protected]"))
@mavilein This is how it works. However, it may not be clear what should go into FindOne, since the argument is an interface. For example, the argument in FindOne may take an interface:
type UserWhereUniqueParams interface {
userUniqueParams()
}
However, the IDE doesn't know in normal autocompletion what methods in different packages it can suggest to satisfy userUniqueParams. This is because we use an interface and a functions API and not a struct with specific values, so User.ByEmail
would return a struct that satisfies that interface.
To take your example, how should the IDE know that you can type User
in the FindOne (to complete User.ByEmail(...)
if the argument is an interface?
Ah i see. Yeah then documents and intuitive namespaces are the way to go i guess.