How to handle namespaces in GraphQL

So I have loades starwas.ttl and sample graph queries from documentation work fine.

Now I would like to develop graphql queries for my own knowledge graph that has prefixes and namespaces - usual sparql RDF stuff...

  • How do I do that?

Example or tutorial should help.

Thank you,

See this section in the docs for namespaces

Stardog examples are usually at this repo, although I don't think there are any GraphQL examples yet. There might be some stuff in the stardog blog.

Thanks Zach! That worked.

Now one more question - can I separate the withPrefixes directive into some separate json file . Is that possible?



If you store the namespaces in the database then you don't need the explicit directive and you can use prefixes like foaf_ directly in your queries. Otherwise there is no option to separate directives from queries.

The next release will also introduce a new schema directive that will let you define the namespaces at the GraphQL schema level so they don't have to be repeated in queries and you can use filed names without the namespace prefixes.

As a side note, there is a GraphQL example in the examples repo but the example only uses the default namespace so not relevant here,



Thanks for this great tip! My graphql query is much cleaner and concise now :smile:!

This capability is awesome for client side developers that need simplicity.

P.S. Java example is good ... but a react example could be better :wink: