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

Add support for @sanity-typegen-ignore to ignore queries #6578

Merged
merged 3 commits into from May 21, 2024

Conversation

largis21
Copy link
Contributor

@largis21 largis21 commented May 6, 2024

Description

Added functionality in findQueriesInSource.ts to ignore queries which are prefixed with the comment @sanity-typegen-ignore.

In some cases you want to extract a single use query to its own value:

const query = `
  *[_type == "post"]
`

const posts = await client.fetch(query)

Now if you validate the posts with zod you will have to explicitly write the result anyway

What to review

If there are any other cases than the ones specified in the function getDeclarationLeadingComment, please let me know and I will add them

Testing

Added tests for const declarations, export const and making sure it chooses the correct comment if there are multiple leading comments

Notes for release

@largis21 largis21 requested a review from a team as a code owner May 6, 2024 12:39
Copy link

vercel bot commented May 6, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
performance-studio ✅ Ready (Inspect) Visit Preview May 21, 2024 10:59am
test-next-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 21, 2024 10:59am
1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
studio-workshop ⬜️ Ignored (Inspect) Visit Preview May 21, 2024 10:59am

Copy link

vercel bot commented May 6, 2024

@largis21 is attempting to deploy a commit to the Sanity Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Member

@sgulseth sgulseth left a comment

Choose a reason for hiding this comment

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

This is a nice addition that unlocks a few use cases for us, thanks! Have some feedback to just improve the experience

@sgulseth
Copy link
Member

sgulseth commented May 8, 2024

Awesome! Can you rebase sanity-io/sanity:main onto you branch?

@largis21 largis21 force-pushed the feature/sanity-typegen-ignore branch from f95582e to c7d09a6 Compare May 8, 2024 09:14
@largis21
Copy link
Contributor Author

largis21 commented May 8, 2024

Should be up to date now

@sgulseth
Copy link
Member

Hi! So sorry I missed your update, but are you OK with doing another rebase/merge?

@largis21
Copy link
Contributor Author

Up to date again now :)

Copy link
Member

@sgulseth sgulseth left a comment

Choose a reason for hiding this comment

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

nice!

@sgulseth sgulseth added this pull request to the merge queue May 21, 2024
Merged via the queue into sanity-io:next with commit efe8bca May 21, 2024
6 of 7 checks passed
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.

None yet

2 participants