-
Notifications
You must be signed in to change notification settings - Fork 3
Home
The hope when building dgraph_ex was to allow Elixir developers like myself to quickly begin using dgraph. dgraph is a new, fast, distributed, open-source graph database that uses a GraphQL-like syntax and/or gRPC requests for querying and modifying data. DgraphEx is an Elixir HTTP client for dgraph. This library was created to ease developers into the use of dgraph through the guided help of a language that we all love.
This library has aspired to keep the easy-to-use feeling of writing dgraph queries in GraphQL+- as well as providing helper functions and modeling to allow applications to be more concrete.
Some features of this library were inspired by Ecto such as the method of model definition, Repo
as the model-to-database interaction module, changesets, and keyword syntax, but there are significant differences from Ecto as well. For example, equivalence in Ecto is asserted with double equals ==
in dgraph_ex equality or equivalence is asserted with the eq/2
expression. The reason double-equals is not used in dgraph_ex is 1) (honestly) AST macros are difficult and I am not on ericmj's level and 2) (and more importantly) the eq
expression is part of dgraph's GraphQL+- syntax. If I wanted to assert equivalence between a name
field in dgraph and the string "Jason"
in dgraph_ex I would use the expression eq(:name, "Jason")
in dgraph's GraphQL+- I would use eq(name, "Jason")
. The previous two expressions only differ by one character the :
of the name
in the Elixir example. By using syntax that more closely resembles GraphQL+- I believe there will be fewer programming errors (on my part and on the part of other devs) and the syntax will be easier to parse for those familiar with GraphQL+- should a query not work as intended.
All examples are run under the context of having run:
import DgraphEx
alias DgraphEx.Repo