Suggestion on adding new query and mutations on top of default scehma

As dgraph already is Graphql I want to have custom queries and mutation for 3rd party endpoint.
like login to third party services have data in our dgraph. Kinda hybrid approach so that only the queries and mutation for 3rd party will have extra layer of graphql other data will directly be fetched and responded from dgraph.

For ex I need mutation on salesforce login and do fetch data and dump it to dgraph and than deliver it to client. It’s because I may need to sync back some data to salesforce at some point.

Any suggestion?

Have you looked at custom resolvers?

Yes but still had a question on third party auth using custom resolvers. Do you think I will need middlelayer for that or just making custom resolvers in schema it self should work?

Using Auth0 like service, we can have hooks/rules that trigger queries or mutations pre/post-login.
I think custom resolvers will be sufficient. Not very sure though, @abhimanyusinghgaur do you know if this would work?
Also, @dgandhi17, can you please elaborate on your use case?

Third party service data fetch using custom resolvers and than insert those data in dgraph. Also need to post data to third party service from querying dgraph

1 Like

Hi @dgandhi17
Dgraph is not a process orchestration engine, so if the sync process between salesforce and dgraph has several steps + error handling, you should consider a middleware or at least some kind of microservice.

However, Dgraph can support orchestration needs elegantly. I have posted this video where a series of process steps are executed in a master data management context. This might be a helpful design pattern, hence sharing this.

do you have any github link for this demo, It will help to get an idea on design of middleware.

I don’t yet have this on GitHub; I will check on that and message you.

Hi @dgandhi17 , I have messaged you the location of the repo. I will be working on moving this into a suitable example on dgraph in parallel.


The MDM with graphql codebase is at the above repo.

@anand can you tell me how to add custom mutation in dql ? dgraph language like below

type Mutation {
   connectWithThirdParty(email: String, token: String): User @custom(http:{
        url: "http://localhost:5050/data"
        method: "POST",
        body: "{ title: $email, name: $token }" 
    })
}

I tried to this to dgraph schema in ratel but didn’t work

Ratel only accepts DQL, not GraphQL. You will need something like Postman or GraphiQL to query Dgraph using GraphQL.

But without this schema in ratel how can i query it from client ? I tried with graphql schema it works but as my schema is in ratel I need option for this

Hi @dgandhi17, the custom mutation is a graphql feature. It is not available in DQL, and Ratel. Hope this clarifies.