WordPress verilerini sorgulaYorumlar
Yorumlar
Bunlar, yorumları çekmek ve eklemek için queries örnekleridir.
Yorumları Çekme
Bir gönderinin yorumları:
query {
post(by: { id: 1 }) {
comments {
id
content
author {
name
}
parent {
id
}
}
}
}Yorumlar ve yanıtları, birden fazla düzey için:
query {
post(by: { id: 1499 }) {
comments(pagination: { limit: 5 }) {
...CommentFields
responses {
...CommentFields
responses {
...CommentFields
}
}
}
}
}
fragment CommentFields on Comment {
id
date
content
}Yorumları filtreleme:
{
posts {
title
comments(
filter: { search: "insight" }
) {
id
content
}
}
}Yorum sonuçlarını sayma:
{
posts {
id
commentCount
}
}Yorumları sayfalama:
{
posts {
id
comments(
pagination: {
limit: 3,
offset: 3
}
) {
id
date
content
}
}
}Sitedeki belirli bir kullanıcıya ait tüm yorumlar:
{
commentCount(filter: { authorIDs: [1], parentID: null })
comments(filter: { authorIDs: [1], parentID: null }, pagination: { limit: -1 }) {
id
date
content
}
}Belirli bir yorum:
{
comment(by: { id: 272 }) {
id
date
content
author {
id
name
}
}
}Meta değerlerini çekme:
{
posts {
id
comments{
id
metaValue(
key:"someKey"
)
}
}
}Yorum Ekleme
Giriş yapmış veya yapmamış kullanıcılar yorum ekleyebilir:
mutation {
addCommentToCustomPost(
input: { customPostID: 1459, commentAs: { html: "Lovely tango!" } }
) {
status
errors {
__typename
...on ErrorPayload {
message
}
}
commentID
comment {
date
content
author {
id
name
}
}
}
}İç içe mutation kullanabilirsiniz:
mutation {
post(by: { id: 1459 }) {
id
title
addComment(input: { commentAs: { html: "Lovely tango!" } }) {
status
errors {
__typename
...on ErrorPayload {
message
}
}
commentID
comment {
date
content
author {
id
name
}
}
}
}
}Yoruma Yanıt Verme
Yorum eklemeye benzer, ancak ek olarak parentCommentID argümanı da sağlanır:
mutation {
addCommentToCustomPost(
input: {
customPostID: 1459
parentCommentID: 272
commentAs: { html: "Hi to you too" }
}
) {
status
errors {
__typename
...on ErrorPayload {
message
}
}
commentID
comment {
date
content
author {
id
name
}
}
}
}Ya da daha özel replyComment alanını kullanabilirsiniz:
mutation {
replyComment(input: { parentCommentID: 272, commentAs: { html: "Hi to you too" } }) {
status
errors {
__typename
...on ErrorPayload {
message
}
}
commentID
comment {
date
content
author {
id
name
}
}
}
}Ya da iç içe mutation kullanarak üst yoruma gidebilirsiniz:
mutation {
post(by: { id: 1459 }) {
comments(filter: { ids: 272 }) {
id
content
reply(input: { commentAs: { html: "Everything good?" } }) {
status
errors {
__typename
...on ErrorPayload {
message
}
}
commentID
comment {
date
content
}
}
}
}
}Prev
Next