Can dgraph store and query on untyped map data?

Hello, I am just getting started and have a question.

I am looking to use Dgraph for asset management. Most of the data would be consistently typed, but some would not, because I support each user setting custom annotations.

This map can vary user to user, or even within the same user:

// User 1 annotates items this way
  "value": 5

// User 2 uses it differently
  "value": "different type",

  "company name": {
    "external id": 3,
    "purchased by": "Sam"

Right now, we handle this using MySQL’s JSON type. It is important that I can efficiently query on this untyped data. How would I support this with Dgraph?

Thank you for your time.

You can use Facets it is untyped. But you can’t query it directly. First you query the object and then, in the query body, query the facets.

It looks to me like I would have to transform the user’s map into a set of key-value pairs, is that right? For the second example, something like:

(value=different type, company-name.external-id=3, company-name.purchased-by=Sam)

I am not yet certain that could handle my use case, as the annotations can be pretty complicated. For example, from the docs it looks like facets do not support arrays.

Facet keys are strings and values can be string, bool, int, float and dateTime

One other question. I was reading from this blog post: which specifies:

When not to use GraphQL:

When wanting to use Dgraph in a schemaless manner such as ingesting inconsistently typed data objects.

I was wondering if that means that if I commit to using DQL I have more options here? Or did I misunderstand what that means.

There’s no array type in Dgraph, there is list type. It is similar, but not the same thing.

GraphQL Spec is a bit limited, for example, there’s no concept of Facets there. But DQL and GraphQL are similar, they can work together.