lotas / contentful-graph

Visual representation of contentful content models in form of graphs
https://www.contentful.com/blog/2017/08/08/how-to-quickly-visualize-your-content-model/
MIT License
59 stars 6 forks source link

General issues #1

Closed jelz closed 7 years ago

jelz commented 7 years ago

Hi there,

Jakub from Contentful here. Thank you for contributing to our open source ecosystem. There are some issues with https://github.com/lotas/contentful-graph/blob/master/src/get-relations.js. Allow me to list them to help you with making your project better:

  1. You check only for field.items.validations. It works only with multiple references fields (array of links). For singular links you'd have to check field.validations.
  2. There is a problem with field.validations: they are not available in CDA (contentful npm module). You'd have to use CMA (contentful-management npm module) response for the /content_types endpoint call.
  3. You always map over linkContentType validation (validation.linkContentType.map). It can fail for some other validations (e.g. array size validation) where linkContentType is undefined.
  4. The other thing is that linkContentType can be either an array or a string. If it's a string, it's an ID of a singular linked content type.

Please let me know if there's something I could help with.

J.

lotas commented 7 years ago

Hey @jelz thank you very much for the response :) To be honest I was simply trying to understand the content model for the project I started working on, and this visual representation could have helped me in doing so.

And your comments are really helpful, because I wasn't aware of those small peculiarities. I'll make some amends to the script, having this knowledge.

Thanks!

lotas commented 7 years ago

Thanks @jelz once again for the comments, added corresponding checks and included Management API for the singular links.