# How to handle namespaces in GraphQL

**URL:** <https://community.stardog.com/t/how-to-handle-namespaces-in-graphql/2321>\
**Category:** Stardog Studio\
**Created:** [March 19, 2020, 3:41pm UTC](https://community.stardog.com/t/how-to-handle-namespaces-in-graphql/2321 "2020-03-19T15:41:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![R3000](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/r3000/32/358_2.png) [@R3000](https://community.stardog.com/u/R3000)\
**Post date:** [March 19, 2020, 3:41pm UTC](https://community.stardog.com/t/how-to-handle-namespaces-in-graphql/2321/1 "2020-03-19T15:41:07Z")

</div>

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,  
Radu

---

<div class="post-metadata">

**Author:** ![zachary.whitley](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/zachary.whitley/32/94_2.png) [@zachary.whitley](https://community.stardog.com/u/zachary.whitley)\
**Post date:** [March 19, 2020, 6:18pm UTC](https://community.stardog.com/t/how-to-handle-namespaces-in-graphql/2321/2 "2020-03-19T18:18:25Z")

</div>

See this section in the docs for namespaces [Home | Stardog Documentation Latest](https://www.stardog.com/docs/#_namespaces_2)

Stardog examples are usually at this [repo](https://github.com/stardog-union/stardog-examples), although I don't think there are any GraphQL examples yet. There might be some stuff in the stardog blog.

---

<div class="post-metadata">

**Author:** ![R3000](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/r3000/32/358_2.png) [@R3000](https://community.stardog.com/u/R3000)\
**Post date:** [March 19, 2020, 8:32pm UTC](https://community.stardog.com/t/how-to-handle-namespaces-in-graphql/2321/3 "2020-03-19T20:32:04Z")

</div>

Thanks Zach! That worked.

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

Thanks,  
Radu

---

<div class="post-metadata">

**Author:** ![evren](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/evren/32/1515_2.png) [@evren](https://community.stardog.com/u/evren)\
**Post date:** [March 19, 2020, 8:41pm UTC](https://community.stardog.com/t/how-to-handle-namespaces-in-graphql/2321/4 "2020-03-19T20:41:37Z")

</div>

Raud,

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](https://github.com/stardog-union/stardog-examples/blob/d826146324306faf069f42f947a530f3c264aec2/examples/api/main/src/com/complexible/stardog/examples/api/GraphQLExample.java) in the examples repo but the example only uses the default namespace so not relevant here,

Best,  
Evren
