GraphQL Cookbook
Accesso
5 min
accesso a un utente esistente tramite l'api graphql di parse problema vuoi accedere a un utente esistente nel tuo backend tramite l'api graphql di parse soluzione utilizzando l'api graphql di parse, puoi accedere a un utente esistente semplicemente inviando le credenziali dell'utente tramite la login login mutazione gli argomenti username username e password password sono obbligatori la mutazione restituirà tutti i campi dell'utente, incluso il sessiontoken sessiontoken dopo aver effettuato l'accesso a un utente esistente, puoi utilizzare la https //www back4app com/docs/parse graphql/graphql user authentication ricetta per inviare il sessiontoken sessiontoken nelle operazioni seguenti in modo che vengano eseguite nel comportamento di questo utente puoi anche utilizzare la https //www back4app com/docs/parse graphql/graphql logout mutation ricetta per distruggere il sessiontoken sessiontoken informazioni sulla versione a seconda della versione di parse che scegli di eseguire, le query graphql, le mutazioni e i risultati saranno leggermente diversi si prega di scegliere l'esempio corretto insieme alla versione di parse che si sta eseguendo parse server 3 10 0 e versioni successive request 1 mutation login{ 2 login(input { 3 username "somefolk" 4 password "somepassword" 5 }){ 6 viewer{ 7 user{ 8 id 9 createdat 10 updatedat 11 username 12 } 13 sessiontoken 14 } 15 } 16 } response 1 { 2 "data" { 3 "login" { 4 "viewer" { 5 "user" { 6 "id" "x1vzzxi6uhnoukj3y1yyrq==", 7 "createdat" "2020 02 06t13 38 04 517z", 8 "updatedat" "2020 02 06t13 38 04 517z", 9 "username" "somefolk" 10 }, 11 "sessiontoken" "r\ a5318d28821a78069f5b618de35b57bb" 12 } 13 } 14 } 15 } parse server 3 9 0 richiesta 1 mutation login{ 2 login(fields { 3 username "somefolk" 4 password "somepassword" 5 }){ 6 id, 7 createdat, 8 updatedat, 9 username, 10 sessiontoken 11 } 12 } risposta 1 { 2 "data" { 3 "viewer" { 4 "sessiontoken" "r 1450d329038f876835fb7aac16742380", 5 "username" "somefolk" 6 } 7 } 8 } parse server 3 8 0 richiesta 1 mutation login{ 2 login(fields { 3 username "somefolk" 4 password "somepassword" 5 }){ 6 objectid, 7 createdat, 8 updatedat, 9 username, 10 sessiontoken 11 } 12 } risposta 1 { 2 "data" { 3 "login" { 4 "objectid" "ktznkvzto2", 5 "createdat" "2019 11 04t14 23 46 014z", 6 "updatedat" "2019 11 04t14 23 46 014z", 7 "username" "somefolk", 8 "sessiontoken" "r\ fe39d9de406d53d13e9af1efbbe967a8" 9 } 10 } 11 } parse server 3 7 2 richiesta 1 mutation login { 2 users { 3 login(username "somefolk", password "somepassword") { 4 objectid, 5 createdat, 6 updatedat, 7 username, 8 sessiontoken 9 } 10 } 11 } risposta 1 { 2 "data" { 3 "users" { 4 "login" { 5 "objectid" "nyu1lnlhpd", 6 "createdat" "2019 07 29t09 09 58 222z", 7 "updatedat" "2019 07 29t09 09 58 222z", 8 "username" "somefolk", 9 "sessiontoken" "r\ cbca71d29d7601761b48ed01bbe9638d" 10 } 11 } 12 } 13 }