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

json 1.1 api support for grpc-ecosystem to use queryparams with filter #938

Closed
gauravkasliwal8 opened this issue May 17, 2019 · 10 comments
Closed

Comments

@gauravkasliwal8
Copy link

gauravkasliwal8 commented May 17, 2019

Support this alternative query parameter method.

@gauravkasliwal8
Copy link
Author

This works : https://myserver.com?filter[name]=test
This does not work https://myserver.com?filter[name][startsWith]=te
When I try to populate query parameters.

@gauravkasliwal8 gauravkasliwal8 changed the title json 1.1 api support : I am trying to write get api supporting json 1.1 standards. I am able to write GET api as below : filter[name]=test but not this : filter[name][startsWith]=te as PopulateQueryParameters function does not support this. I would really appreciate any help supporting this. Source : https://jsonapi.org/format/1.1/#query-parameters-families json 1.1 api support grpc-ecosystem for queryparams May 17, 2019
@gauravkasliwal8
Copy link
Author

I am trying to write get api supporting json 1.1 standards. I am able to write GET api as below : filter[name]=test but not this : filter[name][startsWith]=te as PopulateQueryParameters function does not support this. I would really appreciate any help supporting this. Source : https://jsonapi.org/format/1.1/#query-parameters-families

@gauravkasliwal8 gauravkasliwal8 changed the title json 1.1 api support grpc-ecosystem for queryparams json 1.1 api support for grpc-ecosystem to use queryparams May 17, 2019
@gauravkasliwal8 gauravkasliwal8 changed the title json 1.1 api support for grpc-ecosystem to use queryparams json 1.1 api support for grpc-ecosystem to use queryparams with filter May 17, 2019
@johanbrandhorst
Copy link
Collaborator

The gRPC gateway does not support this standard for query parameters, as you can tell. We support normal dot-separated query parameters at this time which should support your data format already.

If you'd like to, I'd be happy to help you in adding support for this alternative query parameter format. I do not personally have the time to do so though.

Let me know how you wish to proceed.

@gauravkasliwal8
Copy link
Author

Hi @johanbrandhorst,

Thank you for your reply. Could you please give me example for normal dot-separated query parameters to support my data format? I will try that.

@johanbrandhorst
Copy link
Collaborator

What does your proto message type look like? AFAIK you can't do nested maps with proto, so I don't understand what you're doing.

@johanbrandhorst
Copy link
Collaborator

A good source of inspiration for your query parameters are the tests: https://github.com/grpc-ecosystem/grpc-gateway/blob/master/runtime/query_test.go. You can see the use of maps and nested messages.

@gauravkasliwal8
Copy link
Author

Hi @johanbrandhorst,

My current proto definition is : map<string, string> filter
and it works with filter[x]=y.

I am looking for how to support JSON 1.1 API standards and change my proto where filter[x][y]=z is also allowed.

@johanbrandhorst
Copy link
Collaborator

What does filter[x][y]=z mean? Assign z to both key x and key y? The grpc-gateway does not support this standard (yet?) so you need to explain what you're trying to do.

@gauravkasliwal8
Copy link
Author

@johanbrandhorst

by filter[x][y]=z I mean

say filter[name][startsWith]=ab
filter[age][gte]=10
(gte = greater than equal)
filter[key][operator]=value

@johanbrandhorst
Copy link
Collaborator

Ah I see. This isn't really possible to auto translate with a gRPC server backend. You'd have to handle that manually. I don't think this is really feasible from the gateway so I'm going to close this. If you have an idea for how to add support for this please reply and I can reopen it.

Something like filter.field=age&filter.operator=GTE&filter.comparator=10 might work but you have to define the whole structure in your proto message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants