It would be great that eg. the Blocks editing screen would allow copying the interface for developers.
That is, the current Edit block, Duplicate, Delete could include a “Copy interface” menu item, or maybe having this feature inside the Edit block modal. This way developers could just copy and use in their code. DatoCMS knows everything to put it together - field names and types too. This would be probably handy for Models too.
I’m interested in a TypeScript interface but there could be interfaces/classes for other languages too.
You can currently use this for it https://www.gatsbyjs.com/blog/how-to-use-gatsby-graphql-type-generation/ . It’ll generate the types based on your named queries, and put them in the
I was searching for such a request in the forum. I’m surprised it hasn’t been voted much.
I think grouping some models with a set of fields that would provide a GQL interface in the schema would be a great addition. My use case is the following : I need to build links for different kind of models using a slug and a title field. Since these fields are not part of the RecordInterface, I cannot use unions on a single GQL request. I need to allow each content type on my link fields on the CMS , make a fragment for each model containing the same fields and add the record type to the query.
I was looking fo something like this
- Allow the admin to create a group for a set of models
- Forcing these models to use certain fields (like slug and title in my case)
- Allowing groups in the link field
- Providing an interface in the schema for this group
We could then create new models that would be automatically allowed in link fields that accepts their group, and frontend apps would not have to be modified as the proper query would exist for the group’s interface. This would allow to create new models without modifying the frontend app and would greatly reduce manipulation in the CMS.
Sorry for the wall of text. Let me know if there’s a solution I didn’t see.