Skip to content

Fix Application ER Mermaid Diagram#2231

Merged
zachdaniel merged 1 commit intoash-project:mainfrom
maennchen:app_mermaid_er_fix
Jul 28, 2025
Merged

Fix Application ER Mermaid Diagram#2231
zachdaniel merged 1 commit intoash-project:mainfrom
maennchen:app_mermaid_er_fix

Conversation

@maennchen
Copy link
Copy Markdown
Contributor

@maennchen maennchen commented Jul 26, 2025

Fixes

Ash.Info.mermaid_overview/2 type :entity_relationship produced a parse error:

Uncaught (in promise) Error: Parse error on line 2:
erDiagram    AshHq.Accounts    AshHq.
------------------^
Expecting 'EOF', 'SPACE', 'NEWLINE', 'COLON', 'STYLE_SEPARATOR', 'BLOCK_START', 'SQS', 'SQE', 'title', 'acc_title', 'acc_descr', 'acc_descr_multiline_value', 'direction_tb', 'direction_bt', 'direction_rl', 'direction_lr', 'CLASSDEF', 'UNICODE_TEXT', 'CLASS', 'STYLE', 'ENTITY_NAME', 'ZERO_OR_ONE', 'ZERO_OR_MORE', 'ONE_OR_MORE', 'ONLY_ONE', 'MD_PARENT', got '.'
    at rA.parseError (app-b61a0ac225a159bb5806be5f6e266c11.js:644:9248)
    at rA.parse (app-b61a0ac225a159bb5806be5f6e266c11.js:646:179)
    at Diagram.fromText (app-b61a0ac225a159bb5806be5f6e266c11.js:2740:303)
    at Object.render (app-b61a0ac225a159bb5806be5f6e266c11.js:2747:1281)
    at app-b61a0ac225a159bb5806be5f6e266c11.js:2747:5852
    at new Promise (<anonymous>)
    at performCall (app-b61a0ac225a159bb5806be5f6e266c11.js:2747:5829)
    at executeQueue (app-b61a0ac225a159bb5806be5f6e266c11.js:2747:5462)
    at app-b61a0ac225a159bb5806be5f6e266c11.js:2747:6002
    at new Promise (<anonymous>)

Changes

Before:

erDiagram
    Ash.Test.Flow.Domain
    Ash.Test.Flow.User {
        Domain: Ash.Test.Flow.Domain
        Source: test/support/flow/user.ex

        Ash.Type.UUID id
        Ash.Type.String first_name
        Ash.Type.String last_name
        Ash.Type.String email
    }
    Ash.Test.Flow.Org {
        Domain: Ash.Test.Flow.Domain
        Source: test/support/flow/org.ex

        Ash.Type.UUID id
        Ash.Type.String name
    }

    Ash.Test.Flow.Org ||--|| Ash.Test.Flow.User : ""

After:

erDiagram
    "Ash.Test.Flow.User" {
        UUID id
        String first_name
        String last_name
        String email
    }
    "Ash.Test.Flow.Org" {
        UUID id
        String name
    }

    "Ash.Test.Flow.Org" ||--|| "Ash.Test.Flow.User" : ""
  • Names need to be escaped if they contain special characters (")
  • The syntax Domain: .. inside a resource is invalid. I removed it. ← Better Idea?
  • The syntax Source: .. inside a resource is invalid. I removed it. ← Better Idea?
  • The domain was displayed as a box without any connections to the resources. That didn't make sense. I removed it. ← Better Idea?
  • Type Names are always shortened even if name: :full is provided. The field can't be escaped in mermaid and therefore types can't contain any dots.
  • Refactored code so that a single domain and multiple domains use the same implementation.
  • Added tests.

Contributor checklist

Leave anything that you believe does not apply unchecked.

  • I accept the AI Policy, or AI was not used in the creation of this PR.
  • Bug fixes include regression tests
  • Chores
  • Documentation changes
  • Features include unit/acceptance tests
  • Refactoring
  • Update dependencies

@maennchen maennchen force-pushed the app_mermaid_er_fix branch from 76edee6 to 3b52512 Compare July 26, 2025 14:27
@zachdaniel
Copy link
Copy Markdown
Contributor

Not sure how this got so borked 😓
This all seems fine to me, although I'd rather just remove the :full option if we can't honor it. That can be done in a follow up though, if at all.

@zachdaniel zachdaniel merged commit bf31c46 into ash-project:main Jul 28, 2025
43 checks passed
@zachdaniel
Copy link
Copy Markdown
Contributor

🚀 Thank you for your contribution! 🚀

@maennchen
Copy link
Copy Markdown
Contributor Author

@zachdaniel The full option is still honored with the resource names. Just not with the types.

@maennchen maennchen deleted the app_mermaid_er_fix branch July 28, 2025 16:40
@zachdaniel
Copy link
Copy Markdown
Contributor

Ahh, okay. Makes perfect sense, thanks 🙇

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants