graphql-request
graphql-request copied to clipboard
How to @skip fields in graphql-request?
Hi everyone,
How do I use the directive skip
to ignore a field by checking a Boolean variable?
See example below with @skip(if: $skipReleaseDate)
:
const query = gql`
query getMovie($title: String!, $skipReleaseDate: Boolean!) {
Movie(title: $title) {
releaseDate @skip(if: $skipReleaseDate) ##### Don’t query releaseDate via skip directive
actors {
name
}
}
}
`
const variables = {
title: 'Inception',
skipReleaseDate: true
}
const data = await request(endpoint, query, variables)
(Docs by dgraph on skip & include for reference)
Is this something currently supported?
@johannesmutter It works just fine for me.
This is a GraphQL feature within he query string sent to server, nothing about this library's own code.