How to write simple query?

I’m brand new to DGraph and failing to figure out how to execute the simplest of queries. all I want to do is browse the data a little, something I could do with the likes of an SQL query like select top 10 * from <dgraph>

I’m running the Ratel dashboard and have tried entering the following queries, all of which fail:

q() {
  _predicate_
}

while lexing q() { predicate }: Invalid operation type: q

query q() {
  _predicate_
}

Invalid comma in var block

query q {
  _predicate_
}

Expected Left round brackets. Got: lex.Item [7] “}”

q(func: has(name)) {
  _predicate_
}

Unexpected item in place of variable. Got: lex.Item [9] “func” false

query q(func: has(name)) {
  _predicate_
}

while lexing q(func: has(name)) { predicate }: Invalid operation type: q

I’ve googled till I’m blue in the face and I can’t find anyone out there discussing the first thing about dgraph. I’ve asked in the Slack group but it’s totally silent. and the documentation does not make it clear in the least. I find no cookbooks. how am I supposed to get up to speed with this?

Addendum I

well, to start it needs the bloody braces around the query, so this works:

{
   q(func: has(name)) {
       _predicate_
   }
}

but how do I ask for all nodes/records without filtering? I tried:

{
   q() {
       _predicate_
   }
}

and

{
   q {
       _predicate_
   }
}

but neither work. also, how do I just bring the attributes back instead of the names of the attributes, which is what predicate does?

1 Like

You can get the attributes back like this.

{
   q(func: has(name)) {
       expand(_all_)
   }
}

That is not possible, you must use a function at root to get a starting set of nodes.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.