Search code examples
graphdb

Select repository via the REST API


I'm trying to use the new embedded visualisation feature. I have an iframe that points to the graphdb server with url in the form :

http://localhost:7200/graphs-visualizations?uri=[...]&embedded

That works fine, but only for the default or previously selected repository. I can't find a way to select repositories without having to manually go to http://localhost:7200/

It seems that the repository selection is stored in a cookie, and that the X-GraphDB-Repository HTTP header is available, but nothing seems to work with iframes.

Is there a way to select repositories through url ? &repository= would be perfect.

More detail : we have an app with N "studies" backed with N repositories (with SPARQL queries), when a user selects a study, then an uri, we want to display a Visual Graph iframe. That works for the default or previously selected repository, but when she go to another study, we need a way to transparently update/select the repository in the Workbench app.

The only solution we see for the moment is to use a proxy that will set the cookie on the fly. But that seems overkill.


Solution

  • We finally decided to configure a nginx proxy workaround. It works well, but a ?repository= query feature is definitely missing.

    map $arg_repository $repo_cookie {
      "~^(?<repo>[0-9a-f]{32})$" "com.ontotext.graphdb.repository7200=$repo";
    }
    
    server {
      listen 7200;
      server_name localhost;
    
      location / {
        add_header Set-Cookie $repo_cookie;
        proxy_pass http://graphdb:7200;
      }
    }