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 Typegen]: Support wild-card (*) imports when constructing queries #7418

Open
r0skar opened this issue Aug 24, 2024 · 1 comment
Open
Labels
typegen Issues related to TypeScript types generation

Comments

@r0skar
Copy link

r0skar commented Aug 24, 2024

Describe the bug

I am not a 100% sure if this qualifies as a bug report or if it should be a feature request. Currently, we can not use a wild-card (*) import to import fragments of a query.

To Reproduce

Steps to reproduce the behavior:

  1. Create a new file query.ts
import * as F from "./fragments";

export const getSite = groq`*[_type == "site"][0]{
  name,
  "seoMetadata": seoMetadata${F.SEO_META_DATA_FRAGMENT},
}`;
  1. Run typegen.
  2. Typegen throws an error.
❌ Unsupported expression type: MemberExpression in lib/sanity/queries.ts:8:30 in "lib/sanity/queries.ts"

Expected behavior

Types should be generated.

Which versions of Sanity are you using?

@sanity/cli (global)  3.55.0 (up to date)
@sanity/types         3.55.0 (up to date)
@sanity/vision        3.55.0 (up to date)
sanity                3.55.0 (up to date)

Additional context

This works as expected:

import { SEO_META_DATA_FRAGMENT } from "./fragments";

export const getSite = groq`*[_type == "site"][0]{
  name,
  "seoMetadata": seoMetadata${SEO_META_DATA_FRAGMENT},
}`;
@rexxars rexxars added the typegen Issues related to TypeScript types generation label Sep 16, 2024
@dogfrogfog
Copy link

experiencing the issue right now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
typegen Issues related to TypeScript types generation
Projects
None yet
Development

No branches or pull requests

3 participants