Custom Functions: Can't use `_` in identifiers

Moved from GitHub dgraph/5641

Posted by ardan-bkennedy:

What version of Dgraph are you using?

master

Have you tried reproducing the issue with the latest release?

Only on master

What is the hardware spec (RAM, OS)?

Mac with latest OS

Steps to reproduce the issue (command/config used to run Dgraph).

I have to define function parameters and field names in the body like this.

type Query{
	uploadFeed(countryCode: String!, cityName: String!, lat: Float!, lng: Float!): UploadFeedResponse @custom(http:{
		url: "{{.UploadFeedURL}}",
		method: "POST",
		body: "{countrycode: $countryCode, cityname: $cityName, lat: $lat, lng: $lng}"
	})
}

If I attempt to use an underscore _ I get an error. As an example, renamingcountryCode to country_code:

type Query{
	uploadFeed(country_code: String!, cityName: String!, lat: Float!, lng: Float!): UploadFeedResponse @custom(http:{
		url: "{{.UploadFeedURL}}",
		method: "POST",
		body: "{countrycode: $countryCode, cityname: $cityName, lat: $lat, lng: $lng}"
	})
}

I get this error.

Type Query; Field uploadFeed; body template inside @custom directive could not be parsed.

This would also happen if I use underscores for fields in the body document.

Expected behaviour and actual result.

I expect I can use JSON proper variable naming.

arijitAD commented :

Thanks for reporting this. GraphQL specs allow _ in variable naming. Hence it’s a valid use case. GraphQL
Filing a bug.