Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom Functions: Can't use _ in identifiers #5641

Closed
ardan-bkennedy opened this issue Jun 12, 2020 · 2 comments · Fixed by #6157
Closed

Custom Functions: Can't use _ in identifiers #5641

ardan-bkennedy opened this issue Jun 12, 2020 · 2 comments · Fixed by #6157
Labels
area/graphql Issues related to GraphQL support on Dgraph. kind/bug Something is broken. status/accepted We accept to investigate/work on it.

Comments

@ardan-bkennedy
Copy link

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
Copy link

Thanks for reporting this. GraphQL specs allow _ in variable naming. Hence it's a valid use case. https://spec.graphql.org/June2018/#sec-Names
Filing a bug.

@arijitAD arijitAD added area/graphql Issues related to GraphQL support on Dgraph. kind/bug Something is broken. status/accepted We accept to investigate/work on it. labels Jun 16, 2020
@minhaj-shakeel
Copy link
Contributor

Github issues have been deprecated.
This issue has been moved to discuss. You can follow the conversation there and also subscribe to updates by changing your notification preferences.

drawing

abhimanyusinghgaur added a commit that referenced this issue Aug 12, 2020
Fixes #5641
Fixes GRAPHQL-508
Fixes [Discuss Issue](https://discuss.dgraph.io/t/custom-mutation-underscores-within-post-body/8622)

This PR adds support for parsing hardcoded scalar values in `@custom` HTTP body.
This also adds support for allowing `_` in key names in the body template.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/graphql Issues related to GraphQL support on Dgraph. kind/bug Something is broken. status/accepted We accept to investigate/work on it.
Development

Successfully merging a pull request may close this issue.

3 participants