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

Type safe schema generator for the client #4565

Open
Tymek opened this issue Aug 24, 2023 · 0 comments
Open

Type safe schema generator for the client #4565

Tymek opened this issue Aug 24, 2023 · 0 comments
Assignees

Comments

@Tymek
Copy link
Member

Tymek commented Aug 24, 2023

Describe the feature request

Based on community feedback https://unleash-community.slack.com/archives/C03GZBSJV9A/p1689704431836109

Background

Can we generate available flags directly with all possible variants from Unleash instance, and use this to strictly type client code?

Solution suggestions

CLI? Initial attempt in @unleash/nextjs

Tymek added a commit that referenced this issue Sep 11, 2023
## About the changes
Instead of this:
```ts
const { uiConfig } = useUiConfig();
const myFlag = Boolean(uiConfig?.flags?.myFlag)
```
we can have this:
```ts
const myFlag = useUiFlag("myFlag")
```
With the same type safety, less verbose and more purposeful code.

### Important files
- `frontend/src/hooks/useUiFlag.ts`


## Discussion points
Can we in the future share flags between frontend and backend? Right now
adding a new flag has to be done in 4 different places (backend flag
keys list, backend flags defaults config, backend experimental server
options, frontend type).

Most ergonomic option is to pull config directly from Unleash. 
Issue, based on previous user feedback:
#4565
Internal feature request document:
[docs.google.com/document/d/1Sx0q...](https://docs.google.com/document/d/1Sx0qKZXUVUCjuY5F4MOh1ieOM1A2_jE58zEA7jaM_1g/edit?usp=sharing)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Todo
Development

No branches or pull requests

1 participant