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

[@sanity/react-loader]: loadQuery() cache type issue #910

Open
fcisio opened this issue Feb 13, 2024 · 2 comments
Open

[@sanity/react-loader]: loadQuery() cache type issue #910

fcisio opened this issue Feb 13, 2024 · 2 comments

Comments

@fcisio
Copy link

fcisio commented Feb 13, 2024

Describe the bug

The option cache is part of the interface, but it's typed as cache?: undefined.
So it will always throw an error.

To Reproduce

const initial = await context.sanity.loadQuery<PageQuery>(
    PAGE_QUERY,
    params,
    {
      // @ts-expect-error
      cache: context.storefront.CacheShort(),
    },
  )
  1. Create an instance of loadQuery()
  2. Set a cache
  3. See the error and type of the option
  4. Adding // @ts-expect-error makes the error go away

Expected behavior

cache should be typed properly

Screenshots

Screenshot 2024-02-13 at 4 15 03 PM Screenshot 2024-02-13 at 4 15 12 PM

Which versions of Sanity are you using?

@sanity/cli (global) 3.28.0 (latest: 3.29.0)
@sanity/image-url 1.0.2 (up to date)
@sanity/mutator 3.29.0 (up to date)
@sanity/react-loader 1.8.3 (up to date)
@sanity/types 3.29.0 (up to date)
@sanity/visual-editing 1.2.2 (up to date)

What operating system are you using?

Mac Sonoma

Which versions of Node.js / npm are you running?

10.2.3
v20.10.0

@stipsan
Copy link
Member

stipsan commented Feb 14, 2024

Hi @fcisio,
it looks like you're doing something that isn't supported.
The cache option is only relevant to next projects. For this to work I believe it would have to be implemented in https://github.com/sanity-io/hydrogen-sanity/

@fcisio
Copy link
Author

fcisio commented Feb 14, 2024

Humm I see...
Then what is the default cache behavior of loadQuery?
Only covering next seems like an oversight.

I think it'll be quite some time until hydrogen-sanity supports the Stega client. Do I have any alternative in the meantime?

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

No branches or pull requests

2 participants