Table of documentation contents

GraphQL references

GraphQL references overview

All references

All references have their individual subpages, click on one of the references below for more information.

GraphQL

Weaviate’s basic query language is GraphQL. GraphQL is a query language built on using graph data structures. It is an efficient method of data retrieval and mutation, since it mitigates the common over-fetching and under-fetching problems of other query languages. You can query a Weaviate after you’ve created a schema and populated it with data. The GraphQL interface inside the Weaviate Console GUI enables easy querying.

Query structure

You can query Weaviate for semantic kinds based on standard GraphQL queries. The examples below only contain the GraphQL query. You can POST a GraphQL query to Weaviate as follows:

$ curl http://localhost/v1/graphql -X POST -H 'Content-type: application/json' -d '{GraphQL query}'

A GraphQL JSON object is defined as:

{
    "query": "{ # GRAPHQL QUERY }"
}

GraphQL queries follows a defined structure, defined to interact with your data in Weaviate as good as possible. Queries are structured as follows:

{
  <Function> {
    <SemanticKind> {
      <Class> {
        <property>
        _<underscore-property>
      }
    }
  }
}
  • There are three functions currently defined in Weaviate’s GraphQL: Get{}, Aggregate{} and Explore{}. Get{} functions are used to easily retrieve data from your Weaviate instance, while Aggregate{} is used to obtain meta information about data objects and its properties. With Explore{} you can browse through the data to with semantic search, and a slightly different query structure than above is used (there is no <SemanticKind> and <className> defined, since you are searching in a fuzzy way):
{
  Explore (<search arguments>) {
      beacon
      certainty
      className
  }
}
  • SemanticKind in a GraphQL query should always be Things or Actions, it is the semantic kind you want to retrieve from Weaviate.
  • Class is the name of the class you want to fetch, defined in the schema.
  • With including a property (lowercase) list in the query, you specify exactly which property values you want to return. If the property is a reference to another object (beacon), then use the following structure:
{
  <Function> {
    <SematicKind> {
      <Class> {
        <property>
        _<underscore-property>
        <PropertyWithReference>
          ... on <ClassOfBeacon> {
            <property>
            _<underscore-property>
          }
      }
    }
  }
}
  • To obtain meta information about a data object (for example for interpretation or visualization purposes), use the _underscore-property.

More Resources

If you can’t find the answer to your question here, please look at the:

  1. Frequently Asked Questions. Or,
  2. Knowledge base of old issues. Or,
  3. For questions: Stackoverflow. Or,
  4. For issues: Github. Or,
  5. Ask your question in the Slack channel: Slack.
Tags
  • GraphQL references