I have just released a new R package for the most important Survey Solutions GraphQL queries & mutations. The package is purely based on the httr and jsonlite package, and does not require any other client. It also includes all the map related queries and mutations, and in particular the latest addition, the map upload. Using the suso_gql_uploadmap() function allows you to upload a zip file of maps (ESRI shape files, GeoTIFF or TPK) directly from R (or from your shiny application). Thanks to @vitalii for his support in this regard.
The package is released as a beta version, as it is still under active testing and development, including the documentation. Therefore it is only recommended for experienced users at this stage.
Please also note, that this package is currently completely independent from the Survey Solutions REST API package. There are plans for a future integration, but this will take a bit. Also be aware, that the return types may change in the future. Currently a list is returned containing the returned JSON response, however this may be changed to more convenient return types like data.frame or data.table.. This means if you use it in a Shiny application, you will need to change this in the future.
Feedback, feature proposals & bug reports are very welcome, either here or on GitHub directly. If you want to use parts of the code on your own, or create a fork, feel free to do so. If useful for the majority of Survey Solutions users, happy to include it in the next version.
no, i don’t think so. This may have to do with some read/write permission. However to me it looks like the package installed cleanly. Since it uses pretty basic functions, you should be fine even with an older version of the required packages.
Try library(susographql) if it loads cleanly, then you are good to go. Thanks also for testing. Always good to see if it works on different systems.
Given that this solution also demonstrates their usefulness for monitoring purposes, I have now also added certain sort parameters as well as the take and skip parameters to the interviews and maps types.
The solution proposed by Sergiy would then look like this:
suso_gql_interviews(endpoint = [your server] user = [your api user], password = [your password], sortby_updateDateUtc = “DESC”, take = 1)
Other parameters in the interviews type will follow during the next days.
This means in the case of lets say 120 assignments, you would do the following:
suso_gql_assignments(endpoint = [your server] user = [your api user], password = [your password], take = 100)
suso_gql_assignments(endpoint = [your server] user = [your api user], password = [your password], skip = 100, take = 20)
In case you need to do this programmatically, you would first get the total number, divide it by 100, and then loop over it. And certainly the first take above (100) would not be necessary, i only did it for demonstration purposes.
@ashwinikalantri thank you very much for your feedback. This is definitely a good idea, However for now, this package uses the GraphQL API “native” queries & mutations without any significant data wrangling. Nevertheless with a (planned) deeper integration with the Survey Solutions API package this will most likely happen. But at this stage i can not tell you when this will be the case.
In any case you can already achieve this (i.e. getting all assignments with a single call), by using the suso_get_assignments() function from said API package. This function uses the REST API, and will return all assignments in a single data.table.
The latter package was also build with a more application oriented approach, such that it is easier to use i.e. in a shiny application.
To facilitate operator selection, the package now also has some transformation functions, which allows you to use the large variety of operators provided by the API. Currently this is only implemented for numeric values, as outlined under the input types ComparableInt64OperationFilterInput and ComparableNullableOfInt32OperationFilterInput. The following examples demonstrate how to use them: