Best practice for NodeJS client development?

I’m trying do develope a VUE JS app, and would like to use DGraph for my data. In earlier projects I used NEO4J and Express/Apollo for communication between my client and the NEO4J database.

I tried to use the dgraph-js/grpc library directly in VUE, but get errors indicating that my code doing DGraph stuff should run in another environment (not the web-browser).

I suspect that I have to establish a nodejs server component using e.g. Express, and then have my client communicate with the Express server, and then have the Express server communicate with the DGraph server.

Is there any best practices on how to develop a SPA using Vue, Angular, React etc. and DGraph as datastore.
I’m considering to use the express server as a route, accepting my graphql+ queries and just push them forward to the DGraph server, and the same with the response… Is there any reason for why I should avoid such an approach?

If there is an example available on github, that could point me in the correct direction that would be most appreciated.

Any guidance on how to best communicate between a SPA client and a DGraph server is most welcome.
If this request should have been posted in a different forum or thread, please accept my apologies…

1 Like

We have this example here GitHub - dgraph-io/graphoverflow: Run the entire StackOverflow on Dgraph. Work in progress.

It would be safer for you to create an API with Express and not link your project directly to Dgraph. Creating a NodeJS server (as API/REST) would be more interesting for better control of what is being inserted.

You could also create a GraphQL server GitHub - dpeek/dgraphql: DgraphQL: Build a GraphQL service from a schema


I am building a app with DGraph, (micro / express & apollo), and Angular on AWS with Lambda all in typescript. So if you have any specific questions I can try to help out, or if you find any best practices elsewhere online I would be keen to hear about them.

I came to the same conclusion as @MichelDiz that you really want some GraphQL layer in front of your DGraph db.


  • You can connect GraphQL to multiple database
  • Some actions may require other services - I email uses on some actions.
  • Validating inputs
  • Protecting your db from malicious actors - Maybe the most important one

That said often I find myself writing the same query and just piping it through to DGraph, I feel like the eventual solution here is to use something like this:

So you can get a list of the graphql query fields and pipe them trough to a specific DGraph query.

Great - thanks.
I have now a working VUEJS app working that used the dgraph-http-js library that talks directly with the dgraph database.
I have used the graphQL apollo library and used that to talk to NEO4J, where I “replace” all graphql queries with CYPHER queries. I quess I could the similar with DGRAPH, where I have my graphQL query in the client, and do a graphQL+ in the express server.

I agree that the best would be to have a separate express “server” that sits between my VUE client and the DGRAPH server. To get better security until DGRAPH have authentication and ACL implemented.

I will post a simple demo on GitHUb when I have this sorted out :slight_smile:


@erlendoverby Interested to learn if you got this working and maybe you’d be willing to share what code you have. Now that dgraph has native GraphQL, might be a good starting place.

1 Like