Skip to content

Conversation

ballinette
Copy link

@ballinette ballinette commented Aug 10, 2018

What does this PR do?

Make kuzzle.query return value consistent with other sdks, and give access to the whole Kuzzle response.

Given we have following response from Kuzzle:

{
  "status": 200,
  "error": null,
  "result": {"foo": "bar"},
  "volatile": {"you": "'win"}
}

Before this PR:

return this.kuzzle.query({
  controller: 'server',
  action: 'getAllStats'
}, options);
return this.kuzzle.query({
  controller: 'server',
  action: 'now'
}, options)
  .then(result => result.now);

Now:

  • kuzzle.query act as a low-level method which resolves the whole response from the backend, giving access to the response's status, the volatile data, etc.

  • Consequently, each controller's actions must parse the response to resolve the response.result object.
    Examples:

server.getAllstats:

return this.kuzzle.query({
  controller: 'server',
  action: 'getAllStats'
}, options)
  .then(response => response.result);

server.now:

return this.kuzzle.query({
  controller: 'server',
  action: 'now'
}, options)
  .then(response => response.result.now);

@codecov-io
Copy link

Codecov Report

Merging #305 into 6.x will increase coverage by 0.13%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##             6.x     #305      +/-   ##
=========================================
+ Coverage   97.5%   97.64%   +0.13%     
=========================================
  Files         28       28              
  Lines       1325     1400      +75     
=========================================
+ Hits        1292     1367      +75     
  Misses        33       33
Impacted Files Coverage Δ
src/controllers/realtime/room.js 100% <100%> (ø) ⬆️
src/controllers/bulk.js 100% <100%> (ø) ⬆️
src/controllers/index.js 97.36% <100%> (+0.81%) ⬆️
src/controllers/server.js 100% <100%> (ø) ⬆️
src/Kuzzle.js 99.29% <100%> (-0.01%) ⬇️
src/controllers/document.js 100% <100%> (ø) ⬆️
src/controllers/searchResult/base.js 100% <100%> (ø) ⬆️
src/controllers/collection.js 100% <100%> (ø) ⬆️
src/controllers/memoryStorage.js 96.29% <100%> (ø) ⬆️
src/controllers/security/index.js 100% <100%> (ø) ⬆️
... and 2 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b56ed5e...05d5000. Read the comment docs.

@Aschen Aschen merged commit 2d99c40 into 6.x Aug 14, 2018
@Aschen Aschen deleted the do-not-parse-query-result branch August 14, 2018 08:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants