How to Use gqlgen for GraphQL in Go

Web
Execute Weaviate GraphQL queries in Go by chaining builder methods on the client instance.

Use the graphql package from weaviate-go-client to construct queries via a fluent builder pattern. Initialize the client, then chain methods like Get(), WithNearVector(), and Do() to execute the query.

import (
	"github.com/weaviate/weaviate-go-client/v4/weaviate"
	"github.com/weaviate/weaviate-go-client/v4/weaviate/graphql"
)

// Assuming wvClient is initialized and vector is available
result, err := wvClient.GraphQL().Get().
	WithNearVector(graphql.NearVectorArgBuilder().WithVector(vector)).
	WithClassName("Document").
	WithFields(graphql.Field{Name: "text"}).
	WithLimit(3).
	Do(ctx)