Virtual graph from REST API


(Bart Van Leeuwen) #1

Hi

This might be somewhat of a broad question to ask but I'll try it anyway,
I would like to incorporate a REST API into a virtual graph, so results that come from a REST API converted to RDF and then in general queryable through SPARQL.

E.g. I have a set of data about buildings with ID's in my graphstore, I'd like to have the ID as a parameter to the REST Api and the result for example building details incorporated into the knowledge graph.

If the question is not clear let me know as well :slight_smile:

Bart


(Jess Balint) #2

Hi Bart,

Good question. :slight_smile: While the inbuilt virtual graph feature is targeted at mapping other databases, we do provide a semi-public service API. The service API provides an extension point which can be used to answer a fragment of a SPARQL query. The implementation must be written in Java (or another JVM language). We have an entry in the examples repo here with a test that illustrates how to use it.

We recognize the importance of this type of integration and plan to offer a REST-based virtual graph facility in the future.

Jess


(zachary.whitley) #3

I've been a bit curious about one aspect of the service api. It doesn't appear to require that the service portion must be a sparql fragment. If that's the case how terrible of a person would I be to put something other than a sparql fragment in there?


(Jess Balint) #4

The "plan node" argument to createQuery() is a query fragment. What you do with that is up to you.

Jess


(zachary.whitley) #5

So the query will fail to parse if it's not a valid query fragment?

For example, could you do something like this...

SELECT * WHERE {
  SERVICE <jdbc:myql://localhost/test> {
          SELECT * FROM mytable
  }
}

It's just and example and I know that's something you could do with a virtual graph mapping.


(Jess Balint) #6

Yeah that will fail to parse. However, there's nothing stopping you from putting :my :query "SELECT * FROM mytable" inside the service block.