Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

SGQL - Semantic Graph Query language

On Myne, each User has their own personal Semantic Graph.

This graph is composed of Nodes, linked by Relations, and is centered on a Me node that represents an identity of the user.

Anatomy of a query

An SGQL Query is composed of two stages:

  1. The meta stage, which is everything before the >
  2. The query stage, which is everything after the >

The Action keyword

The Action keyword can be one of the following:

What they do is pretty self-explanatory, but check their specificities in the subsections.

Nodes

Nodes SHOULD be title cased and singular.

Nodes MAY have properties, that can be defined with the IS keyword.

FIND > Movie IS:title 'The Matrix'

Relations

Relations SHOULD be title cased and singular.

Relations are directional.

They are defined using the keywords:

  • DID: Node –DID–> Node
  • BEEN: Node <–BEEN– Node

Relations MAY also have properties, that can be defined with the HAS keyword.

For example, if you write this:

WRITE > Me DID:Rate HAS:star '5' Movie IS:title 'The Matrix'

You can retrieve it like this:

FIND > Movie BEEN:Rate HAS:star '5' Me

Note that the position of the Me keyword doesn’t matter, as long as it is after the relation, or it can be omitted altogether.

These are equivalent to the previous query:

FIND > Movie BEEN:Rate Me HAS:star '5'
FIND > Movie BEEN:Rate HAS:star '5'

Values

As you may have noticed, values MUST be surrounded by single quotes '', even for numbers.

Templated Queries

In App Manifests, actions use SGQL queries where values can contain variables.

They are defined like so '%variableName%'.

Operators (AND / OR)

By default, queries use the AND operator, so that you can define multiple relations conditions.

FIND > Movie BEEN:Rate HAS:star '5' HAS:year '2002'

But if you wanted to find movies that you liked in 2021 or 2022:

FIND > Movie BEEN:Like Me HAS:year '2021' OR( HAS:year '2022' )

Mind that its OR(_ (with the open parenthesis and space after) and closed by _) (with a space before).

You can also define another relation in the OR query:

FIND > Person DID:Watch Movie IS:title 'Star Wars' OR( DID:Watch Movie IS:title 'The Matrix' )

Output of a query

If the query is valid, the output of a query is a JSON of the form:

{
  "nodes": [],
  "relations": []
}

The type of the nodes returned is the leftmost node name, that is the one right after the >.

Specific typings for the query response are defined in each SDK documentation in the “Resources” section of this documentation.