menu

Apollo

A community of developers, designers and others who love Apollo and GraphQL. 🚀

Channels
# All channels
view-forward
# General
view-forward
# Apollo Angular
view-forward
# Announcements
view-forward
# Apollo Android
view-forward
# Apollo Client
view-forward
# Apollo iOS
view-forward
# Apollo Link
view-forward
# Apollo Link Rest
view-forward
# Local State
view-forward
# Apollo Studio
view-forward
# Apollo Server
view-forward
# Apollo Tooling
view-forward
# Contributing
view-forward
# Docs
view-forward
# Events
view-forward
# GraphQL Tools
view-forward
# Jobs
view-forward
# Random
view-forward
# React Apollo
view-forward
# Showcase
view-forward
# Subscriptions
view-forward
# Testing
view-forward
# Vue Apollo
view-forward
Team

Resolving an Array of IDs

April 1, 2020 at 4:01pm

Resolving an Array of IDs

April 1, 2020 at 4:01pm
Say I have some query
query Collection($parentId: ID!) {
parent(parentId: $parentId) @rest(type: "Parent", path: '/parent') {
children(childId: $childId) @rest(type: "Child", path: '/children') {
id name
}
}
}
Now, the REST response from /parent, looks like
[
{ "children": ["a", "b", "c"] },
{ "children": ["d", "e", "f"] }
]
What I want is to get those lists of IDs and query for them each
Should I do something like
query Collection($parentId: ID!) {
parent(parentId: $parentId) @rest(type: "Parent", path: "/parent") {
childIds: children(childId: $childId) @export(as: "childId") # fine, but this is a list, will the next line execute all fetches?
children @rest(type: "Child", path: "/children") {
id name
}
}
}
This is a pretty common pattern but it wasn't clear from my read of the documentation.
No messages yet