You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Now it is possible to observe headers with observer function, but it will be much more convenient to simply pass some per-query option like returnResponse so that I can get billing headers in my tests and write a test suite to calculate projected cost of my app.
Currently, client.query(...) returns query result only. Desired feature will work like this:
Based on idea from this Fauna forum issue, I managed to incorporate this solution by overriding faunadb.Client class:
classObserverClientextendsfaunadb.Client{constructor(opts){super({
...opts,// overrides observer to save last responseobserver: (res)=>{this._lastResponse=resopts.observer&&opts.observer(res)// in case we have custom observer passed.},})this._lastResponse=null}asyncquery(expr,options={}){const{ returnResponse, ...rest}=optionsconstresult=awaitsuper.query(expr,rest)returnreturnResponse ? { result,response: this._lastResponse} : result}}
Now it is possible to observe headers with observer function, but it will be much more convenient to simply pass some per-query option like
returnResponse
so that I can get billing headers in my tests and write a test suite to calculate projected cost of my app.Currently,
client.query(...)
returns query result only. Desired feature will work like this:I firmly believe this feature will benefit all Faunadb community.
The text was updated successfully, but these errors were encountered: