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

fix(completion): suggest @id for enum and ignore comments #1192

Merged
merged 3 commits into from
Jul 18, 2022

Conversation

Jolg42
Copy link
Member

@Jolg42 Jolg42 commented Jun 30, 2022

closes #1084

Added @id suggestion after an enum

@Jolg42 Jolg42 added this to the 4.1.0 milestone Jun 30, 2022
@Jolg42 Jolg42 requested a review from tomhoule June 30, 2022 12:53
@github-actions
Copy link

github-actions bot commented Jun 30, 2022

🤖 Pull request artifacts

file commit
pr1192-prisma.vsix 7dc1e9d

github-actions bot added a commit that referenced this pull request Jun 30, 2022
@github-actions
Copy link

@Jolg42 Jolg42 marked this pull request as ready for review June 30, 2022 12:56
Copy link
Contributor

@tomhoule tomhoule left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just adding to Jan's comments, lgtm

packages/language-server/src/completion/completionUtils.ts Outdated Show resolved Hide resolved
}

const modelOrEnum = getModelOrTypeOrEnumBlock(fieldType, lines)
const isAtIdAllowed = fieldType === 'Int' || fieldType === 'String' || modelOrEnum?.type === 'enum'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we allow ids on basically everything except relation fields, so it doesn't need to be restricted to Int and String. These are terrible, terrible ideas of course, but you can have id DateTime @id or id Float @id.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So it's actually ok to not suggest it then 😄

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is an interesting fundametnal discussion: Do we want to suggest all the things that validate, or only the things we want to encourage?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With id DateTime @id id Float @id it sounds very bad
Maybe we should still suggest it because a handful of people would actually know how to use that. But then it's a "foot gun" for most people, I guess?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added a comment for now

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update per discussion on slack:
It is possible to display hints / tooltips
image
Therefore, I am of the mind that we enable @id for all fields that are already supported in engines. Then we can work on adding these tooltips for usage of @id on fields that wouldn't be recommended with an explanation as to why.

github-actions bot added a commit that referenced this pull request Jul 18, 2022
github-actions bot added a commit that referenced this pull request Jul 18, 2022
@Jolg42 Jolg42 merged commit a08656d into main Jul 18, 2022
@Jolg42 Jolg42 deleted the joel/fix-@id-suggestions branch July 18, 2022 09:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Check when @id is suggested and fix
4 participants