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

proposal to display name + id #4

Closed valentinvieriu closed 7 years ago

valentinvieriu commented 7 years ago

As those graphs are displayed most of the time for development purpose, it's useful to display the id of the object. This is the one used by developers

lotas commented 7 years ago

Yes, while this is intended for developers only, it makes sense to include the id of the object. But this also can be optional, so you would have an option to render it with or without.

If you don't mind, I can develop this as a separate feature.

valentinvieriu commented 7 years ago

Sorry for the quick fix, I just needed this quickly for a project I'm working on. So the workflow is quite simple:

Your map is very useful in the process of defining the content models and having an overview but also later for the hand over to the developers. As I see your solution being used in both worlds ( overview of the content but also development of the components based on the content structure) I can only welcome a flag that will allow one view or another.

Would be great if this option enables the development view ( Id focused ) on all levels:

Thank you again for your contribution, and please take my pull requests as suggestions only.

lotas commented 7 years ago

Very nice insight, @valentinvieriu. I haven't even thought about it from that perspective.

Having more use-cases is definitely better, and the suggestions are really good. Thank you once again, I'll try to adopt them soon.

Cheers!

lotas commented 7 years ago

Once again thanks, @valentinvieriu

I have made the proposed changes in acd22df55e7e1af7ace0cea873b534ce07d8c0ed

Now one can use following options: npx contenful-graph -d to show the developer's output, which will include model id and field id in the output

npx contentful-graph -n will render entities without fields information, only models and relationships.

Hope that makes life easier ;) Thnx

valentinvieriu commented 7 years ago

Thank you for the contribution. I've just tried it and looks great!! I want to add one small thing, if can be fixed will be great. See the attached output. Please ignore the [model] and [page] - those are part of my internal naming convention ( they are part of the title ) In the case of the pageStory module you see has one to many relations for content. As you can see the Id it's not being picked up at this level. Would be great if there would be a way to have the id at that level too. model

Thank you again for accepting the feedback.

lotas commented 7 years ago

Ha, I was really confused at first looking at those double brackets, trying to understand where this is coming from 😄

I think the mapping fails somewhere, not yet sure where exactly. Would you be able to share plain *.dot file for examinations, @valentinvieriu ? I had similar problem with escapings, they were escaping too much, and graphviz treated them as separate entities. Apparently, the problem still persists.

valentinvieriu commented 7 years ago

Please ignore the double brackets. I literally gave the title of that component [module] - Carousel or [page] - Story. It's a naming convention that makes it easy to spot different type of content types as you are using the Contentful interface. It could have been also ****module***** - Carousel or also page - Story. I just choose the [] as a personal visual choice.

I've attached a dot file. As you can see on line 22: pageHome:content -> "[module] - Carousel" [dir=forward,label="0..*"]; It has only the title: [module] - Carousel and not the ID + Ttitle, [carousel] [module] - Carousel as you can see on line 11. fdot.txt

Hope that my explanation helps. Thank you @lotas

lotas commented 7 years ago

Understood about the brackets, no worries. I was just thinking if my choice to use them for ids is good or not. Because there is a collision now.

And as for the problem, I guess, I know where it is coming from. I'm sanitising model name in one place too aggressively. Will try to find a better solution there. Thanks!

valentinvieriu commented 7 years ago

You have no idea how useful the graph was when talking with developers and content editors. We have it a 3m/1m print on our room and is very easy to see the connections between the content models and also what are the inputs to our components ( React components ). Thank you again for building this and also for taking this feedback.

lotas commented 7 years ago

Aaaand, another attempt to fix the issue :)

Removed all santisations for entity name, just added escaping. This should do a better mapping, would be really grateful, if you could check this again please (1.1.1 version) Thank you a lot!

valentinvieriu commented 7 years ago

@lotas looks very good now! Actually the whole shape and structure of the graph changed. I think is so much better now!!! model

Thank you!

valentinvieriu commented 7 years ago

Actually there seems to still be a bug. Please see the attached graph. [pageStory] -> [stage] should be linked with [stageStory] and [home] -> [stage] should be linked to [stageHome]. That's how it is in the Contentful.

I wonder if I should record a issue for this. model

fdot.txt

valentinvieriu commented 7 years ago

Ok. I'm coming back. If I use theCONTENTFUL_MANAGEMENT_TOKEN, things look different and seem that this is fixed. In all previous requests I've used CONTENTFUL_TOKEN

See attached Graph and .dot file file.txt

model4

lotas commented 7 years ago

hey! That's awesome. Yes, the problem is that management api gives out a validations property, which contains extra links (content type validations), as was pointed out in #1 by @jelz.

Other than that, thanks again for the feedback and the improvements that we were able to make!