2019-06-19 14:40:52 +00:00
|
|
|
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
|
|
|
|
}
|
2019-08-09 11:14:35 +00:00
|
|
|
avatar {
|
|
|
|
url
|
|
|
|
}
|
2019-06-19 14:40:52 +00:00
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
|
|
|
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);
|