WordPress verilerini sorgula
WordPress verilerini sorgulaKullanicilar

Kullanicilar

Bunlar, kullanici verilerini getirmek ve kullaniciyi giris yaptirmak icin queries ornekleridir.

Kullanicilari Getirme

Gonderileriyle birlikte tek bir kullanici:

query {
  user(by: { id: 1 }) {
    name
    email
    url
    posts {
      id
      title
      excerpt
    }
  }
}

Ada gore sirali 5 kullanicidan olusan bir liste:

query {
  users(
    pagination: { limit: 5 }
    sort: { by: NAME, order: ASC }
  ) {
    id
    displayName
    websiteURL
  }
}

Avatar'lariyla birlikte onceden tanimlanmis kullanicilarin listesi:

{
  users(filter: { ids: [2, 3, 5] }) {
    id
    displayName
    url
    avatar(size: 150) {
      size
      src
    }
  }
}

Kullanicilari ada gore filtreleme:

query {
  users(filter: { searchBy: { name: "le" } }) {
    id
    name
    email
  }
}

Kullanici sonuclarini sayma:

query {
  userCount(
    filter: { searchBy: { name: "le" } }
  )
}

Kullanicilari sayfalama:

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

Meta degerleri getirme:

query {
  users {
    id
    name
    metaValue(
      key: "last_name",
    )
  }
}

Rolleri ve Yetenekleri Getirme

Rehberde daha fazla bilgi edinin: "Hassas" veri alanlarini sorgulama.

Kullanicilarin roles ve capabilities degerlerini alma:

query {
  users {
    id
    displayName
    roles {
      name
      capabilities
    }
  }
}

Kullanicinin Giris ve Cikis Yaptirilmasi

Kullaniciyi giris yaptirmak, mutation'lari calistirmak icin gereklidir (gonderi olusturma, yorum ekleme vb.).

Bu query kullaniciyi giris yaptirir:

mutation {
  loginUser(
    by: {
      credentials: {
        usernameOrEmail: "test",
        password: "pass"
      }
    }
  ) {
    status
    errors {
      __typename
      ...on ErrorPayload {
        message
      }
      ...on GenericErrorPayload {
        code
      }
    }
    userID
  }
}

Giris yapan kullaniciyi almak icin:

query {
  me {
    id
    name
  }
}

Kullaniciyi cikis yaptirma:

mutation {
  logoutUser {
    status
    errors {
      __typename
      ...on ErrorPayload {
        message
      }
      ...on GenericErrorPayload {
        code
      }
    }
    userID
  }
}