hasura / hasura/graphql-engine

Add validation to forms

Open
#3,728 4 comments 1 reaction 0 assignees View on GitHub
c/console k/dx
Dominant language
TypeScript
Stars
32.1k
Forks
3k
PR merge metrics
PR metrics pending

Description

## What is the current behavior?

There are no validations for the forms. If the form is not filled correctly, the request is sent to the server anyway and user sees the error from the server. Error messages are not always self-explanatory and may be confusing what exactly went wrong.

## What is the expected behavior?

Forms in the Hasura Console could be validated before the request is sent. And all the fields that are not filled properly would be marked as invalid. For example somehow like that:
Screenshot 2020-01-17 at 10 07 52

## Examples
### 1.
The form for inserting a new row was not filled properly. The example below is small, but the user can have far more columns and then scroll through the inputs to check which one is not filled. We could make it easier and validate the form so that the user can see which inputs are not filled correctly.

Screenshot 2020-01-17 at 08 59 41
Screenshot 2020-01-17 at 08 59 32

### 2.
Inputs for filter query could be validated so that no unnecessary request is sent. In the example below the array is not valid but the request is sent anyway. If it was validated user could troubleshoot faster.

Screenshot 2020-01-17 at 09 57 57

### 3.
Value input is not filled but the request is sent anyway with `null` as the filtered value.
Screenshot 2020-01-17 at 10 14 15

### 4.
When creating a new table, validate if table is not empty and the primary key is set.

---
Note: There are more examples, I just listed some of them.

## What is the motivation/use case for changing the behavior?

Better user experience.

## Possible technical solution

In Console PRO I introduced `react-hook-form` library, which is lightweight and was working great for validation purposes. It could be also useful here.

Contributor guide

Open the contributing guide

Research direction

No files, tests, or entry points are named. Start by mapping the Console forms covered by the examples and checking their existing request flow; define which fields must block submission and how invalid fields should be displayed, then verify that invalid inputs do not send requests.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.