Dark Mode

Prerequisites

Let's check that the data was inserted.Use the query book with the primary key to find a book based on its title.Use http://$ASTRACLUSTERID-$ASTRA_REGION.apps.astra.datastax.com/api/graphql/library to execute the query in GraphQL playground:

It is also possible to find books with a partial primary key. If more than one bookhas the same title (partition key), for instance, but different ISBN codes (clustering key),then a listing of all books that match can be retrieved:

In both queries, the title , isbn , and author are specified as return results.

To display the contents of a UDT, notice the inclusion of addresses and itsembedded fields in the values designated as return values in this query to retrieve the readers:

In this example, the primary key consists of both name and user_id , to distinguishreaders who might have the same name.

Stargate only allows combinations of fields that have:

  • at most one indexed field in the query
  • if no indexed field is present, then all partition key fields must be present
  • it's possible to omit some or all of the clustering fields (in which casethe query may return multiple rows)

'Filter options for reads'

It's possible to customize the CQL condition of each parameter with `@cql_where`with the following arguments:

  • field: the GraphQL field name to which the condition applies
  • predicate: the conditional predicate to use

The filters available are:

PredicateGraphQL fields that can have condition applied
EQ (equal)partition key, clustering key, regular indexed field
IN (within)partition key, clustering key, regular indexed field
GT (greater than)clustering key
GTE (greater than or equal to)clustering key
LT (less than)clustering key
LTE (less than or equal to)clustering key
CONTAINSregular indexed field that is a list and has an index target of VALUES

IN example, that finds the books that are listed in the supplied array:

IN example with 2 partition keys, demonstrating that values for eachcan be supplied:

GT example, that looks for equality on the partition key, and then a range ofpossible values for the clustering field:

GT example #2, that looks for a book with a title and an ISBN code that isgreater than the value supplied:

LT example, that looks for a book with the same title and an ISBN code that isless than the value supplied:

CONTAINS example that shows how to retrieve a reader that submitted asupplied review: