hasura / hasura/graphql-engine

[Suggestion] Data Validations

Open
#6,902 3 comments 0 reactions 1 assignee Claimed by @0x777 View on GitHub
a/api/graphql k/enhancement
Dominant language
TypeScript
Stars
32.1k
Forks
3k
PR merge metrics
PR metrics pending

Description

There should be an option to add custom Scalars to the Tables which will validate the backend while a mutation is called.

For example, I have a `user` table that has `email`.

| user_id | email |
|--------------|-------------|

have a corresponding GQL
```graphql
type Users {
user_id: String!;
email: String!;
}
````

### Suggested Changes
Add support to change these scalars to custom logic.
```graphql
type Users {
user_id: String!;
email: Email!;
}
```
and a custom logic can be written in any of one language, ex. `nodejs`

```javascript
const emailRegexp = /^....email validation regex....$/;

// will return true or error message that needs to be shown
const Email = (input) => emailRegexp.test(input);

```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.