GraphQL Cookbook
ออกจากระบบ
6 นาที
การออกจากระบบผู้ใช้ที่เข้าสู่ระบบผ่าน parse graphql api ปัญหา คุณต้องการออกจากระบบผู้ใช้ที่เข้าสู่ระบบในแบ็กเอนด์ของคุณผ่าน parse graphql api วิธีแก้ไข โดยใช้ parse graphql api คุณสามารถออกจากระบบผู้ใช้ที่เข้าสู่ระบบได้เพียงแค่ส่ง sessiontoken sessiontoken ของผู้ใช้ผ่าน x parse session token x parse session token ในส่วนหัว (ตามที่อธิบายไว้ใน การตรวจสอบผู้ใช้ https //www back4app com/docs/parse graphql/graphql user authentication สูตร) และเรียกใช้ logout logout การเปลี่ยนแปลง parse server จะทำลาย sessiontoken sessiontoken และจะไม่ถูกยอมรับสำหรับคำขอในอนาคตอื่น ๆ ข้อมูลเวอร์ชัน ขึ้นอยู่กับเวอร์ชันของ parse ที่คุณเลือกใช้งาน คำสั่ง graphql การเปลี่ยนแปลง และผลลัพธ์จะมีความแตกต่างกันเล็กน้อย โปรดเลือกตัวอย่างที่ถูกต้องพร้อมกับเวอร์ชัน parse ที่คุณกำลังใช้งาน parse server 4 4 0 และเวอร์ชันที่ใหม่กว่า request //the headers for this operation are x parse application id, x parse client key and x parse session token 1 mutation logoutbutton { 2 logout(input { clientmutationid "9vc3nljyhp" }) { 3 clientmutationid 4 } 5 } response 1 { 2 "data" { 3 "logout" { 4 "clientmutationid" "9vc3nljyhp" 5 } 6 } 7 } 8 เวอร์ชันเซิร์ฟเวอร์ parse เก่า parse server 3 10 0 และ 4 2 0 request //ด้วย parse 3 10 0 และ 4 2 0 คุณต้องตั้งค่าหัวที่เรียกว่า x parse session token ซึ่งมี session token สำหรับผู้ใช้ที่ได้รับการตรวจสอบสิทธิ์ เมื่อมันถูกตั้งค่าแล้ว คุณสามารถเรียก 1 mutation{ 2 logout(input { clientmutationid "sampleid"}){ 3 viewer{ 4 user{ 5 id 6 } 7 } 8 } 9 } response 1 { 2 "data" { 3 "logout" { 4 "viewer" { 5 "user" { 6 "id" "x1vzzxi6uhnoukj3y1yyrq==" 7 } 8 } 9 } 10 } 11 } parse server 3 9 0 request //ด้วย parse 3 9 0 คุณต้องตั้งค่าหัวที่เรียกว่า x parse session token ซึ่งมี session token สำหรับผู้ใช้ที่ได้รับการตรวจสอบสิทธิ์ เมื่อมันถูกตั้งค่าแล้ว คุณสามารถเรียก 1 mutation{ 2 logout{ 3 id 4 } 5 } response 1 { 2 "data" { 3 "logout" { 4 "id" "gx2zw7yeny" 5 } 6 } 7 } parse server 3 8 0 คำขอ 1 mutation{ 2 logout{ 3 objectid 4 } 5 } การตอบกลับ 1 { 2 "data" { 3 "logout" { 4 "objectid" "ktznkvzto2" 5 } 6 } 7 } parse server 3 7 2 คำขอ 1 mutation logout { 2 users { 3 logout 4 } 5 } การตอบกลับ 1 { 2 "data" { 3 "users" { 4 "logout" true 5 } 6 } 7 }