Open philipbaileynar opened 2 years ago
Using the debugger I was able to pause NAMCr right before it attempts to call the API. This is the GraphQL string that it's attempting to send:
"query rQuery{\nsetSiteCatchment(siteId:2000 catchment:[\"{\"type\": \"Polygon\",\"coordinates\": [[[-122.68,42.77],[-116.53,42.77],[-116.53,44.30],[-122.68,44.30],[-122.68,42.77]]]}\"] ) {\n \n }\n }"
There are several things wrong with this string:
setSiteCatchment
endpoint is a mutation not a query.I manipulated the string from above until it worked. What follows successfully called the API:
tpl_query = "mutation rQuery{\n
setSiteCatchment(siteId:2000, catchment:\"{\\\"type\\\": \\\"Polygon\\\",\\\"coordinates\\\": [[[-122.68,42.77],[-116.53,42.77],[-116.53,44.30],[-122.68,44.30],[-122.68,42.77]]]}\")\n}"
The top priority is to get setSiteCatchment
working from scripts using the NAMCr::save
function. This is a higher priority than getting it working within the CLI.
Since setSiteCatchment
is a mutation we intend for this call to be made through the save
command, not the `query command.
NAMCr::save(api_endpoint="setSiteCatchment", args=list(siteId = 2000, catchment= json <- '{"type": "Polygon","coordinates": [[[-122.68,42.77],[-116.53,42.77],[-116.53,44.30],[-122.68,44.30],[-122.68,42.77]]]}'))
Other mutations that can be used for regression testing are:
NAMCr::save(api_endpoint="setSitePredictorValue", args=list(siteId = 2000, predictorId=1, value="test")
Attempting to set a site catchment with a simple GeoJSON rectangle: