GraphQL Cookbook
Iscrizione
6 min
registrazione di un utente tramite l'api graphql di parse problema vuoi registrare un nuovo utente nel tuo backend tramite l'api graphql di parse soluzione utilizzando l'api graphql di parse, puoi registrare un nuovo utente semplicemente inviando i dati dell'utente tramite la signup signup mutazione i campi username username e password password sono obbligatori la mutazione restituirà non solo i campi objectid objectid e createdat createdat (che vengono restituiti per impostazione predefinita quando https //www back4app com/docs/parse graphql/graphql mutation create object ), ma anche il sessiontoken sessiontoken dopo aver registrato un nuovo utente, puoi utilizzare la https //www back4app com/docs/parse graphql/graphql user authentication 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 login per accedere all'utente utilizzando le credenziali definite e la https //www back4app com/docs/parse graphql/graphql logout mutation per distruggere il sessiontoken sessiontoken informazioni sulla versione a seconda della versione di parse che scegli di eseguire, le query, le mutazioni e i risultati graphql saranno leggermente diversi si prega di scegliere il corretto esempio insieme alla versione di parse che stai eseguendo parse server 4 2 0 e versioni successive request 1 mutation signup{ 2 signup(input { 3 fields { 4 username "somefolk" 5 password "somepassword" 6 } 7 }){ 8 viewer{ 9 user{ 10 id 11 createdat 12 } 13 sessiontoken 14 } 15 } 16 } response 1 { 2 "data" { 3 "signup" { 4 "viewer" { 5 "user" { 6 "id" "x1vzzxi6ckzwbdr3yljuca==", 7 "createdat" "2020 02 06t13 38 04 517z" 8 }, 9 "sessiontoken" "r 3233bc3b6801a15bcda39ff250416143" 10 } 11 } 12 } 13 } versioni precedenti di parse server parse server 3 10 0 e versioni successive richiesta 1 mutation signup{ 2 signup(input { 3 userfields { 4 username "somefolk" 5 password "somepassword" 6 } 7 }){ 8 viewer{ 9 user{ 10 id 11 createdat 12 } 13 sessiontoken 14 } 15 } 16 } risposta 1 { 2 "data" { 3 "signup" { 4 "viewer" { 5 "user" { 6 "id" "x1vzzxi6uhnoukj3y1yyrq==", 7 "createdat" "2020 02 06t13 38 04 517z" 8 }, 9 "sessiontoken" "r\ c7abf06d951e8087c00fa66d546d1fea" 10 } 11 } 12 } 13 } parse server 3 9 0 richiesta 1 mutation signup{ 2 signup(fields { 3 username "somefolk" 4 password "somepassword" 5 }){ 6 id 7 createdat 8 sessiontoken 9 } 10 } risposta 1 { 2 "data" { 3 "signup" { 4 "id" "gx2zw7yeny", 5 "createdat" "2019 11 04t14 24 21 333z", 6 "sessiontoken" "r 6d5f75f0f2d9ee16077b0a0ff1e20eb2" 7 } 8 } 9 } parse server 3 8 0 richiesta 1 mutation signup{ 2 signup(fields { 3 username "somefolk" 4 password "somepassword" 5 }){ 6 objectid 7 createdat 8 } 9 } risposta 1 { 2 "data" { 3 "signup" { 4 "objectid" "ktznkvzto2", 5 "createdat" "2019 11 04t14 23 46 014z", 6 "sessiontoken" "r 2ca6914312ed16803cf3769a25934cdc" 7 } 8 } 9 } parse server 3 7 2 richiesta 1 mutation signup { 2 users { 3 signup(fields { username "somefolk", password "somepassword" }) { 4 objectid, 5 createdat, 6 sessiontoken 7 } 8 } 9 } risposta 1 { 2 "data" { 3 "users" { 4 "signup" { 5 "objectid" "nyu1lnlhpd", 6 "createdat" "2019 07 29t09 09 58 222z", 7 "sessiontoken" "r\ a86665f0b63d9d8f945e4b0f302a1655" 8 } 9 } 10 } 11 }