Issue
Given query
query user($id: Int!) {
getUser(id: $id) {
id
name
}
}
I'd like to grab multiple users and get them returned as an array ex: const users = [1, 2, 3, 5]
I it possible to query this from client, or do I need to define new Query on the server?
I am using Apollo with React btw.
Solution
Adding to @Jonathan's answer:
If you want to generalize to "give me an array of users based on an array of ids and you have the ability to add a mutation to the server, then define a new mutation:
mutation getUsersFromIds(ids: [ID!]!) [User]
Otherwise there is no generalized looping construct in GraphQL.
Answered By - Michel Floyd
Answer Checked By - - Katrina (ReactFix Volunteer)