graphql-engine/console
Matthew Goodwin 12d4de57c0 console: Revisions to #6931
For context: https://github.com/hasura/graphql-engine-mono/pull/6931

This PR makes some revisions that I had originally intended to be in the code, but due to some mixup, was refactored without discussion. @vijayprasanna13 and I synced up to try and make a decision about how to resolve it, but ultimately wanted to get more eyes on it to weigh in.

For context, when I refer to "premade selectors" I am talking about [this file](8a9264b14c/console/src/features/hasura-metadata-api/selectors.ts (L34))

And when I refer to "utility functions" (or metadata utility functions), I am talking about [this file](8a9264b14c/console/src/features/hasura-metadata-api/utils.ts (L38))

The changes I am suggesting here mostly about maintaining (IMHO) clearer separation of concern for selectors vs utility functions, and improving DX.

Here's how I see it high level:

![flows (light theme)](https://user-images.githubusercontent.com/49927862/204630900-aca2aad1-d760-409d-8ec6-446942b2d6ff.png#gh-light-mode-only)
![flows (dar theme)](https://user-images.githubusercontent.com/173663/204755227-e8850dbf-1012-4c7b-8087-dd6f16e5ca23.jpg#gh-dark-mode-only)

In other words, I want to avoid using pre-made selectors within a custom selector as it creates a pattern of multiple layers of curried functions and beings to (IMHO) look confusing and blur the separation of concern.

What I am proposing is that we have a convention of doing either

1) Developer wants the entire table object of a specific table. They can easily do this using one of the **premade** selectors and pass directly into `useMetdata()`:

```ts
const { isLoading, data: metadataTable } = useMetadata(
    MetadataSelectors.findTable(dataSourceName, table)
  );
```

2) Developer wants to get a specific piece of information on a specific table. They can leverage the `findMetadataTable()` utility function within a custom inline selector like this and avoid extra currying and double selector confusion:

  ```ts
const { isLoading, data: savedComment } = useMetadata(
    m => MetadataUtils.findMetadataTable(dataSourceName, table, m)?.configuration?.comment
  );
```

This is somewhat of a stylistic preference, but also one that I think makes a cleaner separation of concern in the way we are building the api and supportive pieces. In other words, premade selectors are _always_ a selector and not used to compose other selectors. It also makes available utility functions that are easy to pull of the shelf to do common metadata tasks whether in the scope of `useMetadata` or not.

## Simpler Approach?

We could also just go with **Flow # 2** and eliminate the premade selectors. The dev would then pass a custom selector into `useMetadata()` and if they prefer, use a utility function to support their task.

With that aside, whatever the team agrees makes more sense, I will gladly get on board with, but I wanted to make my case here : )

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/7095
Co-authored-by: Vijay Prasanna <11921040+vijayprasanna13@users.noreply.github.com>
GitOrigin-RevId: 7ecc2db172def0d2f714cbbb2f95a4b56a528093
2022-12-02 18:28:40 +00:00
..
.storybook feat(console): add import single endpoint from openAPI 2022-11-29 19:09:53 +00:00
cypress test: add snapshot check to action e2e test 2022-12-02 10:03:39 +00:00
docs Fix broken links 2022-10-26 14:22:19 +00:00
exports Add Login with SSO option to EE lite 2022-11-30 05:21:35 +00:00
public console(local-dev): remove ssr for local development 2022-07-20 16:05:04 +00:00
scripts workflow: add lint and format action for console (#4501) 2020-05-29 16:45:43 +05:30
src console: Revisions to #6931 2022-12-02 18:28:40 +00:00
static console: Update the Analytics docs 2022-11-04 16:09:27 +00:00
webpack feat(console): add import single endpoint from openAPI 2022-11-29 19:09:53 +00:00
.babelrc console: add storybook support 2021-09-20 16:31:25 +00:00
.eslintignore Console/permissions tab component 2022-03-08 07:46:19 +00:00
.eslintrc console: Prevent using analytics-related props on React components 2022-10-28 16:23:47 +00:00
.gitignore console: E2E test to verify DB compatibility 2022-11-17 17:00:58 +00:00
.npmignore console: package modules from oss 2021-03-17 18:59:18 +00:00
.npmrc console: refactor filter section components 2022-09-01 13:34:36 +00:00
.nvmrc console: upgrade to node 16 and npm 8 2022-08-02 13:52:53 +00:00
.prettierignore console: fix linter config (#4137) 2020-04-06 16:53:04 +05:30
console.code-workspace console: GQL Customization while tracking a table 2022-09-26 22:02:40 +00:00
control-plane-graphql-codegen.yml console: add a standardised lux client and setup type autogeneration for control plane graphql types 2022-11-04 11:16:41 +00:00
cypress.config.ts test: add snapshot check to action e2e test 2022-12-02 10:03:39 +00:00
hasuraconfig.js add console to graphql-engine 2018-06-28 10:27:37 +05:30
jest.config.js console: support multi tenant connection pooling on cloud 2022-09-27 12:23:14 +00:00
Makefile console: cleenup makefiles 2022-11-10 14:26:41 +00:00
package-lock.json test: add snapshot check to action e2e test 2022-12-02 10:03:39 +00:00
package.json test: add snapshot check to action e2e test 2022-12-02 10:03:39 +00:00
postcss-storybook.config.js console: migrate REST endpoint form to new components 2022-06-30 14:17:52 +00:00
postcss.config.js console: add tailwindcss for styles 2021-08-10 13:46:52 +00:00
README.md console: Define a testing strategy 2022-08-03 11:35:17 +00:00
snapshots.js test: add snapshot check to action e2e test 2022-12-02 10:03:39 +00:00
tailwind-storybook.config.js console: migrate REST endpoint form to new components 2022-06-30 14:17:52 +00:00
tailwind.config.js Docs/improve storybook docs 2022-09-02 09:13:36 +00:00
tsconfig.json console: fix the Typescript no implicit returns rules 2022-08-17 14:37:04 +00:00
tsconfig.test.json console: add schema sharing 2021-07-08 08:18:25 +00:00

Hasura Console

The Hasura console is an admin dashboard to manage the connected database and to try out GraphQL APIs. It is a React application bundled with Webpack and the state is managed mostly using Redux.

Table of contents