Using Dgraph in a Golang server running a GraphQL endpoint

Hello all,

At work, we are planning to switch from PostgresSQL to another DB solution (MongoDB has been on our radar lately). After some research, I discovered Dgraph and really liked the idea of having a Graph database as our primary storage solution. However, I have no idea on how to cleanly use Dgraph behind a Go server running GraphQL. Doing the translation GraphQL <–> GraphQL+ does not seem feasible. Even using the native GraphQL implementation of Dgraph does not seem like a solution as we do not want the clients to interface directly with Dgraph.

I saw some similar posts back in 2018 and 2017 but we have now entered 2020 and I want to know if anyone found a way to make the connection Dgraph <–> Golang <–> GraphQL.

Thank you :slight_smile:

Hey @Mikeal

Using the native GraphQL implementation would be the recommended solution as long as the generated APIs fulfill your needs. If the GraphQL API had authentication/authorization built in to it, would that be good enough for your use case or is there something else that you’d require to be able to use it?

Thank you for your reply @pawan.

Having built-in authentication/authorization in the GraphQL API would make it too opinionated in my opinion. What we need is the ability to plug in with our in-house authentication/authorization solution. Moreover, we need to apply custom logic in the GraphQL resolvers to fetch data from our APIs or perform custom validation and verification for example.

Personally, I have a discomfort exposing Dgraph Alphas’ directly to the client. Having one or more Go services in the middle is my preferred approach.

I know technically this is very challenging due to the limited spec of GraphQL but is there any provisioning to cater for the above?

Lots of other users have also asked for the ability to apply custom logic to GraphQL resolvers and we are looking into what’s the best way to provide it. We’ll have something for you soon.

1 Like

Hi @Mikeal ,
We are trying to do exactly the same as you :wink:
I have opened a thread as well but didn t get much of a solution up to now , there :

Keep me posted if you found a way to do this.

@pawan thanks for keeping up posted. sorry if my question was redundant but it’s a very needed solution.

@hubyhuby Hi, yes, I’m waiting impatiently too :slight_smile:

Try Hasura with DGraph as an external GraphQL schema for a very soft migration on your terms.

I have the issue that I need unified GraphQL access to both, relational and graph data because certain parts of my data cannot be represented efficiently in a graph.

Hasura does just that, plus a few more bits.

Hi @pawan, @Mikeal

Are you thinking of using vektah/gqlparser for this purpose ?
We are thinking of using it but couldn t find a documentation , nor comprehensive examples to understand the parser …

Any help would be greatly appreciated , since we are pretty stucked in our project with dgraph + GO Api :frowning:

I have seen that it has been forked by Dgraph here too …