I'm new to GraphQL and I'm working with an appointments app. This is the data that I'm getting from the API
[
  {
    "appointmentID": "xza120",
    "patient": {
      "firstName": "John",
      "lastName": "Black"
    }
  }
]
Querying appointment by id was relatively easy.
query GetAppointmentById {
  appointment(appointmentCode: "xza120") {
    appointmentID
    firstName
    lastName
  }
}
My question is: What about if I want to look for the combination of appointmentID and lastName? (Eg: A patient might have multiple appointments, so I just want to retrieve the appointment code that matches with the last name.). Is it possible to do it with GraphQL? Should I prefer to do it in the code rather than in the query?
Thanks a lot in advance,
Guillermo.
Since GraphQL is a spec and each server determines the arguments it accepts and their behavior it's hard to generalize and still provide accurate information; this said, you can provide multiple arguments to a query and typically servers will support this. For example:
query GetAppointmentById {
  appointment(appointmentCode: "xza120", lastName: "Black") {
    appointmentID
    firstName
    lastName
  }
}
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With