Can I treat GraphQL as going toward being a "better tinker pop"? If not than what are the use cases for GraphQL in the context of existing graph databases?
https://facebook.github.io/react/blog/2015/05/01/graphql-int...
The spec has a better description: https://facebook.github.io/graphql/#sec-Overview
" GraphQL is a query language designed to build client applications by providing an intuitive and flexible syntax and system for describing their data requirements and interactions.
GraphQL is not a programming language capable of arbitrary computation, but is instead a language used to query application servers that have capabilities defined in this specification. GraphQL does not mandate a particular programming language or storage system for application servers that implement it. Instead, application servers take their capabilities and map them to a uniform language, type system, and philosophy that GraphQL encodes. This provides a unified interface friendly to product development and a powerful platform for tool‐building."
This is very different goal that most graph query languages.
Currently a lot of research is being done on graph databases, and they can be potentially faster for queries that normally take a lot of joins.
But it isn't a way to specify graph queries, e.g. you can't express concepts like "find the shortest path from vertex A to vertex B using edges with the given label". It's just not designed for that kind of thing.
I think Facebook's naming people do this on purpose. (j/k)
I'm not implying that the bindings should have been used. I'm now considering writing a implementation of GraphQL in Haskell and I'm trying to assess whether it's worth using the Facebook C bindings or it's better to implement the whole protocol from scratch.
I think main reasons for this are platform independence and ease of building/packaging/deployment. Also JDK (standard library) and library ecosystem are strong enough to provide pure jvm-based library implementations for most of the scenarios. JVM performance is also pretty good, so there is no necessity to write/use native libraries just to make application more performant.
One reason is that you have to have a schema defined for database already e.g. using Slick, it should be reusable for GraphQL schema as is. Having same schema defined several times is pain.
This implementation requires one to write schema, that is in many ways (maybe fully) identical to your database schema e.g. Slick schema thus you have to write it twice. It would be a better to infer the GraphQL schema from Slick/database schema.
On the other hand, I would argue that it can be advantageous to have a separate model which is exposed through a public API:
1. GraphQL has `description` fields on all entities like types, fields, enum values, etc. This documentation can be retrieved via introspection API. Its not always possible to extract this information from other models, like object-relation mappings.
2. Being datasource agnostic on a low level gives sangria and it's users much more flexibility in terms of where and how they fetch data. This still has a room for integration with other libraries. For example, I can imagine scenario where part of schema is generated based on the Slick mappings, some other part is hand-written and yet another part of it is generated based on swagger/raml service definition (this part of schema will fetch data from some external REST service).
3. Data model evolves over time. Tight coupling between internal data model and publicly exposed model can look reasonable at the beginning of the project, but can become very frustrating over the time. By decoupling these two models from each other you allow them to age and evolve independently. Public API has much more strict requirements when it comes to change. Because of this GraphQL includes the concept of deprecation - you can deprecate fields and enum values. Deprecated fields and values will not show up in the introspection results unless you explicitly asked for it.
4. GraphQL also includes data mutation. While it can be possible to generate the read model from, let's say, Slick mappings, I don't think it would be a good idea to do the same for a write model. GraphQL allows you to define two different models for reads and writes (`Schema` takes mandatory query `Type` and optional mutation `Type` as an argument). I would say that GraphQL has more in common with CQRS (Command Query Responsibility Segregation) rather than CRUD (create, read, update and delete) model. Considering this, I would say that it is advantageous to put careful attention to a write model modeling and model it independently from a read model.