I’m working on a Nextjs project with typescript. Normally when doing this, I prefer to setup auto generated types from the endpoints I consume. In this case from builder.io. Meaning that all the models and custom fields, whether it is pages, sections or cms data models, will have its equivalent types auto generated and creating a reliable contract between the cms and codebase. I often do this in two ways:
Using openapi-generator-cli @openapitools/openapi-generator-cli - npm. But this doesn’t seem possible with the the current rest api (Builder.io: Drag & Drop Headless CMS), as it is not using swagger?
Using GraphQL with graphql-codegen https://www.npmjs.com/package/@graphql-codegen/cli and its typescript plugins. This works just fine. But the GraphQL schamas are limited by the look of it. All the models setup in builder often is just defined as json in the schema and just reads as any type. So this won’t give the wanted result.
I know that a lot of the types makes sense to do manually when it comes to components, when using the registerComponent with the builder.io sdk, as this is codefirst. But some data won’t be, like a cms data model for the navigation. So getting a reliable contract between builder.io and the codebase would be a great feature. And that is what auto generated types deliver.
So my question is, if you have an approach to achieve? Getting types for the all the models and custom fields you setup in builder.io? Or any other best practice to get model types?
Thanks in advance. : )