

If you remember from our Bucket images above, each document is defined by a key in a format like airline_1234 where 1234 is the id of the airline. We also have “ airlineByKey” endpoint where we will fetch a single Airline. This means we will be getting a list of airlines back. Notice that the return value of this endpoint is an array of Airline. Next, we have an Endpoint named “ airlinesUK“. This object model the document structure found in our Couchbase travel-sample bucket where the type is “airline”.

In our GraphQL code, we have an object of type Airline. Understanding when and where to use each is important from the perspective of building the API, we wouldn’t want to use a N1QL query to return a single document that we can get by key. This operation does not use the N1QL query language and therefore does not have any additional overhead. I made the “airlineByKey” endpoint simply to show an example of retrieving a single Couchbase document by key. In our React app, we will only use the “airlinesUK” endpoint. One named “airlinesUK” and the other “airlineByKey”. We have two endpoints defined by that Query. The Query type specifies which GraphQL queries clients can execute against its own data graph.
