Grapher firewall throw error

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?



  firewall(userId, params) {
    if (!isAllowedTo({userId: this.userId, action: 'read'})){
      throw new Meteor.Error('not-allowed');


withTracker(() => {
    const result = myQuery.clone();
    const resultHandle = result.subscribe();
    return {
      result: result.fetch(),
      loading: !resultHandle.ready(),


function ({result, loading}) => (
  {loading ?
    ) : (
      <Result result={result}/>

It seems you aren’t using grapher-react also by @diaconutheodor for data fetching for your react component. It provides easy to use React Components that are suitable for the grapher package. It handles errors really well with the withQuery default export.

@kunubu handling subscription errors was a difficult problem to solve, you can check-out the code from to see how it was done. Specifically this:

1 Like

Thanks for the answers and for helping me.
The hint to the code of grapher-react helped a lot. I wasn’t aware that grapher-react handles errors although i played around with it while testing grapher. The reason i didn’t use it is, as far as i understand, that you can only “subscribe” to one query. I have a parent component with two queries and two child components. Each of the queries is used by both child components. I fetch the data in the parent component and pass it down to the child components. Is there a possibility to have two queries for one component with grapher-react?

1 Like