style: auto format whole project
This commit is contained in:
@@ -7,7 +7,7 @@ interface IRef {
|
||||
const cache = new InMemoryCache({
|
||||
typePolicies: {
|
||||
App: {
|
||||
keyFields: ['key']
|
||||
keyFields: ['key'],
|
||||
},
|
||||
Mutation: {
|
||||
mutationType: true,
|
||||
@@ -24,9 +24,11 @@ const cache = new InMemoryCache({
|
||||
id: appCacheId,
|
||||
fields: {
|
||||
connections: (existingConnections) => {
|
||||
const existingConnectionIndex = existingConnections.findIndex((connection: IRef) => {
|
||||
return connection.__ref === verifiedConnection.__ref;
|
||||
});
|
||||
const existingConnectionIndex = existingConnections.findIndex(
|
||||
(connection: IRef) => {
|
||||
return connection.__ref === verifiedConnection.__ref;
|
||||
}
|
||||
);
|
||||
const connectionExists = existingConnectionIndex !== -1;
|
||||
|
||||
// newly created and verified connection
|
||||
@@ -35,16 +37,16 @@ const cache = new InMemoryCache({
|
||||
}
|
||||
|
||||
return existingConnections;
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
return verifiedConnection;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export default cache;
|
||||
|
@@ -14,17 +14,19 @@ const client = new ApolloClient({
|
||||
defaultOptions: {
|
||||
watchQuery: {
|
||||
fetchPolicy: 'cache-and-network',
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export function mutateAndGetClient(options: CreateClientOptions): typeof client {
|
||||
export function mutateAndGetClient(
|
||||
options: CreateClientOptions
|
||||
): typeof client {
|
||||
const { onError, token } = options;
|
||||
const link = createLink({ uri: appConfig.graphqlUrl, token, onError });
|
||||
|
||||
client.setLink(link);
|
||||
|
||||
return client;
|
||||
};
|
||||
}
|
||||
|
||||
export default client;
|
||||
|
@@ -11,52 +11,51 @@ type CreateLinkOptions = {
|
||||
onError?: (message: string) => void;
|
||||
};
|
||||
|
||||
const createHttpLink = (options: Pick<CreateLinkOptions, 'uri' | 'token'>): ApolloLink => {
|
||||
const createHttpLink = (
|
||||
options: Pick<CreateLinkOptions, 'uri' | 'token'>
|
||||
): ApolloLink => {
|
||||
const { uri, token } = options;
|
||||
const headers = {
|
||||
authorization: token,
|
||||
};
|
||||
return new HttpLink({ uri, headers });
|
||||
}
|
||||
};
|
||||
|
||||
const NOT_AUTHORISED = 'Not Authorised!';
|
||||
const createErrorLink = (callback: CreateLinkOptions['onError']): ApolloLink => onError(({ graphQLErrors, networkError, operation }) => {
|
||||
const context = operation.getContext();
|
||||
const autoSnackbar = context.autoSnackbar ?? true;
|
||||
const createErrorLink = (callback: CreateLinkOptions['onError']): ApolloLink =>
|
||||
onError(({ graphQLErrors, networkError, operation }) => {
|
||||
const context = operation.getContext();
|
||||
const autoSnackbar = context.autoSnackbar ?? true;
|
||||
|
||||
if (graphQLErrors)
|
||||
graphQLErrors.forEach(({ message, locations, path }) => {
|
||||
if (graphQLErrors)
|
||||
graphQLErrors.forEach(({ message, locations, path }) => {
|
||||
if (autoSnackbar) {
|
||||
callback?.(message);
|
||||
}
|
||||
|
||||
console.log(
|
||||
`[GraphQL error]: Message: ${message}, Location: ${locations}, Path: ${path}`
|
||||
);
|
||||
|
||||
if (message === NOT_AUTHORISED) {
|
||||
setItem('token', '');
|
||||
window.location.href = URLS.LOGIN;
|
||||
}
|
||||
});
|
||||
|
||||
if (networkError) {
|
||||
if (autoSnackbar) {
|
||||
callback?.(message);
|
||||
callback?.(networkError.toString());
|
||||
}
|
||||
|
||||
console.log(
|
||||
`[GraphQL error]: Message: ${message}, Location: ${locations}, Path: ${path}`,
|
||||
);
|
||||
|
||||
if (message === NOT_AUTHORISED) {
|
||||
setItem('token', '');
|
||||
window.location.href = URLS.LOGIN;
|
||||
}
|
||||
});
|
||||
|
||||
if (networkError) {
|
||||
if (autoSnackbar) {
|
||||
callback?.(networkError.toString())
|
||||
console.log(`[Network error]: ${networkError}`);
|
||||
}
|
||||
console.log(`[Network error]: ${networkError}`);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
||||
const noop = () => { };
|
||||
const noop = () => {};
|
||||
|
||||
const createLink = (options: CreateLinkOptions): ApolloLink => {
|
||||
const {
|
||||
uri,
|
||||
onError = noop,
|
||||
token,
|
||||
} = options;
|
||||
const { uri, onError = noop, token } = options;
|
||||
|
||||
const httpOptions = { uri, token };
|
||||
|
||||
|
@@ -1,9 +1,7 @@
|
||||
import { gql } from '@apollo/client';
|
||||
|
||||
export const CREATE_CONNECTION = gql`
|
||||
mutation CreateConnection(
|
||||
$input: CreateConnectionInput
|
||||
) {
|
||||
mutation CreateConnection($input: CreateConnectionInput) {
|
||||
createConnection(input: $input) {
|
||||
id
|
||||
key
|
||||
|
@@ -6,8 +6,8 @@ import { DELETE_CONNECTION } from './delete-connection';
|
||||
import { CREATE_AUTH_DATA } from './create-auth-data';
|
||||
|
||||
type Mutations = {
|
||||
[key: string]: any,
|
||||
}
|
||||
[key: string]: any;
|
||||
};
|
||||
|
||||
const mutations: Mutations = {
|
||||
createConnection: CREATE_CONNECTION,
|
||||
|
@@ -1,10 +1,12 @@
|
||||
import type { FieldPolicy, Reference } from '@apollo/client';
|
||||
|
||||
type KeyArgs = FieldPolicy<unknown>["keyArgs"];
|
||||
type KeyArgs = FieldPolicy<unknown>['keyArgs'];
|
||||
|
||||
export type TEdge<TNode> = {
|
||||
node: TNode;
|
||||
} | Reference;
|
||||
export type TEdge<TNode> =
|
||||
| {
|
||||
node: TNode;
|
||||
}
|
||||
| Reference;
|
||||
|
||||
export type TPageInfo = {
|
||||
currentPage: number;
|
||||
@@ -27,7 +29,6 @@ export type CustomFieldPolicy<TNode> = FieldPolicy<
|
||||
TIncoming<TNode> | null
|
||||
>;
|
||||
|
||||
|
||||
const makeEmptyData = <TNode>(): TExisting<TNode> => {
|
||||
return {
|
||||
edges: [],
|
||||
@@ -51,8 +52,7 @@ function offsetLimitPagination<TNode = Reference>(
|
||||
if (!incoming || incoming === null) return existing;
|
||||
|
||||
const existingEdges = existing?.edges || [];
|
||||
const incomingEdges = incoming.edges || []
|
||||
|
||||
const incomingEdges = incoming.edges || [];
|
||||
|
||||
if (args) {
|
||||
const newEdges = [...existingEdges, ...incomingEdges];
|
||||
|
@@ -1,8 +1,16 @@
|
||||
import { gql } from '@apollo/client';
|
||||
|
||||
export const GET_APPS = gql`
|
||||
query GetApps($name: String, $onlyWithTriggers: Boolean, $onlyWithActions: Boolean) {
|
||||
getApps(name: $name, onlyWithTriggers: $onlyWithTriggers, onlyWithActions: $onlyWithActions) {
|
||||
query GetApps(
|
||||
$name: String
|
||||
$onlyWithTriggers: Boolean
|
||||
$onlyWithActions: Boolean
|
||||
) {
|
||||
getApps(
|
||||
name: $name
|
||||
onlyWithTriggers: $onlyWithTriggers
|
||||
onlyWithActions: $onlyWithActions
|
||||
) {
|
||||
name
|
||||
key
|
||||
iconUrl
|
||||
|
@@ -13,4 +13,4 @@ export const GET_CONNECTED_APPS = gql`
|
||||
supportsConnections
|
||||
}
|
||||
}
|
||||
`;
|
||||
`;
|
||||
|
@@ -2,7 +2,11 @@ import { gql } from '@apollo/client';
|
||||
|
||||
export const GET_EXECUTION_STEPS = gql`
|
||||
query GetExecutionSteps($executionId: String!, $limit: Int!, $offset: Int!) {
|
||||
getExecutionSteps(executionId: $executionId, limit: $limit, offset: $offset) {
|
||||
getExecutionSteps(
|
||||
executionId: $executionId
|
||||
limit: $limit
|
||||
offset: $offset
|
||||
) {
|
||||
pageInfo {
|
||||
currentPage
|
||||
totalPages
|
||||
|
@@ -1,8 +1,20 @@
|
||||
import { gql } from '@apollo/client';
|
||||
|
||||
export const GET_FLOWS = gql`
|
||||
query GetFlows($limit: Int!, $offset: Int!, $appKey: String, $connectionId: String, $name: String) {
|
||||
getFlows(limit: $limit, offset: $offset, appKey: $appKey, connectionId: $connectionId, name: $name) {
|
||||
query GetFlows(
|
||||
$limit: Int!
|
||||
$offset: Int!
|
||||
$appKey: String
|
||||
$connectionId: String
|
||||
$name: String
|
||||
) {
|
||||
getFlows(
|
||||
limit: $limit
|
||||
offset: $offset
|
||||
appKey: $appKey
|
||||
connectionId: $connectionId
|
||||
name: $name
|
||||
) {
|
||||
pageInfo {
|
||||
currentPage
|
||||
totalPages
|
||||
|
Reference in New Issue
Block a user