docs icon indicating copy to clipboard operation
docs copied to clipboard

Improve documentation of default attribute arguments

Open keerlu opened this issue 2 years ago • 1 comments

From @janpio:

We are currently using an _ to document the "default" argument of our attributes in PSL which can be used with and without its "name": @@index(_ fields: FieldReference[], map: String?) (via https://www.prisma.io/docs/reference/api-reference/prisma-schema-reference#signature-5) Here this means that if you can either do @@index([foo, bar]) or @@index(fields: [foo, bar]) interchangeably to achieve the same thing. Is this a common notation? I noticed we are not consistently using it any more, probably accidentally when changing things or when editing. We should probably define if we want to keep using it, or not. If not, we need another way to document which argument is the default and can be used without the name.

Slack thread with lots more discussion and context here: https://prisma-company.slack.com/archives/C01TM7UM83Y/p1658848253368889

keerlu avatar Aug 11 '22 10:08 keerlu

My current understanding based on the thread:

  • We can stop using the _ syntax in docs, as this was borrowed from Swift but doesn't correspond to any actual Prisma language feature.
  • These 'default' attribute arguments with the _ can be referred to without using the argument key name, but they're not positional, you can list the key-value pairs in any order
  • We need a way to explain this in docs

keerlu avatar Aug 11 '22 10:08 keerlu