Dgraph client using HTTP API
This library still under development, and the API may change completely, contributions and suggestions are welcomed.
-
Add the dependency to your
shard.yml
:dependencies: dgraph: github: tareifz/dgraph
-
Run
shards install
require "dgraph"
require "dgraph"
class Test
class Movie
JSON.mapping(
name: String
)
end
JSON.mapping(
movie: Array(Movie)
)
end
client = Dgraph::Pooled.new
res = client.query(%(
query test($name: string) {
movie(func: allofterms(name, $name)) {
name
}
}
), {"$name" => "Star Wars"})
result = Dgraph::QueryResult(Test).from_json(res)
if result.errors.empty?
result.data.try do |data|
data.movie.each do |mov|
pp mov.name
end
end
else
result.errors.each do |err|
pp err.code
end
end
require "dgraph"
client = Dgraph::Pooled.new
res = client.alter(%(
name: string @index(term) .
))
if res.success?
res.data.try do |data|
pp data.message
end
end
if res.fail?
res.errors.each do |err|
pp err.message
end
end
- Query
- Alter
- Mutations
- Transactions
- Fork it (https://github.com/tareifz/dgraph/fork)
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
- tareifz - creator and maintainer