{"size": 1026, "ext": "js", "max_stars_repo_path": "src/graphql/user/mutations.js", "max_stars_repo_name": "stardustdev9/react-firebase", "max_stars_repo_stars_event_min_datetime": "2021-03-19T02:53:23.000Z", "max_stars_repo_stars_event_max_datetime": "2021-03-19T02:53:23.000Z", "max_issues_repo_path": "src/graphql/user/mutations.js", "max_issues_repo_name": "stardustdev9/react-firebase", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/graphql/user/mutations.js", "max_forks_repo_name": "stardustdev9/react-firebase", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 20.52, "max_line_length": 61, "alphanum_fraction": 0.6627680312}
/**
 * React Starter Kit for Firebase
 * https://github.com/kriasoft/react-firebase-starter
 * Copyright (c) 2015-present Kriasoft | MIT License
 */

/* @flow */

import { GraphQLNonNull, GraphQLString } from 'graphql';
import { mutationWithClientMutationId } from 'graphql-relay';

import UserType from './UserType';
import type Context from '../Context';

export const signIn = mutationWithClientMutationId({
  name: 'SignIn',
  description: 'Authenticate user by using JWT token.',

  inputFields: {
    token: {
      type: new GraphQLNonNull(GraphQLString),
    },
  },

  outputFields: {
    me: {
      type: UserType,
    },
  },

  async mutateAndGetPayload(input: any, ctx: Context) {
    return {
      me: await ctx.signIn(input.token),
    };
  },
});

export const signOut = mutationWithClientMutationId({
  name: 'SignOut',
  description: 'Clear authentication cookie.',

  inputFields: {},
  outputFields: {},

  async mutateAndGetPayload(input: any, ctx: Context) {
    ctx.signOut();
    return {};
  },
});
