WordPress-gegevens opvragenRichtlijnen
Richtlijnen
Richtlijnen worden aangeboden via Gato GraphQL-extensies. Hier zijn slechts een paar voorbeelden.
Operatie-richtlijnen
Maak een operatie-pipeline via @depends en voer een van de operaties voorwaardelijk uit, op basis van een dynamische waarde, via @skip en @include:
query CheckIfPostExists($id: ID!) {
# Initialize the dynamic variable to `false`
postExists: _echo(value: false)
@export(as: "postExists")
post(by: { id: $id }) {
# Found the Post => Set dynamic variable to `true`
postExists: _echo(value: true)
@export(as: "postExists")
}
}
mutation ExecuteOnlyIfPostExists
@depends(on: "CheckIfPostExists")
@include(if: $postExists)
{
# Do something...
}Veld-richtlijnen
Transformeer een veld naar kleine letters via @strLowerCase:
{
posts(pagination: { limit: 3 }) {
id
title @strLowerCase
}
}Geef een standaardwaarde op voor het veld via @default:
query GetFeaturedImages {
posts(pagination: { limit: 10 }) {
id
title
hasFeaturedImage
featuredImage @default(value: 1505) {
id
src
}
}
}Verwijder de velduitvoer uit het antwoord via @remove:
query GetFeaturedImages {
posts(pagination: { limit: 10 }) {
id
title
hasFeaturedImage
featuredImage @remove(condition: IS_NULL) {
src
}
sourceFeaturedImage: featuredImage {
src
}
}
}Pas een functieveld toe op een veldwaarde via @passOnwards en @applyFunction:
{
posts {
id
hasComments
notHasComments: hasComments
@passOnwards(as: "postHasComments")
@applyFunction(
name: "_not"
arguments: {
value: $postHasComments
},
setResultInResponse: true
)
}
}