Iām working on a Next.js app and Iām fetching the data using ā@datocms/cma-client-nodeā library.
Iām wondering if there is a way to generate Typescript types locally for the created models/blocks to use them in my components?
Unfortunately we donāt currently support TypeScript generation from our CMA API. The GraphQL generators depend on upstream type generation libs tied to GraphQL queries in particular.
However, if you generate the types from the GraphQL calls, that might get you like 70%-80% of the way there, and you can manually modify the resulting types (probably renaming field names from the GraphQL APIās camelCase to the CMAās snake_case).
Can I ask if thereās a particular reason you want to use the CMA instead of the CDA in your Next project?
Hi Roger,
Thank you for the quick response.
Iām new to Dato CMS and I was didnāt know that the CMA and CDA are separated.
I checked them now and Iāll move to using CDA.
Youāre welcome, and glad to hear it Hopefully youāll like the GraphQL APIā¦ itās designed to make it easy for your frontend to pull exactly what it needs.
Welcome again to Dato, and please donāt hesitate to ask for help if you ever need it.