msgraph-sdk-ruby
msgraph-sdk-ruby copied to clipboard
Add ability to sort and filter
I'm a true beginner at Ruby RoR and for my internship I decided to use this gem over the Microsoft Graph Ruby on Rails Connect Sample one. It looked better to me (comparing both tutorials and gem name) It's the first time i check this github repo, to star it.
As you said you need feedback, I would just say that not being able to filter and sort a query is pretty annoying. And of course there's a crazy lack of documentation... but now i understand better why.
Anyway thanks for the gem, I'm using it to create an intranet for our collaborators, around an office365 dashboard (mails, agenda, yammer, ...).
We appreciate your feedback about query options (sort, filter) and docs. If you'd like to submit some other suggestions of how we can better serve Ruby developers, we have a UserVoice site for tracking ideas/recommendations from the community. Thanks again for using the gem.
Not being an expert at the graph API, it took me a bit to learn that this means that you can sort or filter but not both. For my use, I just needed events that are in the future, and learned by piecing together various pieces of information that this would be expressed something like:
now = DateTime.now.utc.strftime("'%Y-%m-%dT%H:%M'")
@events = graph.me.events.filter("start/dateTime ge #{now}")
Note that the date string must be surrounded by single quotes. I thought about doing a pull request to start the documentation but since that is starting from nothing that seems like an uphill battle. I can sort the results so the lack of a sort is less impactful than the amount of time it took to figure out the filter syntax. The examples in this link were very helpful.
I believe this can be supported easily because somehow it is supported in the REST API. If you use the graph explorer and run https://graph.microsoft.com/v1.0/me/calendar/events?$filter=start/dateTime ge '2018-07-03T14:39:23-07:00' and start/dateTime le '2018-09-01T14:39:23-07:00'&$orderby=lastModifiedDateTime desc
query, it works, but once you try to do graph.me.calendar.events.filter(...).order_by(...)
it fails with MicrosoftGraph::TypeError: A collection cannot be both ordered and filtered.
. It would be awesome to have this added.
For all of REST API this would be useful.
edit: API doesn't support this :-/
@dpim, What is the status of supporting this? This issue has been open for almost 2 years. It looks like the API supports it, so why doesn't the gem?
@afkplus
I just tried it, the API doesn't honor the filter.
Wow, I am pretty sure it used to support when I was working on it. Probably something got changed there.
@afkplus
I found in the docs where it says you can't use both :-/
Note: With Azure AD resources that derive from directoryObject, like user and group, you cannot combine $orderby with $filter expressions.
https://docs.microsoft.com/en-us/graph/query-parameters#search-parameter
@darrelmiller / @afkplus
I stand corrected. I think they misread the docs. You can't use filter and orderby on the search endpoint, but if you're not using search, then you can use both together.
I tested this in the API and it seems to be working. I am going to fork this gem and patch it.
Thanks for reporting this issue. That version of the SDK has been deprecated a number of years ago. We're now starting the work on a new generation of this SDK and you can learn all about it on the updated readme page.