Querying Data from existing Cassandra DB via Stargate GraphQL API
I tried to search from google to find how actually use GraphQL API provided by Stargate in situations when you have existing production Cassandra DB and you cannot or want to do schema changes to db.
After some digging it was pretty straightforward at least with Datastax Astra DB.
Stargate provides two endpoints by default:
/graphql-schema
/graphql/{keyspace-name}
Later one is interesting in my case. So point your playground to url ..../api/graphql/{keyspace}
If you need help how to get started and setup stargate stuff just go Develop with GraphQL
And do query like this (replace table name and fields to match your schema):
query TestQuery {
testTable1(value: { primaryKeyField: "XXX" }) {
values {
primaryKeyField
otherfield
}
}
testTable2(value: { primaryKeyField2: "YYY" })
{
values {
field1
field2
}
}
}
Easy piecy, this is how you can get data from multiple tables with single request. Could be helpful in cases where original DB schema is not designed to support queries you need.
That's it. Thanks for reading this far!