Closed eatyourgreens closed 6 years ago
Turns out I didn't properly remember how query params are passed to the client. The syntax is client.type(type).get(queryParams)
.
Maybe the equivalent for create
and update
should be
resource.update(changeSet).save(queryParams)
client.type(type).create(payload).save(queryParams)
.
That is a pity as the intention of this code client.type(type).query(paramsObject)
reads loud and clear whereas obfuscating behind the get / save params is less intuitive.
Something to revisit if it ever gets rewritten...
.query()
reads better to me too, but .type()
returns a Resource object so the query params would have to be written to the resource somehow then read on .save()
? It might get messy.
Ideally, we'd like to be able to specify query params alongside request payloads, something along the lines of
client.type(type).query(paramsObject).create(payloadObject)
.This probably requires adding
.query()
to PUT and POST requests, and updating the client to differentiate between payload data and query params.