# Custom Subscription Support

**URL:** <https://discuss.dgraph.io/t/custom-subscription-support/9437>\
**Category:** GraphQL\
**Tags:** status:accepted, ticket:created, community\
**Created:** [August 13, 2020, 5:40pm UTC](https://discuss.dgraph.io/t/custom-subscription-support/9437 "2020-08-13T17:40:37Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![vishalaf](https://avatars.discourse-cdn.com/v4/letter/v/9fc348/32.png) [@vishalaf](https://discuss.dgraph.io/u/vishalaf)\
**Post date:** [August 13, 2020, 5:40pm UTC](https://discuss.dgraph.io/t/custom-subscription-support/9437/1 "2020-08-13T17:40:37Z")

</div>

Can we expect custom subscription support?

---

<div class="post-metadata">

**Author:** ![gja](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/gja/32/2654_2.png) [@gja](https://discuss.dgraph.io/u/gja)\
**Post date:** [August 13, 2020, 5:41pm UTC](https://discuss.dgraph.io/t/custom-subscription-support/9437/2 "2020-08-13T17:41:11Z")

</div>

Hi Vishal,

Could you elaborate on what you mean by custom subscriptions?

Tejas

---

<div class="post-metadata">

**Author:** ![amaster507](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/amaster507/32/4123_2.png) [@amaster507](https://discuss.dgraph.io/u/amaster507)\
**Post date:** [August 13, 2020, 5:43pm UTC](https://discuss.dgraph.io/t/custom-subscription-support/9437/3 "2020-08-13T17:43:30Z")

</div>

@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

---

<div class="post-metadata">

**Author:** ![vishalaf](https://avatars.discourse-cdn.com/v4/letter/v/9fc348/32.png) [@vishalaf](https://discuss.dgraph.io/u/vishalaf)\
**Post date:** [August 13, 2020, 5:44pm UTC](https://discuss.dgraph.io/t/custom-subscription-support/9437/4 "2020-08-13T17:44:04Z")

</div>

Exactly!

---

<div class="post-metadata">

**Author:** ![pawan](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/pawan/32/1946_2.png) [@pawan](https://discuss.dgraph.io/u/pawan)\
**Post date:** [August 14, 2020, 8:55am UTC](https://discuss.dgraph.io/t/custom-subscription-support/9437/6 "2020-08-14T08:55:02Z")

</div>

> [@vishalaf](#):
>
> Can we expect custom subscription support?

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?

---

<div class="post-metadata">

**Author:** ![yodaheis](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/yodaheis/32/4321_2.png) [@yodaheis](https://discuss.dgraph.io/u/yodaheis)\
**Post date:** [September 11, 2020, 7:40am UTC](https://discuss.dgraph.io/t/custom-subscription-support/9437/7 "2020-09-11T07:40:05Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![maaft](https://avatars.discourse-cdn.com/v4/letter/m/4af34b/32.png) [@maaft](https://discuss.dgraph.io/u/maaft)\
**Post date:** [November 8, 2020, 1:25pm UTC](https://discuss.dgraph.io/t/custom-subscription-support/9437/8 "2020-11-08T13:25:45Z")

</div>

> [@pawan](#):
>
> 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?

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

```auto
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.

---

<div class="post-metadata">

**Author:** ![pawan](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/pawan/32/1946_2.png) [@pawan](https://discuss.dgraph.io/u/pawan)\
**Post date:** [November 10, 2020, 6:49am UTC](https://discuss.dgraph.io/t/custom-subscription-support/9437/9 "2020-11-10T06:49:26Z")

</div>

> [@maaft](#):
>
> ```auto
> 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)}"
> }
> )
> }
> 
> ```

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?](http://discuss.hypermode.com/t/will-we-be-able-to-subscribe-to-a-query/11382) it makes sense for certain use cases. We can look into supporting this in the next quarter. Marking this as accepted.

---

<div class="post-metadata">

**Author:** ![maaft](https://avatars.discourse-cdn.com/v4/letter/m/4af34b/32.png) [@maaft](https://discuss.dgraph.io/u/maaft)\
**Post date:** [November 17, 2020, 8:49am UTC](https://discuss.dgraph.io/t/custom-subscription-support/9437/11 "2020-11-17T08:49:38Z")

</div>

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!
