Skip to content

Add a batching layer #17

@ooflorent

Description

@ooflorent

When using nested routes in Relay, multiple queries are required to render the application. Relay default network layer receives the requests as an array but runs then concurrently. Because of query structure, it is really hard to combine them in a single query (fragment names and variables can create conflicts).

An alternate solution is to support query batching. Instead of receiving a json request containing the query and the variables, the server should be able to decode an array of requests.

// Normal query
{query: "query q{user(id:$id){id}}", variables: {id: 1}}

// Batch alternative
[
  {query: "query q{user(id:$id){id}}", variables: {id: 1}},
  {query: "query q{user(id:$id){id}}", variables: {id: 2}},
]

// Combine approach (too hard to implement)
{query: "query q{u0:user(id:$id0){id}u1:user(id:$id1){id}}", variables: {id0: 1, id1: 2}}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions