Q: Golang - Query for references

Description

Hey there

I am trying to query Weaviate from a Golang program.
My dataset has a reference, where “A” has a ref “hasB” to “B”.
If I query it via the console directly it works fine with results, e.g.

  Get {
    A {
      title
      hasB {
        ... on B {
          text
        }
      }
    }
  }
}

But if I try to add “hasB” to the fields list in Go to query, it plain fails with no results.

fields := []graphql.Field{
		{Name: "title"},
		{Name: "hasB", Fields: []graphql.Field{
			{Name: "text"},
		}},
	}
...
results, err := this.weaviate.Client.GraphQL().Get().
		WithClassName(schema).
		WithFields(fields...).
		WithNearText(nearText).
		WithLimit(limit).
		Do(context.Background())

Is there something missing? How would you query for results with references in Go?
Here Cross-references | Weaviate - Vector Database are Python examples, but no other.

Thanks for any pointing in the right direction already

Server Setup Information

  • Weaviate Server Version: latest
  • Deployment Method: docker
  • Multi Node? Number of Running Nodes: 1
  • Client Language and Version: Go, 1.22.3
  • Multitenancy?: No

Ok, found it myself ^^’

Really have to inline the graphQl, not just the names

{Name: "hasB", Fields: []graphql.Field{
			{Name: "... on B", Fields: []graphql.Field{
				{Name: "text"},
			}},
		}},

Works now.

Thanks