<commit_before>import React from 'react';
import { graphql, compose } from 'react-apollo';
import { connect } from 'react-redux';
import { array, bool, func, object } from 'prop-types';
import jwtDecode from 'jwt-decode';

import Dashboard from '../components/Dashboard/Dashboard';
import Loader from '../components/Loader';

import userGamesQuery from '../graphql/userGames.graphql';
import allGamesQuery from '../graphql/allGames.graphql';
import updateGeneralSettings from '../graphql/updateGeneralSettings.graphql';
import deleteGame from '../graphql/deleteGame.graphql';
import createTestingSession from '../graphql/createTestingSession.graphql';

const mapStateToProps = ({ user }) => (
  {
    user
  }
);

const withGraphql = compose(
  graphql(userGamesQuery, {
    props: ({ data }) => {
      if (!data.user) return { loading: data.loading };
      if (data.error) return { hasErrors: true };
      return {
        games: data.user.games,
      };
    },
    options: () => {
      const token = localStorage.getItem('token');
      const user = jwtDecode(token);
      return { variables: { id: user._id } };
    }
  }),
  graphql(createTestingSession, {
    props: ({ mutate }) => ({
      createSession: (input) => mutate({ variables: { input } }),
    })
  }),
  graphql(updateGeneralSettings, {
    props: ({ mutate }) => ({
      updateGeneral: (gameId, isPrivate, releaseStatus) =>
        mutate({ variables: { gameId, isPrivate, releaseStatus } }),
    })
  }),
  graphql(deleteGame, {
    props: ({ mutate }) => {
      const token = localStorage.getItem('token');
      const user = jwtDecode(token);
      const queriesToRefetch = [
        {
          query: userGamesQuery,
          variables: { id: user._id }
        },
        {
          query: allGamesQuery,
          variables: { checkInvisible: true }
        }
      ];
<commit_msg>Refetch user games on test session creation<commit_after>import React from 'react';
import { graphql, compose } from 'react-apollo';
import { connect } from 'react-redux';
import { array, bool, func, object } from 'prop-types';
import jwtDecode from 'jwt-decode';

import Dashboard from '../components/Dashboard/Dashboard';
import Loader from '../components/Loader';

import userGamesQuery from '../graphql/userGames.graphql';
import allGamesQuery from '../graphql/allGames.graphql';
import updateGeneralSettings from '../graphql/updateGeneralSettings.graphql';
import deleteGame from '../graphql/deleteGame.graphql';
import createTestingSession from '../graphql/createTestingSession.graphql';

const mapStateToProps = ({ user }) => (
  {
    user
  }
);

const withGraphql = compose(
  graphql(userGamesQuery, {
    props: ({ data }) => {
      if (!data.user) return { loading: data.loading };
      if (data.error) return { hasErrors: true };
      return {
        games: data.user.games,
      };
    },
    options: () => {
      const token = localStorage.getItem('token');
      const user = jwtDecode(token);
      return { variables: { id: user._id } };
    }
  }),
  graphql(createTestingSession, {
    props: ({ mutate }) => {
      const token = localStorage.getItem('token');
      const user = jwtDecode(token);
      const queriesToRefetch = [
        {
          query: userGamesQuery,
          variables: { id: user._id }
        }
      ];
      return ({
        createSession: (input) => mutate({
          refetchQueries: queriesToRefetch,
          variables: { input }
        }),
      });
    }
  }),
  graphql(updateGeneralSettings, {
    props: ({ mutate }) => ({
      updateGeneral: (gameId, isPrivate, releaseStatus) =>
        mutate({ variables: { gameId, isPrivate, releaseStatus } }),
    })
  }),
  graphql(deleteGame, {
    props: ({ mutate }) => {
      const token = localStorage.getItem('token');
      const user = jwtDecode(token);
      const queriesToRefetch = [
        {
          query: userGamesQuery,
          variables: { id: user._id }
        },
        {
          query: allGamesQuery,
          variables: { checkInvisible: true }
        }
      ];

{'fraction_non_alphanumeric': 0.14159509202453988, 'fraction_numerical': 0.0, 'mean_word_length': 2.7122040072859743, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '794396', 'n_tokens_mistral': 1190, 'n_tokens_neox': 1195, 'n_words': 276}