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

Feature Request: Auto expand all nested references recursivelly #941

Open
JRebella opened this issue Dec 5, 2024 · 0 comments
Open

Feature Request: Auto expand all nested references recursivelly #941

JRebella opened this issue Dec 5, 2024 · 0 comments

Comments

@JRebella
Copy link

JRebella commented Dec 5, 2024

Working with deeply nested schemas, it can become very cumbersome to expand every referenced entry in the queries. For example:

groq`*[_type == "movie" && _id == "123"]{
  ...,
  "directors": directors[]->{
    ...,
    "awards": awards[]->{
      ...,
      "organization": organization->{
        ...,
        "country": country->
      }
    },
    "filmography": filmography[]->{
      ...,
      "cast": cast[]->{
        ...,
        "agency": agency->
      }
    }
  },
  "producers": producers[]->{
    ...,
    "awards": awards[]->{
      ...,
      "organization": organization->{
        ...,
        "country": country->
      }
    },
    "projects": projects[]->{
      ...,
      "budgetDetails": budgetDetails->{
        ...,
        "currency": currency->
      }
    }
  }
}
`;

Not sure which syntax would make the most sense, but something simple like this would work wonders:

groq`*[_type == "movie" && _id == "123"]{
  (...)->,
}
`;

As in, expand every reference field and also those within the references themselves, recursively. Parameters that could be helpful:

  • A way of limiting the maximum depth to expand (example max depth 3, any references deeper than 3 levels wouldn't get expanded)
  • A way of limiting expanding circular dependencies. Maybe a boolean, that if true, when a reference was already expanded somewhere else in the current tree branch, it wouldn't get expanded again (if you have some sort of circular dependency like person1 -> twin field (also type person) value person2 -> again twin field in person2 -> person1, person1 wouldn't be expanded since it was already expanded at the root)
@JRebella JRebella changed the title Auto expand all nested references recursivelly Feature Request: Auto expand all nested references recursivelly Dec 5, 2024
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

1 participant