How to query all people using GraphQL with Star War API?

How to query all people using GraphQL with Star War API?


0

I tried the sample in the book Learning GraphQL, 1st Ed, by O’Reilly:

query {
 person(personID: 5) {
   name
   birthYear
 }
}

on https://graphql.org/swapi-graphql
and was able to get back:

{
 "data": {
   "person": {
     "name": "Leia Organa",
     "birthYear": "19BBY"
   }
 }
}

However, I tried to look for how to omit the personID and get all people, but can’t:

query {
 person {
   name
   birthYear
 }
}

or

query {
 allPeople {
   name
   birthYear
 }
}

They both gave errors and I can’t find the answer in many parts of the book.

I did see an example like this:

query {
  allLifts {
    name
    status 
  }
}

which is for all ski lifts in a "fake ski resort". So my Star War query is very similar to it but it doesn’t work.

How can it be done?


Load 6 more related questions


Show fewer related questions

0



Leave a Reply

Your email address will not be published. Required fields are marked *