Skip to content

Commit

Permalink
Simplify file structure
Browse files Browse the repository at this point in the history
  • Loading branch information
kmcginnes committed May 10, 2024
1 parent 5546cac commit abdb822
Show file tree
Hide file tree
Showing 12 changed files with 39 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import keywordSearch from "./queries/keywordSearch";
import { fetchDatabaseRequest } from "../fetchDatabaseRequest";
import { GraphSummary } from "./types";
import { v4 } from "uuid";
import { Explorer } from "../../core/ConnectorProvider/types";
import { Explorer } from "../useGEFetchTypes";

function _gremlinFetch(connection: ConnectionConfig, options: any) {
return async (queryTemplate: string) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { GraphSummary } from "./types";
import { fetchDatabaseRequest } from "../fetchDatabaseRequest";
import { ConnectionConfig } from "../../core";
import { DEFAULT_SERVICE_TYPE } from "../../utils/constants";
import { Explorer } from "../../core/ConnectorProvider/types";
import { Explorer } from "../useGEFetchTypes";

function _openCypherFetch(connection: ConnectionConfig, options: any) {
return async (queryTemplate: string) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/graph-explorer/src/connector/sparql/useSPARQL.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type {
Criterion,
Explorer,
KeywordSearchRequest,
KeywordSearchResponse,
NeighborsResponse,
Expand All @@ -21,7 +22,6 @@ import {
} from "./types";
import { ConnectionConfig } from "../../core";
import { v4 } from "uuid";
import { Explorer } from "../../core/ConnectorProvider/types";

const replaceBlankNodeFromSearch = (
blankNodes: BlankNodesMap,
Expand Down
24 changes: 24 additions & 0 deletions packages/graph-explorer/src/connector/useGEFetchTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,3 +201,27 @@ export type ConfigurationWithConnection = Omit<
"connection"
> &
Required<Pick<ConfigurationContextProps, "connection">>;

/**
* Abstracted interface to the common database queries used by
* Graph Explorer.
*/
export type Explorer = {
fetchSchema: (options?: any) => Promise<SchemaResponse>;
fetchVertexCountsByType: (
req: CountsByTypeRequest,
options?: any
) => Promise<CountsByTypeResponse>;
fetchNeighbors: (
req: NeighborsRequest,
options?: any
) => Promise<NeighborsResponse>;
fetchNeighborsCount: (
req: NeighborsCountRequest,
options?: any
) => Promise<NeighborsCountResponse>;
keywordSearch: (
req: KeywordSearchRequest,
options?: any
) => Promise<KeywordSearchResponse>;
};
31 changes: 0 additions & 31 deletions packages/graph-explorer/src/core/ConnectorProvider/types.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { every, isEqual } from "lodash";
import LoggerConnector from "../../connector/LoggerConnector";
import { createGremlinExplorer } from "../../connector/gremlin/useGremlin";
import { createOpenCypherExplorer } from "../../connector/openCypher/useOpenCypher";
import { createSparqlExplorer } from "../../connector/sparql/useSPARQL";
import { mergedConfigurationSelector } from "../StateProvider/configuration";
import LoggerConnector from "../connector/LoggerConnector";
import { createGremlinExplorer } from "../connector/gremlin/useGremlin";
import { createOpenCypherExplorer } from "../connector/openCypher/useOpenCypher";
import { createSparqlExplorer } from "../connector/sparql/useSPARQL";
import { mergedConfigurationSelector } from "./StateProvider/configuration";
import { selector } from "recoil";
import { equalSelector } from "../../utils/recoilState";
import { equalSelector } from "../utils/recoilState";

/**
* Active connection where the value will only change when one of the
Expand Down
2 changes: 1 addition & 1 deletion packages/graph-explorer/src/hooks/useExpandNode.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useCallback } from "react";
import { useNotification } from "../components/NotificationProvider";
import type { NeighborsRequest } from "../connector/useGEFetchTypes";
import { explorerSelector } from "../core/ConnectorProvider/connector";
import { explorerSelector } from "../core/connector";
import useEntities from "./useEntities";
import { Vertex } from "../@types/entities";
import { useRecoilValue } from "recoil";
Expand Down
2 changes: 1 addition & 1 deletion packages/graph-explorer/src/hooks/useFetchNode.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useCallback } from "react";
import { Vertex } from "../@types/entities";
import { explorerSelector } from "../core/ConnectorProvider/connector";
import { explorerSelector } from "../core/connector";
import useEntities from "./useEntities";
import { NeighborsCountRequest } from "../connector/useGEFetchTypes";
import { useRecoilValue } from "recoil";
Expand Down
5 changes: 1 addition & 4 deletions packages/graph-explorer/src/hooks/useSchemaSync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ import { useCallback, useRef } from "react";
import { useNotification } from "../components/NotificationProvider";
import type { SchemaResponse } from "../connector/useGEFetchTypes";
import useConfiguration from "../core/ConfigurationProvider/useConfiguration";
import {
explorerSelector,
loggerSelector,
} from "../core/ConnectorProvider/connector";
import { explorerSelector, loggerSelector } from "../core/connector";
import usePrefixesUpdater from "./usePrefixesUpdater";
import useUpdateSchema from "./useUpdateSchema";
import { createDisplayError } from "../utils/createDisplayError";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useEffect, useMemo } from "react";
import { useQuery } from "@tanstack/react-query";
import { useConfiguration } from "../core";
import { explorerSelector } from "../core/ConnectorProvider/connector";
import { explorerSelector } from "../core/connector";
import useUpdateSchema from "./useUpdateSchema";
import { useRecoilValue } from "recoil";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useQuery, useQueryClient } from "@tanstack/react-query";
import { useNotification } from "../../components/NotificationProvider";
import { useConfiguration } from "../../core";
import { explorerSelector } from "../../core/ConnectorProvider/connector";
import { explorerSelector } from "../../core/connector";
import usePrefixesUpdater from "../../hooks/usePrefixesUpdater";
import { useCallback, useEffect, useMemo } from "react";
import { createDisplayError } from "../../utils/createDisplayError";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import {
useWithTheme,
withClassNamePrefix,
} from "../../core";
import { explorerSelector } from "../../core/ConnectorProvider/connector";
import { explorerSelector } from "../../core/connector";
import {
userStylingAtom,
VertexPreferences,
Expand Down

0 comments on commit abdb822

Please sign in to comment.