best practices for querying a resource

18 views
Skip to first unread message

tyty

unread,
Mar 18, 2022, 6:23:35 PM3/18/22
to Protocol Buffers
I have a resource called Resturants. There are multiple fields and a few i want to allow people to query specifically for (Rating and Location). 

Is it better to create multiple RPC endpoints like:

```
//all resturants
QueryReseturants(QueryResturantsRequest) returns (QueryResturantsResponse)

// all resturants with a specific rating
QueryResturantsByRating(QueryResturantsByRatingRequest) returns (QueryResturantsByRatingResponse)

// all resturants with a specific locatoin
QueryResturantsByLocation(QueryResturantsByLocationRequest) returns (QueryResturantsByLocationResponse)
```

OR is it better to have one query, with the specifics as fields:

```
//all resturants
QueryReseturants(QueryResturantsRequest) returns (QueryResturantsResponse)
```
where QueryResturantsRequest contains a Rating and Location field. Specifying neither will return all. or you can specify one or both of the fields to narrow down the resturants returned.

Either way works for our use case, but I'm mainly curious if this breaks protobuf standards or something like that.

Thanks.

Deanna Garcia

unread,
May 2, 2022, 2:49:38 PM5/2/22
to Protocol Buffers
I think this question is more suited for gRPC, protobuf doesn't have standards about RPC endpoints.
Reply all
Reply to author
Forward
0 new messages