diff --git a/react-app/components/graphiql.tsx b/react-app/components/graphiql.tsx index e2e3ec6..578bb8a 100644 --- a/react-app/components/graphiql.tsx +++ b/react-app/components/graphiql.tsx @@ -13,7 +13,6 @@ import { import { useStoreState } from "../store" import { useState } from "react" -// TODO: Change this to be dynamic or take UI input const HASURA_ENDPOINT = process.env.NEXT_PUBLIC_HASURA_URL ? process.env.NEXT_PUBLIC_HASURA_URL + "/v1/graphql" : "http://localhost:8085/v1/graphql" diff --git a/react-app/components/react-table.tsx b/react-app/components/react-table.tsx new file mode 100644 index 0000000..7276c5d --- /dev/null +++ b/react-app/components/react-table.tsx @@ -0,0 +1,109 @@ +// import { useMemo } from "react" +// import { useTable, Column } from "react-table" + +// export function ReactTable() { +// const data = useMemo( +// () => [ +// { +// currency: "EUR", +// amount: 10000, +// date: "2020-01-01", +// }, +// { +// currency: "EUR", +// amount: 11000, +// date: "2020-02-01", +// }, +// { +// currency: "GBP", +// amount: 12000, +// date: "2020-01-01", +// }, +// ], +// [] +// ) + +// const columns: Column[] = useMemo( +// () => [ +// { +// Header: "Currency", +// accessor: "currency", +// }, +// { +// Header: "Amount", +// accessor: "amount", +// }, +// { +// Header: "Date", +// accessor: "date", +// }, +// ], +// [] +// ) + +// const table = useTable({ columns, data }) + +// const Header = () => ( +// +// {table.headerGroups.map(headerGroup => ( +// +// {headerGroup.headers.map(column => ( +// +// {column.render("Header")} +// +// ))} +// +// ))} +// +// ) + +// const Body = () => ( +// +// {table.rows.map(row => { +// table.prepareRow(row) +// return ( +// +// {row.cells.map(cell => ( +// +//
+//
+//
+// {cell.render("Cell")} +//
+//
+//
+// +// ))} +// +// ) +// })} +// +// ) + +// return ( +//
+//
+//
+//
+// +//
+// +//
+//
+//
+//
+//
+// ) +// } diff --git a/react-app/generated-gql-client/guards.esm.js b/react-app/generated-gql-client/guards.esm.js index 9342d31..55bbd10 100644 --- a/react-app/generated-gql-client/guards.esm.js +++ b/react-app/generated-gql-client/guards.esm.js @@ -191,7 +191,7 @@ export var isEventTriggerDefinition = function(obj) { -var OperationSpec_possibleTypes = ['OperationSpec'] +var OperationSpec_possibleTypes = ['OperationSpecAllColumns','OperationSpecIndividualColumns'] export var isOperationSpec = function(obj) { if (!obj || !obj.__typename) throw new Error('__typename is missing in "isOperationSpec"') return OperationSpec_possibleTypes.includes(obj.__typename) @@ -199,6 +199,22 @@ export var isOperationSpec = function(obj) { +var OperationSpecAllColumns_possibleTypes = ['OperationSpecAllColumns'] +export var isOperationSpecAllColumns = function(obj) { + if (!obj || !obj.__typename) throw new Error('__typename is missing in "isOperationSpecAllColumns"') + return OperationSpecAllColumns_possibleTypes.includes(obj.__typename) +} + + + +var OperationSpecIndividualColumns_possibleTypes = ['OperationSpecIndividualColumns'] +export var isOperationSpecIndividualColumns = function(obj) { + if (!obj || !obj.__typename) throw new Error('__typename is missing in "isOperationSpecIndividualColumns"') + return OperationSpecIndividualColumns_possibleTypes.includes(obj.__typename) +} + + + var RetryConf_possibleTypes = ['RetryConf'] export var isRetryConf = function(obj) { if (!obj || !obj.__typename) throw new Error('__typename is missing in "isRetryConf"') diff --git a/react-app/generated-gql-client/schema.graphql b/react-app/generated-gql-client/schema.graphql index 56f1266..31dff44 100644 --- a/react-app/generated-gql-client/schema.graphql +++ b/react-app/generated-gql-client/schema.graphql @@ -188,9 +188,16 @@ type EventTriggerDefinition { update: OperationSpec } -type OperationSpec { +union OperationSpec = OperationSpecAllColumns | OperationSpecIndividualColumns + +type OperationSpecAllColumns { + columns: String! + payload: [String!] +} + +type OperationSpecIndividualColumns { columns: [String!]! - payload: [String] + payload: [String!] } type RetryConf { diff --git a/react-app/generated-gql-client/schema.ts b/react-app/generated-gql-client/schema.ts index 948216c..0199c0e 100644 --- a/react-app/generated-gql-client/schema.ts +++ b/react-app/generated-gql-client/schema.ts @@ -206,10 +206,18 @@ export interface EventTriggerDefinition { __typename?: 'EventTriggerDefinition' } -export interface OperationSpec { +export type OperationSpec = (OperationSpecAllColumns | OperationSpecIndividualColumns) & { __isUnion?: true } + +export interface OperationSpecAllColumns { + columns: Scalars['String'] + payload?: Scalars['String'][] + __typename?: 'OperationSpecAllColumns' +} + +export interface OperationSpecIndividualColumns { columns: Scalars['String'][] - payload?: (Scalars['String'] | undefined)[] - __typename?: 'OperationSpec' + payload?: Scalars['String'][] + __typename?: 'OperationSpecIndividualColumns' } export interface RetryConf { @@ -719,7 +727,16 @@ export interface EventTriggerDefinitionRequest{ __scalar?: boolean | number } -export interface OperationSpecRequest{ +export interface OperationSpecRequest{on_OperationSpecAllColumns?:OperationSpecAllColumnsRequest,on_OperationSpecIndividualColumns?:OperationSpecIndividualColumnsRequest,__typename?:boolean | number} + +export interface OperationSpecAllColumnsRequest{ + columns?: boolean | number + payload?: boolean | number + __typename?: boolean | number + __scalar?: boolean | number +} + +export interface OperationSpecIndividualColumnsRequest{ columns?: boolean | number payload?: boolean | number __typename?: boolean | number @@ -1236,7 +1253,7 @@ export const isEventTriggerDefinition = (obj?: { __typename?: any } | null): obj -const OperationSpec_possibleTypes = ['OperationSpec'] +const OperationSpec_possibleTypes = ['OperationSpecAllColumns','OperationSpecIndividualColumns'] export const isOperationSpec = (obj?: { __typename?: any } | null): obj is OperationSpec => { if (!obj?.__typename) throw new Error('__typename is missing in "isOperationSpec"') return OperationSpec_possibleTypes.includes(obj.__typename) @@ -1244,6 +1261,22 @@ export const isOperationSpec = (obj?: { __typename?: any } | null): obj is Opera +const OperationSpecAllColumns_possibleTypes = ['OperationSpecAllColumns'] +export const isOperationSpecAllColumns = (obj?: { __typename?: any } | null): obj is OperationSpecAllColumns => { + if (!obj?.__typename) throw new Error('__typename is missing in "isOperationSpecAllColumns"') + return OperationSpecAllColumns_possibleTypes.includes(obj.__typename) +} + + + +const OperationSpecIndividualColumns_possibleTypes = ['OperationSpecIndividualColumns'] +export const isOperationSpecIndividualColumns = (obj?: { __typename?: any } | null): obj is OperationSpecIndividualColumns => { + if (!obj?.__typename) throw new Error('__typename is missing in "isOperationSpecIndividualColumns"') + return OperationSpecIndividualColumns_possibleTypes.includes(obj.__typename) +} + + + const RetryConf_possibleTypes = ['RetryConf'] export const isRetryConf = (obj?: { __typename?: any } | null): obj is RetryConf => { if (!obj?.__typename) throw new Error('__typename is missing in "isRetryConf"') @@ -1903,26 +1936,36 @@ export interface EventTriggerObservableChain{ export interface EventTriggerDefinitionPromiseChain{ enable_manual: ({get: (request?: boolean|number, defaultValue?: Scalars['Boolean']) => Promise}), - insert: (OperationSpecPromiseChain & {get: (request: R, defaultValue?: (FieldsSelection | undefined)) => Promise<(FieldsSelection | undefined)>}), - delete: (OperationSpecPromiseChain & {get: (request: R, defaultValue?: (FieldsSelection | undefined)) => Promise<(FieldsSelection | undefined)>}), - update: (OperationSpecPromiseChain & {get: (request: R, defaultValue?: (FieldsSelection | undefined)) => Promise<(FieldsSelection | undefined)>}) + insert: ({get: (request: R, defaultValue?: (FieldsSelection | undefined)) => Promise<(FieldsSelection | undefined)>}), + delete: ({get: (request: R, defaultValue?: (FieldsSelection | undefined)) => Promise<(FieldsSelection | undefined)>}), + update: ({get: (request: R, defaultValue?: (FieldsSelection | undefined)) => Promise<(FieldsSelection | undefined)>}) } export interface EventTriggerDefinitionObservableChain{ enable_manual: ({get: (request?: boolean|number, defaultValue?: Scalars['Boolean']) => Observable}), - insert: (OperationSpecObservableChain & {get: (request: R, defaultValue?: (FieldsSelection | undefined)) => Observable<(FieldsSelection | undefined)>}), - delete: (OperationSpecObservableChain & {get: (request: R, defaultValue?: (FieldsSelection | undefined)) => Observable<(FieldsSelection | undefined)>}), - update: (OperationSpecObservableChain & {get: (request: R, defaultValue?: (FieldsSelection | undefined)) => Observable<(FieldsSelection | undefined)>}) + insert: ({get: (request: R, defaultValue?: (FieldsSelection | undefined)) => Observable<(FieldsSelection | undefined)>}), + delete: ({get: (request: R, defaultValue?: (FieldsSelection | undefined)) => Observable<(FieldsSelection | undefined)>}), + update: ({get: (request: R, defaultValue?: (FieldsSelection | undefined)) => Observable<(FieldsSelection | undefined)>}) +} + +export interface OperationSpecAllColumnsPromiseChain{ + columns: ({get: (request?: boolean|number, defaultValue?: Scalars['String']) => Promise}), + payload: ({get: (request?: boolean|number, defaultValue?: (Scalars['String'][] | undefined)) => Promise<(Scalars['String'][] | undefined)>}) +} + +export interface OperationSpecAllColumnsObservableChain{ + columns: ({get: (request?: boolean|number, defaultValue?: Scalars['String']) => Observable}), + payload: ({get: (request?: boolean|number, defaultValue?: (Scalars['String'][] | undefined)) => Observable<(Scalars['String'][] | undefined)>}) } -export interface OperationSpecPromiseChain{ +export interface OperationSpecIndividualColumnsPromiseChain{ columns: ({get: (request?: boolean|number, defaultValue?: Scalars['String'][]) => Promise}), - payload: ({get: (request?: boolean|number, defaultValue?: ((Scalars['String'] | undefined)[] | undefined)) => Promise<((Scalars['String'] | undefined)[] | undefined)>}) + payload: ({get: (request?: boolean|number, defaultValue?: (Scalars['String'][] | undefined)) => Promise<(Scalars['String'][] | undefined)>}) } -export interface OperationSpecObservableChain{ +export interface OperationSpecIndividualColumnsObservableChain{ columns: ({get: (request?: boolean|number, defaultValue?: Scalars['String'][]) => Observable}), - payload: ({get: (request?: boolean|number, defaultValue?: ((Scalars['String'] | undefined)[] | undefined)) => Observable<((Scalars['String'] | undefined)[] | undefined)>}) + payload: ({get: (request?: boolean|number, defaultValue?: (Scalars['String'][] | undefined)) => Observable<(Scalars['String'][] | undefined)>}) } export interface RetryConfPromiseChain{ diff --git a/react-app/generated-gql-client/types.esm.js b/react-app/generated-gql-client/types.esm.js index 2b3739f..2776114 100644 --- a/react-app/generated-gql-client/types.esm.js +++ b/react-app/generated-gql-client/types.esm.js @@ -5,8 +5,8 @@ export default { 5, 14, 16, - 70, - 71 + 72, + 73 ], "types": { "JSON": {}, @@ -220,22 +220,22 @@ export default { 18 ], "custom_types": [ - 51 + 53 ], "functions": [ - 60 + 62 ], "remote_schemas": [ - 62 + 64 ], "query_collections": [ - 64 + 66 ], "allowlist": [ - 67 + 69 ], "cron_triggers": [ - 68 + 70 ], "__typename": [ 5 @@ -256,28 +256,28 @@ export default { 27 ], "computed_fields": [ - 31 + 33 ], "object_relationships": [ - 34 + 36 ], "array_relationships": [ - 37 + 39 ], "remote_relationships": [ - 41 + 43 ], "insert_permissions": [ - 43 + 45 ], "select_permissions": [ - 45 + 47 ], "update_permissions": [ - 47 + 49 ], "delete_permissions": [ - 49 + 51 ], "__typename": [ 5 @@ -441,7 +441,7 @@ export default { 28 ], "retry_conf": [ - 30 + 32 ], "webhook": [ 5 @@ -474,6 +474,28 @@ export default { ] }, "OperationSpec": { + "on_OperationSpecAllColumns": [ + 30 + ], + "on_OperationSpecIndividualColumns": [ + 31 + ], + "__typename": [ + 5 + ] + }, + "OperationSpecAllColumns": { + "columns": [ + 5 + ], + "payload": [ + 5 + ], + "__typename": [ + 5 + ] + }, + "OperationSpecIndividualColumns": { "columns": [ 5 ], @@ -503,7 +525,7 @@ export default { 5 ], "definition": [ - 33 + 35 ], "comment": [ 5 @@ -525,7 +547,7 @@ export default { }, "ComputedFieldDefinition": { "function": [ - 32 + 34 ], "table_argument": [ 5 @@ -542,7 +564,7 @@ export default { 5 ], "using": [ - 35 + 37 ], "comment": [ 5 @@ -556,7 +578,7 @@ export default { 5 ], "manual_configuration": [ - 36 + 38 ], "__typename": [ 5 @@ -578,7 +600,7 @@ export default { 5 ], "using": [ - 38 + 40 ], "comment": [ 5 @@ -589,10 +611,10 @@ export default { }, "ArrRelUsing": { "foreign_key_constraint_on": [ - 39 + 41 ], "manual_configuration": [ - 40 + 42 ], "__typename": [ 5 @@ -625,7 +647,7 @@ export default { 5 ], "definition": [ - 42 + 44 ], "__typename": [ 5 @@ -650,7 +672,7 @@ export default { 5 ], "permission": [ - 44 + 46 ], "comment": [ 5 @@ -681,7 +703,7 @@ export default { 5 ], "permission": [ - 46 + 48 ], "comment": [ 5 @@ -715,7 +737,7 @@ export default { 5 ], "permission": [ - 48 + 50 ], "comment": [ 5 @@ -746,7 +768,7 @@ export default { 5 ], "permission": [ - 50 + 52 ], "comment": [ 5 @@ -765,16 +787,16 @@ export default { }, "CustomTypes": { "input_objects": [ - 52 + 54 ], "objects": [ - 54 + 56 ], "scalars": [ - 57 + 59 ], "enums": [ - 58 + 60 ], "__typename": [ 5 @@ -785,7 +807,7 @@ export default { 5 ], "fields": [ - 53 + 55 ], "description": [ 5 @@ -813,10 +835,10 @@ export default { 5 ], "fields": [ - 55 + 57 ], "relationships": [ - 56 + 58 ], "description": [ 5 @@ -872,7 +894,7 @@ export default { 5 ], "values": [ - 59 + 61 ], "description": [ 5 @@ -897,10 +919,10 @@ export default { }, "CustomFunction": { "function": [ - 32 + 34 ], "configuration": [ - 61 + 63 ], "__typename": [ 5 @@ -919,7 +941,7 @@ export default { 5 ], "definition": [ - 63 + 65 ], "comment": [ 5 @@ -953,7 +975,7 @@ export default { 5 ], "definition": [ - 65 + 67 ], "comment": [ 5 @@ -964,7 +986,7 @@ export default { }, "QueryCollectionDefinition": { "queries": [ - 66 + 68 ], "__typename": [ 5 @@ -1006,7 +1028,7 @@ export default { 24 ], "retry_conf": [ - 69 + 71 ], "include_in_metadata": [ 16 diff --git a/react-app/graphql-server-utils/schema.ts b/react-app/graphql-server-utils/schema.ts index e087178..dac99c4 100644 --- a/react-app/graphql-server-utils/schema.ts +++ b/react-app/graphql-server-utils/schema.ts @@ -194,9 +194,19 @@ export const typeDefs = gql` update: OperationSpec } - type OperationSpec { + # The "columns" value can either be "*" for "all columns", an array of strings for column names + union OperationSpec = OperationSpecAllColumns | OperationSpecIndividualColumns + + # Case when columns = "*" + type OperationSpecAllColumns { + columns: String! + payload: [String!] + } + + # Case when individual columns provided + type OperationSpecIndividualColumns { columns: [String!]! - payload: [String] + payload: [String!] } type RetryConf { diff --git a/react-app/package.json b/react-app/package.json index e26d3c6..ab0ab5c 100644 --- a/react-app/package.json +++ b/react-app/package.json @@ -32,6 +32,7 @@ "react-cool-dimensions": "^1.1.10", "react-dom": "17", "react-modal": "^3.11.2", + "react-table": "^7.6.2", "styled-components": "^5.2.0", "tailwindcss": "^1.9.5" }, @@ -39,6 +40,7 @@ "@genql/cli": "^2.3.3", "@types/lodash": "^4.14.162", "@types/react": "^16.9.53", + "@types/react-table": "^7.0.25", "prettier": "^2.1.2", "typescript": "^4.0.3" } diff --git a/react-app/pages/api/graphql.ts b/react-app/pages/api/graphql.ts index 5c5a7af..3f85734 100644 --- a/react-app/pages/api/graphql.ts +++ b/react-app/pages/api/graphql.ts @@ -15,13 +15,12 @@ import { getPrimaryKeys } from "../../graphql-server-utils/sql-queries/primary-k import { getTables } from "../../graphql-server-utils/sql-queries/tables.queries" import { getViews } from "../../graphql-server-utils/sql-queries/views.queries" -// TODO: Environment variable for endpoint or something const runMetadataQuery = createHasuraMetadataClient({ endpoint: process.env.NEXT_PUBLIC_HASURA_URL ? process.env.NEXT_PUBLIC_HASURA_URL + "/v1/query" : "http://localhost:8085/v1/query", headers: { - "X-Hasura-Admin-Secret": process.env.HASURA_ADMIN_SECRET || "mysecret", + "X-Hasura-Admin-Secret": process.env.NEXT_PUBLIC_HASURA_ADMIN_SECRET, }, }) diff --git a/react-app/pages/index.tsx b/react-app/pages/index.tsx index 67bfa3c..888d363 100644 --- a/react-app/pages/index.tsx +++ b/react-app/pages/index.tsx @@ -67,7 +67,7 @@ const DataModels = () => { if (!tableName.match(search)) return {} return { name: it.table.name, - comment: it.database_table?.comment || "lorem upsum", + comment: it.database_table?.comment, source: "Postgres", } })} diff --git a/react-app/react-table-config.d.ts b/react-app/react-table-config.d.ts new file mode 100644 index 0000000..c3809d7 --- /dev/null +++ b/react-app/react-table-config.d.ts @@ -0,0 +1,132 @@ +// See readme here: +// https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/react-table + +import { + UseColumnOrderInstanceProps, + UseColumnOrderState, + UseExpandedHooks, + UseExpandedInstanceProps, + UseExpandedOptions, + UseExpandedRowProps, + UseExpandedState, + UseFiltersColumnOptions, + UseFiltersColumnProps, + UseFiltersInstanceProps, + UseFiltersOptions, + UseFiltersState, + UseGlobalFiltersColumnOptions, + UseGlobalFiltersInstanceProps, + UseGlobalFiltersOptions, + UseGlobalFiltersState, + UseGroupByCellProps, + UseGroupByColumnOptions, + UseGroupByColumnProps, + UseGroupByHooks, + UseGroupByInstanceProps, + UseGroupByOptions, + UseGroupByRowProps, + UseGroupByState, + UsePaginationInstanceProps, + UsePaginationOptions, + UsePaginationState, + UseResizeColumnsColumnOptions, + UseResizeColumnsColumnProps, + UseResizeColumnsOptions, + UseResizeColumnsState, + UseRowSelectHooks, + UseRowSelectInstanceProps, + UseRowSelectOptions, + UseRowSelectRowProps, + UseRowSelectState, + UseRowStateCellProps, + UseRowStateInstanceProps, + UseRowStateOptions, + UseRowStateRowProps, + UseRowStateState, + UseSortByColumnOptions, + UseSortByColumnProps, + UseSortByHooks, + UseSortByInstanceProps, + UseSortByOptions, + UseSortByState, +} from "react-table" + +declare module "react-table" { + // take this file as-is, or comment out the sections that don't apply to your plugin configuration + + export interface TableOptions< + D extends Record + > extends UseExpandedOptions, + UseFiltersOptions, + UseGlobalFiltersOptions, + UseGroupByOptions, + UsePaginationOptions, + UseResizeColumnsOptions, + UseRowSelectOptions, + UseRowStateOptions, + UseSortByOptions, + // note that having Record here allows you to add anything to the options, this matches the spirit of the + // underlying js library, but might be cleaner if it's replaced by a more specific type that matches your + // feature set, this is a safe default. + Record {} + + export interface Hooks< + D extends Record = Record + > extends UseExpandedHooks, + UseGroupByHooks, + UseRowSelectHooks, + UseSortByHooks {} + + export interface TableInstance< + D extends Record = Record + > extends UseColumnOrderInstanceProps, + UseExpandedInstanceProps, + UseFiltersInstanceProps, + UseGlobalFiltersInstanceProps, + UseGroupByInstanceProps, + UsePaginationInstanceProps, + UseRowSelectInstanceProps, + UseRowStateInstanceProps, + UseSortByInstanceProps {} + + export interface TableState< + D extends Record = Record + > extends UseColumnOrderState, + UseExpandedState, + UseFiltersState, + UseGlobalFiltersState, + UseGroupByState, + UsePaginationState, + UseResizeColumnsState, + UseRowSelectState, + UseRowStateState, + UseSortByState {} + + export interface ColumnInterface< + D extends Record = Record + > extends UseFiltersColumnOptions, + UseGlobalFiltersColumnOptions, + UseGroupByColumnOptions, + UseResizeColumnsColumnOptions, + UseSortByColumnOptions {} + + export interface ColumnInstance< + D extends Record = Record + > extends UseFiltersColumnProps, + UseGroupByColumnProps, + UseResizeColumnsColumnProps, + UseSortByColumnProps {} + + export interface Cell< + D extends Record = Record, + V = any + > extends UseGroupByCellProps, + UseRowStateCellProps {} + + export interface Row< + D extends Record = Record + > extends UseExpandedRowProps, + UseGroupByRowProps, + UseRowSelectRowProps, + UseRowStateRowProps {} +} diff --git a/react-app/store/model.ts b/react-app/store/model.ts index 6aa48de..ecadd97 100644 --- a/react-app/store/model.ts +++ b/react-app/store/model.ts @@ -102,7 +102,6 @@ const model: Store = { }), loadGraphQLSchemaByIntrospection: thunk( async (actions, _payload, helpers) => { - // TODO: Replace with dynamic value const endpoint = process.env.NEXT_PUBLIC_HASURA_URL ? process.env.NEXT_PUBLIC_HASURA_URL + "/v1/graphql" : "http://localhost:8085/v1/graphql" @@ -111,6 +110,8 @@ const model: Store = { method: "POST", headers: { "Content-Type": "application/json", + "X-Hasura-Admin-Secret": + process.env.NEXT_PUBLIC_HASURA_ADMIN_SECRET || "", "X-Hasura-Role": helpers.getState().currentRole || "admin", }, body: JSON.stringify({ diff --git a/react-app/store/utils.ts b/react-app/store/utils.ts index 3ed3f58..7df93dc 100644 --- a/react-app/store/utils.ts +++ b/react-app/store/utils.ts @@ -15,7 +15,7 @@ interface GroupMetadataAndPostgresInfoParams { /** * Extracts all unique roles from Hasura metadata - * Used for display role-selection modal options + * Used for displaying role-selection modal options */ export function findRoleNamesInMetadata( metadata: MetadataAndPostgresQueryResult["metadata"] @@ -89,13 +89,16 @@ export function groupMetadataAndPostgresInfoByTableName( ) if (!table) { - throw new Error( + console.log( `Could not find PG table matching metadata table: ${metadataTable.table?.name}` ) + // throw new Error( + // `Could not find PG table matching metadata table: ${metadataTable.table?.name}` + // ) } return { - id: table.table_name, + id: table?.table_name, database_table: table, ...metadataTable, } @@ -110,7 +113,10 @@ export function groupMetadataAndPostgresInfoByTableName( }) // Key the results by table name to turn it into a dictionary for easier name-based lookups - return _.keyBy(roleFilteredCombinedTables, it => it.database_table.table_name) + return _.keyBy( + roleFilteredCombinedTables, + it => it.database_table?.table_name + ) } export type GroupedMetadataAndPostgresTables = ReturnType< diff --git a/react-app/utils/querySelectionSets.ts b/react-app/utils/querySelectionSets.ts index d277423..c1da05d 100644 --- a/react-app/utils/querySelectionSets.ts +++ b/react-app/utils/querySelectionSets.ts @@ -11,9 +11,9 @@ export const metadataSelectionSet = { arguments: everything, headers: { on_HeaderFromEnv: everything, - on_HeaderFromValue: everything - } - } + on_HeaderFromValue: everything, + }, + }, }, allowlist: everything, cron_triggers: { @@ -21,34 +21,34 @@ export const metadataSelectionSet = { retry_conf: everything, headers: { on_HeaderFromEnv: everything, - on_HeaderFromValue: everything - } + on_HeaderFromValue: everything, + }, }, custom_types: { enums: { ...everything, - values: everything + values: everything, }, input_objects: { ...everything, - fields: everything + fields: everything, }, objects: { ...everything, fields: everything, relationships: { ...everything, - remote_table: everything - } - } + remote_table: everything, + }, + }, }, functions: { configuration: everything, - function: everything + function: everything, }, query_collections: { ...everything, - definition: { queries: everything } + definition: { queries: everything }, }, remote_schemas: { ...everything, @@ -56,9 +56,9 @@ export const metadataSelectionSet = { ...everything, headers: { on_HeaderFromEnv: everything, - on_HeaderFromValue: everything - } - } + on_HeaderFromValue: everything, + }, + }, }, tables: { ...everything, @@ -67,42 +67,51 @@ export const metadataSelectionSet = { using: { foreign_key_constraint_on: { ...everything, - table: everything - } - } + table: everything, + }, + }, }, computed_fields: { ...everything, definition: { ...everything, - function: everything - } + function: everything, + }, }, configuration: { ...everything, - custom_root_fields: everything + custom_root_fields: everything, }, delete_permissions: { ...everything, - permission: everything - }, - event_triggers: { - ...everything, - definition: { - ...everything, - delete: everything, - insert: everything, - update: everything - }, - headers: { - on_HeaderFromEnv: everything, - on_HeaderFromValue: everything - }, - retry_conf: everything + permission: everything, }, + // event_triggers: { + // ...everything, + // definition: { + // ...everything, + // delete: { + // // on_OperationSpecAllColumns: everything, + // on_OperationSpecIndividualColumns: everything, + // }, + // insert: { + // // on_OperationSpecAllColumns: everything, + // on_OperationSpecIndividualColumns: everything, + // }, + // update: { + // // on_OperationSpecAllColumns: everything, + // on_OperationSpecIndividualColumns: everything, + // }, + // }, + // headers: { + // on_HeaderFromEnv: everything, + // on_HeaderFromValue: everything, + // }, + // retry_conf: everything, + // }, insert_permissions: { ...everything, - permission: everything + permission: everything, }, object_relationships: { ...everything, @@ -110,25 +119,25 @@ export const metadataSelectionSet = { foreign_key_constraint_on: true, manual_configuration: { column_mapping: true, - remote_table: everything - } - } + remote_table: everything, + }, + }, }, remote_relationships: { ...everything, - definition: everything + definition: everything, }, select_permissions: { ...everything, - permission: everything + permission: everything, }, table: everything, update_permissions: { ...everything, - permission: everything - } - } - } + permission: everything, + }, + }, + }, } export const postgresSelectionSet = { @@ -141,15 +150,15 @@ export const postgresSelectionSet = { columns: everything, foreign_keys: everything, indexes: everything, - primary_key: everything - } - } - } + primary_key: everything, + }, + }, + }, } export const metadataAndPostgresSelectionSet = { ...metadataSelectionSet, - ...postgresSelectionSet + ...postgresSelectionSet, } export type MetadataQueryResult = QueryResult