Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove workspacetables type #590

Merged
merged 3 commits into from
Aug 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions grai-frontend/__generated__/globalTypes.ts

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

4 changes: 2 additions & 2 deletions grai-frontend/src/components/home/HomeCards.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ test("renders", async () => {
filtered: 38,
},
},
tables: {
nodes: {
meta: {
total: 2,
filtered: 2,
},
},
connections: {
Expand Down
6 changes: 3 additions & 3 deletions grai-frontend/src/components/home/HomeCards.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ export const GET_COUNTS = gql`
filtered
}
}
tables {
nodes(filters: { node_type: { equals: "Table" } }) {
meta {
total
filtered
}
}
connections {
Expand Down Expand Up @@ -51,7 +51,7 @@ const HomeCards: React.FC = () => {
{error && <GraphError error={error} />}
<Grid item md={3}>
<HomeCard
count={data?.workspace.tables.meta.total}
count={data?.workspace.nodes.meta.filtered}
text="Tables"
color="#8338EC"
to="tables"
Expand Down
12 changes: 6 additions & 6 deletions grai-frontend/src/components/home/__generated__/GetCountsHome.ts

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

4 changes: 2 additions & 2 deletions grai-frontend/src/components/tables/TableEvents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const GET_TABLE_EVENTS = gql`
) {
workspace(organisationName: $organisationName, name: $workspaceName) {
id
table(id: $tableId) {
node(id: $tableId) {
id
events {
data {
Expand Down Expand Up @@ -72,7 +72,7 @@ const TableEvents: React.FC<TableEventsProps> = ({ table, responsive }) => {
if (error) return <GraphError error={error} />
if (loading) return <Loading />

const tableData = data?.workspace?.table
const tableData = data?.workspace?.node

if (!tableData) return <NotFound />

Expand Down
26 changes: 13 additions & 13 deletions grai-frontend/src/components/tables/__generated__/GetTableEvents.ts

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

4 changes: 2 additions & 2 deletions grai-frontend/src/pages/Home.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,9 @@ test("no reports", async () => {
filtered: 0,
},
},
tables: {
nodes: {
meta: {
total: 0,
filtered: 0,
},
},
connections: {
Expand Down
6 changes: 3 additions & 3 deletions grai-frontend/src/pages/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ export const GET_WORKSPACE = gql`
filtered
}
}
tables {
nodes(filters: { node_type: { equals: "Table" } }) {
meta {
total
filtered
}
}
connections {
Expand Down Expand Up @@ -88,7 +88,7 @@ const Home: React.FC = () => {
<WelcomeCard search={search} setSearch={setSearch} />
<HomeCards />
{workspace.connections.meta.total === 0 &&
workspace.tables.meta.total === 0 && <GettingStarted />}
workspace.nodes.meta.filtered === 0 && <GettingStarted />}
<ReportsCard />
<SourceGraph workspaceId={workspace.id} />
</Box>
Expand Down
12 changes: 6 additions & 6 deletions grai-frontend/src/pages/__generated__/GetWorkspaceHome.ts

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

2 changes: 1 addition & 1 deletion grai-frontend/src/pages/edges/Edges.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const GET_EDGES = gql`
edges(
pagination: { limit: 20, offset: $offset }
search: $search
filter: $filter
filters: $filter
) {
data {
id
Expand Down
2 changes: 1 addition & 1 deletion grai-frontend/src/pages/nodes/Nodes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const GET_NODES = gql`
nodes(
pagination: { limit: 20, offset: $offset }
search: $search
filter: $filter
filters: $filter
order: $order
) {
data {
Expand Down
14 changes: 12 additions & 2 deletions grai-frontend/src/testing/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@
"defaultValue": null
},
{
"name": "filter",
"name": "filters",
"description": null,
"type": {
"kind": "INPUT_OBJECT",
Expand Down Expand Up @@ -359,7 +359,7 @@
"defaultValue": null
},
{
"name": "filter",
"name": "filters",
"description": null,
"type": {
"kind": "INPUT_OBJECT",
Expand Down Expand Up @@ -1526,6 +1526,16 @@
},
"defaultValue": null
},
{
"name": "metadata__grai__node_type",
"description": null,
"type": {
"kind": "ENUM",
"name": "Ordering",
"ofType": null
},
"defaultValue": null
},
{
"name": "is_active",
"description": null,
Expand Down
8 changes: 4 additions & 4 deletions grai-server/app/api/tests/test_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ async def test_nodes_filter_node_type_equals(test_context):
query Workspace($workspaceId: ID!, $filter: WorkspaceNodeFilter) {
workspace(id: $workspaceId) {
id
nodes(filter: $filter) {
nodes(filters: $filter) {
data{
id
}
Expand Down Expand Up @@ -366,7 +366,7 @@ async def test_nodes_filter_node_type_contains(test_context):
query Workspace($workspaceId: ID!, $filter: WorkspaceNodeFilter) {
workspace(id: $workspaceId) {
id
nodes(filter: $filter) {
nodes(filters: $filter) {
data{
id
}
Expand Down Expand Up @@ -737,7 +737,7 @@ async def test_edges_filter_edge_type_equals(test_context):
query Workspace($workspaceId: ID!, $filter: WorkspaceEdgeFilter) {
workspace(id: $workspaceId) {
id
edges(filter: $filter) {
edges(filters: $filter) {
data{
id
}
Expand Down Expand Up @@ -784,7 +784,7 @@ async def test_edges_filter_edge_type_contains(test_context):
query Workspace($workspaceId: ID!, $filter: WorkspaceEdgeFilter) {
workspace(id: $workspaceId) {
id
edges(filter: $filter) {
edges(filters: $filter) {
data{
id
}
Expand Down
28 changes: 14 additions & 14 deletions grai-server/app/api/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ def nodes(
self,
pagination: Optional[OffsetPaginationInput] = strawberry.UNSET,
search: Optional[str] = strawberry.UNSET,
filter: Optional[WorkspaceNodeFilter] = strawberry.UNSET,
filters: Optional[WorkspaceNodeFilter] = strawberry.UNSET,
order: Optional[NodeOrder] = strawberry.UNSET,
) -> Pagination["Node"]:
queryset = NodeModel.objects.filter(workspace=self)
Expand All @@ -561,12 +561,12 @@ def nodes(
Q(id__icontains=search) | Q(name__icontains=search) | Q(display_name__icontains=search)
)

if filter:
if filter.node_type:
if filter.node_type.equals:
queryset = queryset.filter(metadata__grai__node_type=filter.node_type.equals)
if filter.node_type.contains:
queryset = queryset.filter(metadata__grai__node_type__in=filter.node_type.contains)
if filters:
if filters.node_type:
if filters.node_type.equals:
queryset = queryset.filter(metadata__grai__node_type=filters.node_type.equals)
if filters.node_type.contains:
queryset = queryset.filter(metadata__grai__node_type__in=filters.node_type.contains)

return Pagination[Node](queryset=queryset, pagination=pagination, order=order)

Expand All @@ -583,7 +583,7 @@ def edges(
self,
pagination: Optional[OffsetPaginationInput] = strawberry.UNSET,
search: Optional[str] = strawberry.UNSET,
filter: Optional[WorkspaceEdgeFilter] = strawberry.UNSET,
filters: Optional[WorkspaceEdgeFilter] = strawberry.UNSET,
) -> Pagination["Edge"]:
queryset = EdgeModel.objects.filter(workspace=self)

Expand All @@ -595,12 +595,12 @@ def edges(
| Q(source__name__icontains=search)
)

if filter:
if filter.edge_type:
if filter.edge_type.equals:
queryset = queryset.filter(metadata__grai__edge_type=filter.edge_type.equals)
if filter.edge_type.contains:
queryset = queryset.filter(metadata__grai__edge_type__in=filter.edge_type.contains)
if filters:
if filters.edge_type:
if filters.edge_type.equals:
queryset = queryset.filter(metadata__grai__edge_type=filters.edge_type.equals)
if filters.edge_type.contains:
queryset = queryset.filter(metadata__grai__edge_type__in=filters.edge_type.contains)

return Pagination[Edge](queryset=queryset, pagination=pagination)

Expand Down
Loading