Programatically construct a DQL query with filters and functions

Using dgo package - github.com/dgraph-io/dgo/v210 - Go Packages

Can I programatically construct a DQL query with all filters, first, offset included?

Hey @droslean So you’re looking to build DQL queries using a library? dgo’s all about handling connection and transactions. Not much in there for building up the actual queries (most of the API functions expect string inputs).

Check out this go library: https://github.com/fenos/dqlx: “A DGraph Query Builder”

2 Likes

Is there any other library? I just want to check other options too. The fenos/dqlx is a nice one but it doesn’t have any dynamics. For example, the query has to be constructed manually including filters and so on.

What we do: have a look at Dgraph’s internal package gql, where you find a type GraphQuery which is the data type for a DQL. Writing a renderer for this type is quite trivial.

That package cannot be imported with dgo package at the project. Either way, it is really strange why there is no library that supports this, or why the package you mentioned is internal only.