Seena V P
Seena V P

Reputation: 994

Cassandra support in apollo graphql

I want to connect Apache Cassandra to apollo graphql server. Is there any ORM library available for cassandra in node just like Sequelize for relational databases. Can any one please help me out

Upvotes: 0

Views: 1327

Answers (2)

csplinter
csplinter

Reputation: 51

There is an automatically generated GraphQL API for Cassandra that you can run as a service to expose your CQL tables via GraphQL.

GitHub repo: https://github.com/datastax/cassandra-data-apis

Small Example: Say you have the a table called books

CREATE TABLE library.books (
    title text PRIMARY KEY,
    author text
);

It will automatically generate these APIs

schema {
  query: Query
  mutation: Mutation
}

type Query {
  books(value: BooksInput, orderBy: [BooksOrder], options: QueryOptions): BooksResult
  booksFilter(filter: BooksFilterInput!, orderBy: [BooksOrder], options: QueryOptions): BooksResult
}

type Mutation {
  insertBooks(value: BooksInput!, ifNotExists: Boolean, options: UpdateOptions): BooksMutationResult
  updateBooks(value: BooksInput!, ifExists: Boolean, ifCondition: BooksFilterInput, options: UpdateOptions): BooksMutationResult
  deleteBooks(value: BooksInput!, ifExists: Boolean, ifCondition: BooksFilterInput, options: UpdateOptions): BooksMutationResult
}

And you can query them with

mutation {
  catch22: insertBooks(value: {title:"Catch-22", author:"Joseph Heller"}) {
    value {
      title
    }
  }
}

query {
    books (value: {title:"Catch-22"}) {
      values {
        title
        author
      }
    }
}

Upvotes: 1

Alejandro RV
Alejandro RV

Reputation: 36

Maybe this could help:

http://express-cassandra.readthedocs.io/en/stable/

From the description of the page: Express-Cassandra is a Cassandra ORM/ODM/OGM for NodeJS with Elassandra & JanusGraph Support.

Upvotes: 2

Related Questions