mobql icon indicating copy to clipboard operation
mobql copied to clipboard

Optimization: Multi-fetch standard to decrease request size

Open Rodentman87 opened this issue 4 years ago • 0 comments

This issue is tracking the creation of a standard for a multi-fetch interface, allowing consumers to decrease their outgoing request size by providing a gql query name that implements this standard.

What does the standard look like?

The gql query would take an array of ids and the properties you want for all of them, similar to fetching a single object. This would decrease the amount of duplication that currently exists when fetching a large number of the same object as property names are repeated over and over.

query {
    users([id1, id2, id3...]) {
        id
        name
        ...
    }
}

How would this be implemented in MobQL?

When the DataLoadedList begins the process of requesting the properties from the server, it will find common properties being requested across all the objects in its list. It will then prepare the minimum number of queries to collect all the props needed from the server. For example:

Object 1 is requesting- [name, age, nickname] Object 2 is requesting- [name, age]

The list will generate:

query {
    a: users([1, 2]) {
        id
        name
        age
    }
    b: users([1]) {
        id
        nickname
    }
}

Rodentman87 avatar Apr 12 '21 02:04 Rodentman87