Bug? With GraphQL, onBeforeLoad fires too late

https://snippet.webix.com/goeql9sh

Notice how onBeforeLoad triggers after the data was already loaded, before we call .parse.

No, it’s not a bug.

The event fires before data reaches the component itself and it is triggered for both server-side and client-side data when it is ready to be parsed.

It is not related to Ajax requests that are sent implicitly during data loading. They can be handled with global Webix onBeforeAjax event.

The event fires before data reaches the component itself

Would it be more accurate to name the event onBeforeParse then, instead of onBeforeLoad?

Based on your sample for loading GraphQL data, I assume an event named “onBeforeLoad” would be triggered immediately after calling load({currency:"USD"}) in that example, and before the GraphQL request is sent.

My goal is to display a “Loading…” overlay while waiting for new data from the server after changing the sort order in a Datatable (I’m trying to do server-side sorting). onBeforeLoad is not useful for that goal, because it is fired after the data has already arrived, so if I use it, the user will see the old Datatable contents (or blank if I use this.clearAll()) while waiting for data. Is there a more appropriate event for this purpose with GraphQL?

My fault, I should have put the idea in a more clear way. The event fires before data reaches the component in any of the ways, loading or parsing.

But you need to use widget loading API: .load()/.parse() methods or url/data properties. The call to the .load() method of any proxy will not trigger the event.

Fortunately, you can use the proxy within a loading function:

$$("grid").load(function(){
    return webix.proxy().load({}).then(data => { 
      return data;
    });
})

Please, check the updated example from above: Code Snippet