prisma-client-go icon indicating copy to clipboard operation
prisma-client-go copied to clipboard

Improve experience for function arguments

Open steebchen opened this issue 3 years ago • 4 comments

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.

steebchen avatar Aug 18 '20 14:08 steebchen

Would we be able to improve this experience through the VS Code plug-in? Cc @carmenberndt

sorenbs avatar Sep 20 '20 08:09 sorenbs

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 avatar Sep 21 '20 07:09 mavilein

@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?

steebchen avatar Sep 21 '20 09:09 steebchen

Ah i see. Yeah then documents and intuitive namespaces are the way to go i guess.

mavilein avatar Sep 23 '20 08:09 mavilein