Few case in points →
Each field must be marked with a type, this can either be simple ones (string, int, etc.) or a uid or an array of the simple types.
I’d suggest the following schema for you
type A {
field1
}
field1: string .
type B {
field2
hasConnectionTo
}
field2: string .
hasConnectionTo: [uid] @reverse .
and accordingly the test rdf would be:
<_:A_1> <dgraph.type> "A" .
<_:A_1> <field1> "value1" .
<_:A_2> <dgraph.type> "A" .
<_:A_2> <field1> "value2" .
<_:B_1> <dgraph.type> "B" .
<_:B_1> <field2> "aaaaaaaaaaaa" .
<_:B_1> <hasConnectionTo> <_:A_1> .
now you can run something as follows:
{
getField2(func: has(field2)){
hasConnectionTo{
expand(_all_)
}
~hasConnectionTo{
expand(_all_)
}
}
}
While this makes sense for now, you might want to separate out into types based selection and filter predicates in the future