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

[Feature Request] Generate Types of Datasources #40

Open
madebyfabian opened this issue Apr 6, 2023 · 3 comments
Open

[Feature Request] Generate Types of Datasources #40

madebyfabian opened this issue Apr 6, 2023 · 3 comments

Comments

@madebyfabian
Copy link

madebyfabian commented Apr 6, 2023

Hi there! First of all, thanks for your work on this package. It's really great.

I started to use the Datasources Feature of Storyblok more for my Single-Option fields.
It's great because you can share field options between components, to keep them consistent.

However though, I noticed that when having "locally"/inside the component defined Single-Option fields, they are typed with a union of the possible field values. When using Datasources, I just get a string type out of them, which isn't that helpful.

If it's technically possible, it would be great to have the datasources also typed. If you like, I can offer to help with integrating this feature.

@dohomi
Copy link
Owner

dohomi commented Apr 6, 2023

I am open for any PR - meanwhile you also extend the typings like I did in the examples https://github.com/dohomi/storyblok-generate-ts#resolve-relations

@madebyfabian
Copy link
Author

madebyfabian commented Apr 7, 2023

@dohomi
Looked into it and it seems the generated JSON from the CLI only returns the slug of the datasource:

"schema": {
  "versusCategory": {
    "datasource_slug": "versuscategory",
    "...": "..."
  }
},

But the actual values of the datasource are not listed. So there is no way to generate those types, exept, this package would have to do a HTTP request to the Storyblok API, which would also need an API key then. Not sure if this is still in the scope of this package, since this would include larger rewrite.

Maybe I can file a feature request to the storyblok team including datasource values somewhere in the generated JSON.

What do you think?

@dohomi
Copy link
Owner

dohomi commented Apr 9, 2023

@madebyfabian sure you can ping them, not sure why there is no native tooling around the API for creating types. In my opinion this should be handled via GraphQL but the endpoint only delivers root page typings last time I checked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants