Custom Subscription Support

Can we expect custom subscription support?

1 Like

Hi Vishal,

Could you elaborate on what you mean by custom subscriptions?

Tejas

@gja, I think he means, if he adds a Custom query, can we add the @withSubscription onto that custom query and turn it into a subscription

1 Like

Exactly!

1 Like

This isn’t something that we are looking to add right now. Could you elaborate on a use case in which you would use this?

better filters to get realtime updates on the exact data we need according to business logic. As we know currently filter in GraphQL is very limited

1 Like

I would be also very interested in @custom subscriptions.
My use-case is the implementation of copy-mutations (which are currently not auto-generated).

type Progress @remote {
  current: Int!
  max: Int!
}
type Subscription {
   copyProject(projectId: String!, targetUser: UserRef): Progress!
    @custom(
      http: {
        url: "${GQL_URL}"
        method: POST
        graphql: "subscription($projectId: String!, $targetUser: UserRef) {copyResearchBox(projectId: $projectId, targetUser: $targetUser)}"
      }
    )
}

This subscription would take care of copying all childs and child-childs and notifiy the client about the progress. Besides copy this could also be useful for deletes (if cascading deletes will not be implemented).

The workaround I will implement now will involve adding a new Process-type to dgraph which is then set from my 2nd server and where the client can subscribe on updates.

Sounds like an interesting use case where you are trying to subscribe to updates for subscriptions from a remote GQL server. I was averse to the idea of supporting this because it can end up turning Dgraph into a proxy layer where it’s used to subscribe over HTTP URL’s from the web. Though based on this and Will we be able to subscribe to a query? it makes sense for certain use cases. We can look into supporting this in the next quarter. Marking this as accepted.

2 Likes

Hi!
Just wanted to add that while my workaround works for the above use-case (although inconvenient), I am currently having hard issues for other use-cases like getting real-time updates from sensor-data. So I just wanted to re-express my interest in this feature!