Skip to content
This repository has been archived by the owner on Oct 9, 2019. It is now read-only.

GraphQL interface types #95

Closed
sedubois opened this issue Oct 2, 2018 · 0 comments
Closed

GraphQL interface types #95

sedubois opened this issue Oct 2, 2018 · 0 comments

Comments

@sedubois
Copy link

sedubois commented Oct 2, 2018

I have a Gatsby site which needs:

  1. a navigation menu to various pages
  2. to expose SEO information for all pages
  3. to generate an Algolia search page
  4. to generate an RSS feed

For all these operations, various metadata which is generic to all model types is required: title, description, image, slug/path.

To my understanding, there is currently no way to make DatoCMS models inherit from shared interface types. This would however ideally solve such use cases as all models could be loaded with one single GraphQL type for all of the operations listed above.

Currently I have to workaround this by:

  1. either duplicating all these properties between the various models, which leads to code duplication, a bug-prone situation when the model configurations diverge and also requires more GraphQL fetching logic (can't reuse same GraphQL fragment everywhere). Not ideal.
  2. or extracting these shared properties to a common model with a one-to-one relationship (a model which I could call "SEO" for instance). I'm currently choosing this second approach to improve code quality, but it makes it more verbose than it should, with nested seo properties appearing everywhere. It also makes the navigation and editing in DatoCMS not so nice. But more importantly, it prevents filtering by any property embedded within this extracted model, as DatoCMS currently does not seem to allow filtering of sub-properties.

Also, DatoCMS already exposes generic _seoMetaTags for all models, but its type definition appears to be duplicated on each and every model instead of being defined on a shared interface.

Did I miss the existence of GraphQL interface types somewhere or could this be considered (including for _seoMetaTags)? How likely is it to come? Thank you very much and keep up the great work

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

No branches or pull requests

2 participants