Reputation: 25964
I am looking for a Graph database using Scylla or Cassandra as the backend and then expose the web api as GraphQl.
Can you help me verify that I have got the followin stack right:
Upvotes: 6
Views: 1803
Reputation: 946
I like @MarcintheCloud's answer, just wanted to paraphrase and give my solution to the problem.
GraphQL does not care or depend on any specific database type, KV, Graph, Document, etc and in fact markets itself as being able to fetch data from different sources. So you can create a UI to fetch the latest stock prices from redis, stock history from Mongo and similar stock by name from Elasticsearch. GraphQL will let you abstract that complexity away from your API (but it still exists elsewhere) allowing you to fetch all the data in one go. There is no relation between GraphQL and Graph databases.
Gremlin, in brief, is a powerful graph traversal comparable to what SQL is for some relational databases.
Definitions aside, how I use the both of them is by mapping GraphQL to Gremlin. I have attempted to create a standard around it https://github.com/The-Don-Himself/graphql2gremlin. Basically, it works by interchanging GraphQL arguments between vertexes and edges so a GraphQL query like this
{
users(
following: {
users: {
user_id: "eq(5)"
}
}
) {
user_id
username
bio
}
}
Means fetch a users followers for user_id 5 and get the id, username and bio fields. There are samples of much more complex GraphQL to Gremlin examples and it works perfect for my use case.
The gremlin traversal could look like this
g.V().hasLabel('users').has('user_id', eq(5)).in('following').hasLabel('users').values('user_id', 'username', 'bio')
I also open sourced a sample Twitter Graph in PHP if you want to play around with it https://github.com/The-Don-Himself/gremlin-ogm.
Upvotes: 2
Reputation: 1653
You've pretty much got it right though just to help clarify:
GraphQL is an abstraction designed to help make development/data access a bit simpler for developers. You would have to create a service that translates GraphQL into Gremlin.
The stack you're envisioning looks like:
GraphQL -> Gremlin/TinkerPop -> JanusGraph -> DataStore (Cassandra, Scylla, etc).
As far as the datastore is concerned, JanusGraph is compatible with both Apache Cassandra and Scylla.
Upvotes: 13