Skip to content
Graffle is a work in progress. Learn more.

Directive

This example shows how to use special fields to write GraphQL document directives.

ts
// import { parse, print } from 'graphql'
import { 
Graffle
} from './graffle/__.js'
const
pokemon
=
Graffle
.
create
()
const
pokemons
= await
pokemon
.
query
.
$batch
({
___
: {
$skip
: true,
pokemons
: {
name
: true,
}, },
trainers
: {
name
: true,
id
: {
$skip
: true,
},
pokemon
: {
id
: {
$include
: false,
},
name
: true,
}, }, }) console.log(
pokemons
)

Outputs

json
{
  "trainers": [
    {
      "name": "Ash",
      "pokemon": [
        {
          "name": "Pikachu"
        },
        {
          "name": "Charizard"
        }
      ]
    },
    {
      "name": "Misty",
      "pokemon": [
        {
          "name": "Squirtle"
        }
      ]
    },
    {
      "name": "Brock",
      "pokemon": []
    },
    {
      "name": "Gary",
      "pokemon": []
    }
  ]
}

Released under the MIT License.