-
Notifications
You must be signed in to change notification settings - Fork 313
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(docs): guide for document method
- Loading branch information
1 parent
6af92b8
commit fcaccba
Showing
3 changed files
with
60 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,39 @@ | ||
# Batch <GeneratedClientBadge /> | ||
|
||
<!-- @include: @/_snippets/example-links/batch.md --> | ||
|
||
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](https://the-guild.dev/graphql/yoga-server/docs/features/request-batching). | ||
> That is a feature [Graffle does not yet support](https://github.com/jasonkuhrt/graffle/issues/1017). | ||
For example the [pokemon schema](../../examples/01_about/pokemon-schema.md) 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 twoslash | ||
import { Pokemon } from './pokemon/__.js' | ||
const pokemon = Pokemon.create() | ||
// ---cut--- | ||
const result = await pokemon.query.$batch({ | ||
// ^^^^^^ | ||
pokemons: { | ||
name: true, | ||
}, | ||
trainers: { | ||
name: true, | ||
}, | ||
}) | ||
``` | ||
|
||
### Example | ||
|
||
<!-- @include: @/_snippets/examples/generated/batch.md --> |