Skip to content

Feature Request: Auto expand all nested references recursivelly #941

@JRebella

Description

@JRebella

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions