Hello there
I’m trying to use grapher in my project and at the moment i am stuck on the following:
I expose a query and in the firewall i check if the user is allowed to see the results. As shown in the docs i throw an error if the user is not allowed. But how do i handle the error client side (feedback for user). If i throw an error the result seems to be empty but subscription never gets ready (forever loading) and i have no error and therefor no hint why the result is empty. How would one do this?
Markus
expose.js
myQuery.expose({
firewall(userId, params) {
if (!isAllowedTo({userId: this.userId, action: 'read'})){
throw new Meteor.Error('not-allowed');
}
}
});
componentContainer.jsx
withTracker(() => {
const result = myQuery.clone();
const resultHandle = result.subscribe();
return {
result: result.fetch(),
loading: !resultHandle.ready(),
}
}
)(Component);
component.jsx
function ({result, loading}) => (
{loading ?
(
<Loading/>
) : (
<Result result={result}/>
)
}
)