Skip to content

Commit

Permalink
chore: 🔧 change queries to mutations
Browse files Browse the repository at this point in the history
  • Loading branch information
apotdevin committed Dec 4, 2020
1 parent f2eff6c commit 18911fd
Show file tree
Hide file tree
Showing 13 changed files with 131 additions and 136 deletions.
26 changes: 12 additions & 14 deletions pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,18 @@ import { ForwardBox } from '../src/views/home/reports/forwardReport';
import { LiquidReport } from '../src/views/home/reports/liquidReport/LiquidReport';
import { ConnectCard } from '../src/views/home/connect/Connect';

const HomeView = () => {
return (
<>
<Version />
<AccountInfo />
<ConnectCard />
<QuickActions />
<FlowBox />
<LiquidReport />
<ForwardBox />
<NetworkInfo />
</>
);
};
const HomeView = () => (
<>
<Version />
<AccountInfo />
<ConnectCard />
<QuickActions />
<FlowBox />
<LiquidReport />
<ForwardBox />
<NetworkInfo />
</>
);

const Wrapped = () => (
<GridWrapper>
Expand Down
4 changes: 1 addition & 3 deletions server/schema/auth/resolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const { serverRuntimeConfig } = getConfig() || {};
const { cookiePath, nodeEnv } = serverRuntimeConfig || {};

export const authResolvers = {
Query: {
Mutation: {
getAuthToken: async (
_: undefined,
{ cookie }: { cookie: string },
Expand Down Expand Up @@ -142,8 +142,6 @@ export const authResolvers = {
);
return info?.version || '';
},
},
Mutation: {
logout: async (
_: undefined,
__: any,
Expand Down
4 changes: 2 additions & 2 deletions server/schema/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,6 @@ export const queryTypes = gql`
initialize: Boolean
lastMessage: String
): getMessagesType
getAuthToken(cookie: String): Boolean!
getSessionToken(id: String, password: String): String!
getServerAccounts: [serverAccountType]
getAccount: serverAccountType
getLatestVersion: String
Expand All @@ -95,6 +93,8 @@ export const queryTypes = gql`

export const mutationTypes = gql`
type Mutation {
getAuthToken(cookie: String): Boolean!
getSessionToken(id: String, password: String): String!
claimBoltzTransaction(
redeem: String!
transaction: String!
Expand Down
5 changes: 3 additions & 2 deletions src/components/accounts/ServerAccounts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@ import * as React from 'react';
import { useRouter } from 'next/router';
import { appendBasePath } from 'src/utils/basePath';
import { getUrlParam } from 'src/utils/url';
import { useGetAuthTokenLazyQuery } from 'src/graphql/queries/__generated__/getAuthToken.generated';
import { toast } from 'react-toastify';
import { getErrorContent } from 'src/utils/error';
import { useGetAuthTokenMutation } from 'src/graphql/mutations/__generated__/getAuthToken.generated';

export const ServerAccounts: React.FC = () => {
const { push, query } = useRouter();

const cookieParam = getUrlParam(query?.token);

const [getToken, { data }] = useGetAuthTokenLazyQuery({
const [getToken, { data }] = useGetAuthTokenMutation({
variables: { cookie: cookieParam },
refetchQueries: ['GetNodeInfo'],
onError: error => {
toast.error(getErrorContent(error));
push(appendBasePath('/login'));
Expand Down
46 changes: 46 additions & 0 deletions src/graphql/mutations/__generated__/getAuthToken.generated.tsx

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 48 additions & 0 deletions src/graphql/mutations/__generated__/getSessionToken.generated.tsx

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { gql } from '@apollo/client';

export const GET_AUTH_TOKEN = gql`
query GetAuthToken($cookie: String) {
mutation GetAuthToken($cookie: String) {
getAuthToken(cookie: $cookie)
}
`;
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { gql } from '@apollo/client';

export const GET_SESSION_TOKEN = gql`
query GetSessionToken($id: String!, $password: String!) {
mutation GetSessionToken($id: String!, $password: String!) {
getSessionToken(id: $id, password: $password)
}
`;
47 changes: 0 additions & 47 deletions src/graphql/queries/__generated__/getAuthToken.generated.tsx

This file was deleted.

49 changes: 0 additions & 49 deletions src/graphql/queries/__generated__/getSessionToken.generated.tsx

This file was deleted.

26 changes: 13 additions & 13 deletions src/graphql/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,6 @@ export type Query = {
getChainTransactions?: Maybe<Array<Maybe<GetTransactionsType>>>;
getUtxos?: Maybe<Array<Maybe<GetUtxosType>>>;
getMessages?: Maybe<GetMessagesType>;
getAuthToken: Scalars['Boolean'];
getSessionToken: Scalars['String'];
getServerAccounts?: Maybe<Array<Maybe<ServerAccountType>>>;
getAccount?: Maybe<ServerAccountType>;
getLatestVersion?: Maybe<Scalars['String']>;
Expand Down Expand Up @@ -199,19 +197,10 @@ export type QueryGetMessagesArgs = {
lastMessage?: Maybe<Scalars['String']>;
};


export type QueryGetAuthTokenArgs = {
cookie?: Maybe<Scalars['String']>;
};


export type QueryGetSessionTokenArgs = {
id?: Maybe<Scalars['String']>;
password?: Maybe<Scalars['String']>;
};

export type Mutation = {
__typename?: 'Mutation';
getAuthToken: Scalars['Boolean'];
getSessionToken: Scalars['String'];
claimBoltzTransaction: Scalars['String'];
createBoltzReverseSwap: CreateBoltzReverseSwapType;
lnMarketsDeposit: Scalars['Boolean'];
Expand Down Expand Up @@ -244,6 +233,17 @@ export type Mutation = {
};


export type MutationGetAuthTokenArgs = {
cookie?: Maybe<Scalars['String']>;
};


export type MutationGetSessionTokenArgs = {
id?: Maybe<Scalars['String']>;
password?: Maybe<Scalars['String']>;
};


export type MutationClaimBoltzTransactionArgs = {
redeem: Scalars['String'];
transaction: Scalars['String'];
Expand Down
2 changes: 1 addition & 1 deletion src/utils/ssr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { initializeApollo } from 'config/client';
import { parseCookies } from 'src/utils/cookies';
import { DocumentNode } from 'graphql';
import { appConstants } from 'server/utils/appConstants';
import { GET_AUTH_TOKEN } from 'src/graphql/queries/getAuthToken';
import { GET_AUTH_TOKEN } from 'src/graphql/mutations/getAuthToken';

const cookieProps = (
context: NextPageContext,
Expand Down
6 changes: 3 additions & 3 deletions src/views/homepage/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { toast } from 'react-toastify';
import styled from 'styled-components';
import { useRouter } from 'next/router';
import { appendBasePath } from 'src/utils/basePath';
import { useGetSessionTokenLazyQuery } from 'src/graphql/queries/__generated__/getSessionToken.generated';
import { getErrorContent } from 'src/utils/error';
import { Lock } from 'react-feather';
import { ServerAccountType } from 'src/graphql/types';
import { getVersion } from 'src/utils/version';
import { useGetSessionTokenMutation } from 'src/graphql/mutations/__generated__/getSessionToken.generated';
import { SingleLine, Sub4Title, Card } from '../../components/generic/Styled';
import { ColorButton } from '../../components/buttons/colorButton/ColorButton';
import { Input } from '../../components/input';
Expand Down Expand Up @@ -41,8 +41,8 @@ export const Login = ({ account }: LoginProps) => {

const [pass, setPass] = useState('');

const [getSessionToken, { data, loading }] = useGetSessionTokenLazyQuery({
fetchPolicy: 'network-only',
const [getSessionToken, { data, loading }] = useGetSessionTokenMutation({
refetchQueries: ['GetNodeInfo'],
onError: err => {
toast.error(getErrorContent(err));
},
Expand Down

0 comments on commit 18911fd

Please sign in to comment.