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

import client from @sanity-typed/client instead of @sanity/client #959

Closed
xuzuodong opened this issue Feb 11, 2024 · 3 comments
Closed

import client from @sanity-typed/client instead of @sanity/client #959

xuzuodong opened this issue Feb 11, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@xuzuodong
Copy link
Contributor

xuzuodong commented Feb 11, 2024

@sanity-typed is a project completes Sanity's developer experience with typescript, which includes @sanity-typed/client with typed GROQ Results. It seems to be good if nuxt-sanity can optionally import client from this package. Is it possible to do so for better TypeScript DX?

@xuzuodong xuzuodong added the enhancement New feature or request label Feb 11, 2024
@danielroe
Copy link
Collaborator

This is extremely cool. Would it be sufficient to allow the import to be configurable? Is it otherwise equivalent in API?

@xuzuodong
Copy link
Contributor Author

xuzuodong commented Mar 19, 2024

I think the most intuitive way to do so is to add typedClient configuration in sanity field in nuxt.config.ts:

sanity: {
    projectId: 'myProject',
    typedClient: true // requires users to explicitly set
},

Although this may be conflict with another configuration minimal. Maybe we can mix the two features up and do something like:

sanity: {
    projectId: 'myProject',
    clientType: 'typed' // can also be 'minimal' or 'default', defaults to 'default'
},

In this way, the minimal configuration should be deprecated, and causes breaking changes though.

@xuzuodong
Copy link
Contributor Author

For those who want better TypeScript DX, Sanity now introduces an experimental feature called Sanity TypeGen which supersedes @sanity-typed. Sanity TypeGen supports generate types via its CLI, so I think this issue can be closed now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants