Skip to content
This repository has been archived by the owner on Mar 26, 2024. It is now read-only.

[v1][client] Error when using snippets/string variables #290

Open
madeleineostoja opened this issue Feb 16, 2023 · 0 comments
Open

[v1][client] Error when using snippets/string variables #290

madeleineostoja opened this issue Feb 16, 2023 · 0 comments

Comments

@madeleineostoja
Copy link

madeleineostoja commented Feb 16, 2023

I'm trying to use query snippets/fragments exported from a shared lib to reduce boilerplate, but the codegen client throws the following error:

Error: Found unsupported source node type "Unknown" in reduceObjectStructures call. Please open an issue.

The basic shape of what I'm trying to do:

fragments.ts

export const asset = groq`'': asset->{url,extension}`;

query.ts

sanity(
  'Home',
  groq`*[_id == "home"][0]{
    ...,
    image {
      ${asset}
    }
  }`
);

Removing the ${...} snippet fixes the issue.

Does the codegen client need to statically analyse the query? Because snippets like this work fine with the standard sanity client (not sure if it's common practice or not, I'm coming from a graphql background and was missing my fragments)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant