Search⌘ K
AI Features

Graph and Query APIs

Explore how to define and implement Graph and Query APIs to manage RDF graph services. Understand CRUD operations, querying with SPARQL, and how to pull metrics through graph info functions to efficiently handle global data integration.

Graph API

We can define our graph services API as follows:

Elixir
def graph_create(%GraphCommons.Graph{} = graph) do
if rdf_store_admin() do
graph_delete()
graph_update(graph)
else
{:error, rdf_store()}
end
end
def graph_delete() do
if rdf_store_admin() do
{:ok, env} = Tesla.delete(rdf_store_admin())
GraphCommons.Graph.new(env.body, "", :rdf)
env
else
{:error, rdf_store()}
end
end
def graph_read() do
if rdf_store_admin() do
{:ok, env} = Tesla.get(rdf_store_admin())
GraphCommons.Graph.new(env.body, "", :rdf)
else
{:error, rdf_store()}
end
end
def graph_update(%GraphCommons.Graph{} = graph) do
if rdf_store_admin() do
{:ok, env} = Tesla.post(rdf_store_admin(), graph.data, headers: [{"content-type", "text/turtle"}])
GraphCommons.Graph.new(env.body, "", :rdf)
else
{:error, rdf_store()}
end
end

This defines the API for CRUD operations, although we can expand the ...