Best practices for connecting to third party services

Hi,

I am new here. I think I could use DGraph for a current project that is in POC stage right now.

I have read through the docs and watched a few videos and also looked at lot of posts here but I am still confused about a couple of things.

First is that how best to connect to a third-party service? Lets say an emailing service or a Payment gateway?
Is writing Custom HTTP the way to go? BUt what if the services don’t provide a REST API? And I want to use a NodeJS client, should I run a separate server somewhere then and expose an API and then connect that API with Dgraph ?

Second question around this that I will need to keep the private keys secured so as to connect to third party services, is there a way to declare secrets that are only available on server runtime but not shown anywhere? If I go for managed dgraph (slash graphql) would you have the access to read my keys?

Is there an example somewhere that uses a e-mailing service or any other thirdparty service for that matter so that I can quickly get started on that?

thanks!

that what?

Yes, one way. The other way is gRPC and GraphQL(which is HTTP).

But what would they provide instead?

Dgraph has Dgraph-js and Dgraph-js-http - with those you can create any API with any(not all always) JS framework.

Not sure what you mean. Dgraph is just a DB. You will have to create your API with business logic. If you wanna an easy API without much effort, you can use the GraphQL feature.

This is out of Dgraph scope. But there are tools like HashiCorp Vault that cover this. And there are other approaches to do the same.

Well, Slash will provide just the DB. It won’t host your API. You will manage your API somewhere and connect to Slash. But pay attention that there are two ways of using Slash. One is with GraphQL in mind and the other with DQL. DQL is Dgraph’s query language, it has raw access to the DB. And for your case, DQL will be the chosen one as looks like you are not looking for GraphQL. Right?

Again, Slash will host your DB and on your end, you will deal with secrets, keys, and whatever. About your question, I don’t think we* have access to your DB. @gja could cover this.

No, Dgraph is just a DB. There’s no native way of connecting to such services. Unless it is something that I’m not aware of.

Cheers.

Hi @MichelDiz thank you for the detailed response.

So looks like I was thinking about Slash in a wrong way then. Based on the examples and the knowledge I have so far, I was thinking of just directly connecting Slash GraphQL to my frontend and not having any server in between. but looks like I do need one? Still a bit confused as the examples I see don’t seem to have a server which connect to DGraph.

BTW I am looking for GraphQL, the frontend can use Apollo Client.

That’s right. Slash was made for that. But the focus of Slash is GraphQL. Dgraph’s GraphQL feature is an automated GraphQL server. Based on your schema. But it is only for the GraphQL case. Not DQL.

If you gonna use DQL.

Okay, now we are talking :stuck_out_tongue: - It just works. BTW If you wanna some remote thing on your self-generated GraphQL server in Slash, you can add Lambda functions.

But even tho, Dgraph can’t connect to third-party applications out of the blue. We have some third-party applications support coming, things like Kafka. But it isn’t a universal thing(support any third-party application). Lambda can be a way out for you.

1 Like

You can use @lambda, eg in your schema:

type Mutation {
  sendEmail(to:String!) : Boolean! @lambda
} 

then use lambda server to send out your email (returning status as boolean in above case).

This is a good solution.