TerminusDB - Now with GraphQL
Tags: graphql, database, news, showdev
Published: 2022-11-17 14:20:12

For those of you that don't know, TerminusDB is a document graph database with Git-like superpowers. It stores data as JSON documents and the schema language connects these into a graph. You get the best of both worlds, the convenience of JSON with the query power of Graph.

The latest version of TerminusDB has been released which means TerminusDB now comes with GraphQL to improve the developer experience. Your data product schemas are automatically loaded in GraphQL for speed and convenience. GraphQL means you can now use any programming language to work with TerminusDB.

Enhancements include – 

- GraphQL endpoint at localhost:6363/api/graphql/ORG/DB
- GraphiQL endpoint for testing available at localhost:6363/graphiql/ORG/DB
- GraphQL automatic loading of Schema in GraphQL schema
- GraphQL search and retrieval

[Head on over to GitHub](https://github.com/terminusdb/terminusdb/releases/tag/v10.1.8) for a full list of enhancements and bug fixes.

If you want to learn more, take a look at our [GraphQL docs](https://terminusdb.com/docs/guides/reference-guides/graphql_query) or [install the latest version of TerminusDB](https://terminusdb.com/docs/) to experiment and play.

Excitingly, this release is a big step toward our TerminusDB becoming a headless CMS and connecting content in a knowledge graph. You can read more about our plans for [headless CMS](https://terminusdb.com/blog/terminusdb-a-headless-cms/) here.

Here’s a quick example of how GraphQL works in TerminusDB – 

Using the following TerminusDB schema:

```json
{ "@type" : "Class",
  "@id" : "Person",
  "name" : "xsd:string",
  "dob" : "xsd:dateTime",
  "friend" : {"@type" : "Set", "@class" : "Person" }}
```

TerminusDB will generate the following GraphQL class.

```graphql
type Query {
  Person(
    id: ID

    """skip N elements"""
    offset: Int

    """limit results to N elements"""
    limit: Int
    filter: Person_Filter

    """order by the given fields"""
    orderBy: Person_Ordering
  ): [Person!]!
}

type Person {
  dob: DateTime!
  friend(
    id: ID

    """skip N elements"""
    offset: Int

    """limit results to N elements"""
    limit: Int
    filter: Person_Filter

    """order by the given fields"""
    orderBy: Person_Ordering
  ): [Person!]!
  name: String!
  id: ID!
}
```

You can then query this using the [GraphQL endpoint](https://terminusdb.com/docs/guides/reference-guides/graphql_query/connecting_to_graphql).

## We’ve got more planned

TerminusDB automatically generates fields in GraphQL based on classes and their properties in the data product schema. Here you can use arguments such as id, offset, limit, and order by, as well as filters such as time comparisons and for strings, and, or, not. All the filter options are also automatically generated for you.

We’re not stopping here though, we are working to integrate WOQL into GraphQL so that you can use GraphQL for complex path queries to make building graph-based applications even easier.

Our goal is to be the smoothest and most powerful GraphQL experience around.

We hope you join us on this journey.

## Other resources that you might like

[RDF & GraphQL Bridge using a Star Wars Dataset](https://terminusdb.com/blog/graphql-rdf-bridge-using-star-wars-dataset/)

[How we implemented GraphQL in 14 days](https://terminusdb.com/blog/implement-graphql-in-fourteen-days/)

[Tutorial – Build a blog-focused CMS with TerminusDB & GraphQL](https://github.com/terminusdb/terminusdb-tutorials/blob/master/terminusBlog)