Batch generated client
Examples -> Batch
The $batch
method appears on the client interface for every root type in the GraphQL schema. It is useful when you need to select multiple root fields in a single request.
NOTE
This is not the same thing as request batching. That is a feature Graffle does not yet support.
For example the pokemon schema has these two root fields:
graphql
type Mutation {
addPokemon(attack: Int, defense: Int, hp: Int, name: String!, type: PokemonType!): Pokemon
# ...
}
And you could select both with $batch
in a single request:
ts
const result = await pokemon.query.$batch({
pokemons: {
name: true,
},
trainers: {
name: true,
},
})