59 lines
1.1 KiB
TypeScript
59 lines
1.1 KiB
TypeScript
![]() |
import gql from "graphql-tag";
|
||
|
|
||
|
import { TypedMutation } from "../mutations";
|
||
|
import { TokenAuth, TokenAuthVariables } from "./types/TokenAuth";
|
||
|
import { VerifyToken, VerifyTokenVariables } from "./types/VerifyToken";
|
||
|
|
||
|
export const fragmentUser = gql`
|
||
|
fragment User on User {
|
||
|
id
|
||
|
email
|
||
|
firstName
|
||
|
lastName
|
||
|
isStaff
|
||
|
note
|
||
|
permissions {
|
||
|
code
|
||
|
name
|
||
|
}
|
||
|
}
|
||
|
`;
|
||
|
|
||
|
export const tokenAuthMutation = gql`
|
||
|
${fragmentUser}
|
||
|
mutation TokenAuth($email: String!, $password: String!) {
|
||
|
tokenCreate(email: $email, password: $password) {
|
||
|
token
|
||
|
errors {
|
||
|
field
|
||
|
message
|
||
|
}
|
||
|
user {
|
||
|
...User
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
`;
|
||
|
|
||
|
export const TypedTokenAuthMutation = TypedMutation<
|
||
|
TokenAuth,
|
||
|
TokenAuthVariables
|
||
|
>(tokenAuthMutation);
|
||
|
|
||
|
export const tokenVerifyMutation = gql`
|
||
|
${fragmentUser}
|
||
|
mutation VerifyToken($token: String!) {
|
||
|
tokenVerify(token: $token) {
|
||
|
payload
|
||
|
user {
|
||
|
...User
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
`;
|
||
|
|
||
|
export const TypedVerifyTokenMutation = TypedMutation<
|
||
|
VerifyToken,
|
||
|
VerifyTokenVariables
|
||
|
>(tokenVerifyMutation);
|