Autenticação via Google OAuth. Recebe o token do Google e autentica ou cria o cliente automaticamente.
ClientGoogleLoginMutationInput!
| Campo | Tipo | Descrição |
|---|---|---|
| hostname | String! | Hostname da loja. |
| token | String! | Token OAuth do Google (id_token do Google Sign-In). |
| Campo | Tipo | Descrição |
|---|---|---|
| token | String | Token de autenticação. |
| user | AuthUser | Dados do usuário autenticado. |
clientGoogleSignup com os mesmos inputs — cria conta caso o e-mail não exista.
mutation GoogleLogin($input: ClientGoogleLoginMutationInput!) {
clientGoogleLogin(input: $input) {
token
user {
id
name
email
}
}
} {
"input": {
"hostname": "minha-loja",
"token": "eyJhbGciOiJSUzI1NiIs..."
}
} {
"data": {
"clientGoogleLogin": {
"token": "eyJhbGciOiJIUzI...",
"user": {
"id": "user789",
"name": "João Google",
"email": "joao@gmail.com"
}
}
}
} const response = await fetch('/graphql', {
method: 'POST',
credentials: 'include',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
query: `mutation($input: ClientGoogleLoginInput!) {
clientGoogleLogin(input: $input) { user { id name email } }
}`,
variables: { input: { hostname: "minha-loja", googleToken: "ya29..." } }
})
}); curl -X POST https://minha-loja.com/graphql \
-H "Content-Type: application/json" \
-d '{"query":"mutation { clientGoogleLogin(input: { hostname: \"minha-loja\", googleToken: \"ya29...\" }) { user { id name } } }"}'