GraphQL Cookbook
Logging out
6 min
logging out a logged user through the parse graphql api problem you want to log out a logged user in your backend through the parse graphql api solution using the parse graphql api, you can log out a logged user just by sending the user’s sessiontoken sessiontoken through the x parse session token x parse session token header (as described in the authenticating a user https //www back4app com/docs/parse graphql/graphql user authentication recipe) and calling the logout logout mutation parse server will destroy the sessiontoken sessiontoken and it will not be accepted for any other future request version information depending on the version of parse you choose to run, the graphql queries, mutations and results will be slightly different please choose the correct example along with the parse version you are running parse server 4 4 0 and later 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 older parse server versions parse server 3 10 0 and 4 2 0 request //with parse 3 10 0 and 4 2 0 you must set a header called x parse session token containing the session token for the authenticated user once it is set, you can call 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 //with parse 3 9 0 you must set a header called x parse session token containing the session token for the authenticated user once it is set, you can call 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 request 1 mutation{ 2 logout{ 3 objectid 4 } 5 } response 1 { 2 "data" { 3 "logout" { 4 "objectid" "ktznkvzto2" 5 } 6 } 7 } parse server 3 7 2 request 1 mutation logout { 2 users { 3 logout 4 } 5 } response 1 { 2 "data" { 3 "users" { 4 "logout" true 5 } 6 } 7 }