Query examples
Query examplesPost Tags

Post Tags

These are examples of queries to fetch post tag data.

Fetching tags

List of post tags, ordering them by name, and showing their post count:

query {
  postTags(
    sort: { order: ASC, by: NAME }
    pagination: { limit: 50 }
  ) {
    id
    name
    url
    postCount
  }
}

All tags in a post:

query {
  post(by: { id: 1 }) {
    tags {
      id
      name
      url
    }
  }
}

Tag names in posts:

query {
  posts {
    id
    title
    tagNames
  }
}

A list of predefined tags:

query {
  postTags(filter: { ids: [66, 70, 191] }) {
    id
    name
    url
  }
}

Filtering tags by name:

query {
  postTags(filter: { search: "oo" }) {
    id
    name
    url
  }
}

Counting tag results:

query {
  postTagCount(filter: { search: "oo" })
}

Paginating tags:

query {
  postTags(
    pagination: {
      limit: 5,
      offset: 5
    }
  ) {
    id
    name
    url
  }
}

Fetching meta values:

query {
  postTags(
    pagination: { limit: 5 }
  ) {
    id
    name
    metaValue(
      key: "someKey"
    )
  }
}

Setting tags on a post

Mutation:

mutation {
  setTagsOnPost(
    input: {
      id: 1499, 
      tags: ["api", "development"]
    }
  ) {
    status
    errors {
      __typename
      ... on ErrorPayload {
        message
      }
    }
    postID
    post {
      tags {
        id
      }
      tagNames
    }
  }
}

Nested mutation:

mutation {
  post(by: { id: 1499 }) {
    setTags(
      input: {
        tags: ["api", "development"]
      }
    ) {
      status
      errors {
        __typename
        ... on ErrorPayload {
          message
        }
      }
      postID
      post {
        tags {
          id
        }
        tagNames
      }
    }
  }
}