# Arguments on custom fields

**URL:** <https://discuss.dgraph.io/t/arguments-on-custom-fields/10823>\
**Category:** GraphQL\
**Tags:** kind:question, status:accepted, ticket:created\
**Created:** [October 7, 2020, 10:34am UTC](https://discuss.dgraph.io/t/arguments-on-custom-fields/10823 "2020-10-07T10:34:01Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![stormking](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/stormking/32/5047_2.png) [@stormking](https://discuss.dgraph.io/u/stormking)\
**Post date:** [October 7, 2020, 10:34am UTC](https://discuss.dgraph.io/t/arguments-on-custom-fields/10823/1 "2020-10-07T10:34:01Z")

</div>

Hi,

Since [graphql: Allow user to define and pass arguments to fields. by pawanrawal · Pull Request #5562 · dgraph-io/dgraph · GitHub](https://github.com/dgraph-io/dgraph/pull/5562) was merged back in June, I was under the impression that arguments to custom fields were supported in master. So I ran dgraph/dgraph:master from Docker Hub and tried to add the following GraphQL schema:

```auto
type TSVal @remote {
    timestamp: String! @id
    value: Int
}
 
type Timeseries {
    id: String! @id
    values(from: DateTime!, till: DateTime!): [TSVal] @custom(http: {
        url: "http://localhost:5000/timeseries?from=$from&till=$till"
        method: GET
    })
}

```

I got the following error message:

```auto
{"errors":[{"message":"resolving updateGQLSchema failed because input:9: Type Timeseries; Field values; url query inside @custom directive uses a field from that is not defined.\ninput:9: Type Timeseries; Field values; url query inside @custom directive uses a field till that is not defined.\n (Locations: [{Line: 3, Column: 4}])","extensions":{"code":"Error"}}]}

```

So my question is: Is this change supposed to be in the Docker container? Am I using this wrong?

Best regards,  
Marcus

---

<div class="post-metadata">

**Author:** ![stormking](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/stormking/32/5047_2.png) [@stormking](https://discuss.dgraph.io/u/stormking)\
**Post date:** [October 7, 2020, 10:36am UTC](https://discuss.dgraph.io/t/arguments-on-custom-fields/10823/2 "2020-10-07T10:36:04Z")

</div>

If I add a custom query, it works as expected:

```auto
type Query {
    customTS(id: String!, from: DateTime, till: DateTime): [TSVal] @custom(http: {
        url: "http://localhost:5000/timeseries?from=$from&till=$till"
        method: GET
    }) 
}

```

---

<div class="post-metadata">

**Author:** ![aman-bansal](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/aman-bansal/32/4475_2.png) [@aman-bansal](https://discuss.dgraph.io/u/aman-bansal)\
**Post date:** [October 7, 2020, 5:10pm UTC](https://discuss.dgraph.io/t/arguments-on-custom-fields/10823/3 "2020-10-07T17:10:46Z")

</div>

Hi @stormking, I believe what you are doing wrong is with adding arguments to value and using it with the URL. Currently, to resolve params in URL dgraph uses fields in the type. You can read more about that [here](https://dgraph.io/docs/graphql/custom/directive#how-custom-fields-are-resolved).

Its actually in our [roadmap](https://dgraph.io/docs/graphql/custom/directive#restrictions--roadmap) to add arguments in custom fields.

So having the schema like this will work

```auto
type TSVal @remote {
    timestamp: String! @id
    value: Int
}
 
type Timeseries {
    id: String! @id
    from: DateTime!
    till: DateTime!
    values: [TSVal] @custom(http: {
        url: "http://localhost:5000/timeseries?from=$from&till=$till"
        method: GET
    })
}

```

can you please help with your use case so that we can help you with the solution.

---

<div class="post-metadata">

**Author:** ![stormking](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/stormking/32/5047_2.png) [@stormking](https://discuss.dgraph.io/u/stormking)\
**Post date:** [October 7, 2020, 6:02pm UTC](https://discuss.dgraph.io/t/arguments-on-custom-fields/10823/4 "2020-10-07T18:02:33Z")

</div>

Hi Aman,

I know it’s on the roadmap, I just thought the commit I referenced in my initial post meant that it was already available in master. Seems I was wrong, there. Any idea when that feature will be available?

Thanks for the workaround, I came up with pretty much the same thing in the meantime, but for my usecase, the custom query is more suitable.

Thanks again, and keep up the good work! In the past, I dealt with JanusGraph and Cassandra and in comparison, Dgraph is just amazing!

Best regard,  
Marcus

---

<div class="post-metadata">

**Author:** ![stormking](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/stormking/32/5047_2.png) [@stormking](https://discuss.dgraph.io/u/stormking)\
**Post date:** [October 7, 2020, 6:11pm UTC](https://discuss.dgraph.io/t/arguments-on-custom-fields/10823/5 "2020-10-07T18:11:50Z")

</div>

Oh, and my usecase is to link Dgraph with InfluxDB to have an universal datastore. Structured data will be held in the graph, timeseries mass-data will be forwarded to Influx. So I really need to specify “from” and “till” dynamically in my queries.

Ideally, I would query data like this:

```auto
query {
  getMachine(machineID: "someIdentifier") {
    timeseries {
      values(from: "2020-10-07T18:00:00Z", till: "2020-10-07T18:30:00Z") {
        timestamp
        value
      }
    }
  }
}

```

And then get the data for all timeseries linked to the “Machine” vertex for the requested timeframe.

For now, I will workaround the issue by splitting the query, getting the Timeseries’ id first and then using the custom query to get the data for the requested timeframe.

---

<div class="post-metadata">

**Author:** ![aman-bansal](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/aman-bansal/32/4475_2.png) [@aman-bansal](https://discuss.dgraph.io/u/aman-bansal)\
**Post date:** [October 11, 2020, 11:30am UTC](https://discuss.dgraph.io/t/arguments-on-custom-fields/10823/6 "2020-10-11T11:30:54Z")

</div>

Hi @stormking, your use case looks really exciting. We would love to learn more about your journey of integrating Influxdb with Dgraph.

@pawan do we have any timeline for this?

---

<div class="post-metadata">

**Author:** ![stormking](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/stormking/32/5047_2.png) [@stormking](https://discuss.dgraph.io/u/stormking)\
**Post date:** [February 26, 2021, 8:57am UTC](https://discuss.dgraph.io/t/arguments-on-custom-fields/10823/7 "2021-02-26T08:57:21Z")

</div>

Hi Aman,

Any news on this issue?

---

<div class="post-metadata">

**Author:** ![stormking](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/stormking/32/5047_2.png) [@stormking](https://discuss.dgraph.io/u/stormking)\
**Post date:** [March 20, 2021, 11:21pm UTC](https://discuss.dgraph.io/t/arguments-on-custom-fields/10823/8 "2021-03-20T23:21:34Z")

</div>

It would be really great to know if you at least consider this. You’ve already updated your schema parser to allow that kind of definition. Now all you have to do is to pass these arguments to the REST or GraphQL call that is made. The hard part is already done! It would make @remote types so much more powerful!

I really don’t understand why there is so much silence in such a no-brainer!

Best regards,  
Marcus

---

<div class="post-metadata">

**Author:** ![abhimanyusinghgaur](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/abhimanyusinghgaur/32/2980_2.png) [@abhimanyusinghgaur](https://discuss.dgraph.io/u/abhimanyusinghgaur)\
**Post date:** [March 22, 2021, 7:33am UTC](https://discuss.dgraph.io/t/arguments-on-custom-fields/10823/9 "2021-03-22T07:33:35Z")

</div>

Hi @stormking,

Really sorry that we missed this.  
We will surely consider this, and plan to have it as part of the 21.07 release.

Thanks

---

<div class="post-metadata">

**Author:** ![stormking](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/stormking/32/5047_2.png) [@stormking](https://discuss.dgraph.io/u/stormking)\
**Post date:** [March 23, 2021, 11:44pm UTC](https://discuss.dgraph.io/t/arguments-on-custom-fields/10823/10 "2021-03-23T23:44:05Z")

</div>

Hi abhimanyusinghgaur,

Thanks for your feedback. I hope you acknowledge that getting no feedback at all is worse than getting a “no”. So thanks you for your answer and I really hope this gets implemented. Currently, I’m betting my career on Dgraph because I see the potential and you should see that, too! The support of “remote types” is a major competetive factor, if you expand on that Unique Selling Point, you will certainly succeed as a company!

Best regards,  
Marcus

---

<div class="post-metadata">

**Author:** ![mrjn](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/mrjn/32/775_2.png) [@mrjn](https://discuss.dgraph.io/u/mrjn)\
**Post date:** [March 24, 2021, 6:04am UTC](https://discuss.dgraph.io/t/arguments-on-custom-fields/10823/11 "2021-03-24T06:04:24Z")

</div>

@hardik please track this.

Sorry for the silence here. That’s not the kind of experience we want to create for our users.

---

<div class="post-metadata">

**Author:** ![jerber](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/jerber/32/8920_2.png) [@jerber](https://discuss.dgraph.io/u/jerber)\
**Post date:** [October 31, 2021, 9:03pm UTC](https://discuss.dgraph.io/t/arguments-on-custom-fields/10823/13 "2021-10-31T21:03:52Z")

</div>

Hi @abhimanyusinghgaur and @mrjn, is this still on track to be in the next release? Allowing arguments on custom fields would be huge for us as we transition our production db from Firestore!
