Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- export interface WithLoginMutation {
- login(opts: {username: string, password: string}): Promise<Login.Login>;
- }
- const WithLoginMutation = graphql<Login.Mutation>(
- GraphQL.login,
- {
- props({ mutate }): WithLoginMutation {
- if (!mutate) {
- throw new Error("No mutate found");
- }
- return {
- async login(opts: {username: string, password: string}): Promise<Login.Login> {
- try {
- const {username, password} = opts;
- const variables: Login.Variables = {
- username,
- password
- };
- const result = await mutate({
- variables
- });
- return result.data.login
- } catch (error) {
- throw error;
- }
- }
- };
- }
- }
- );
Add Comment
Please, Sign In to add comment