Agent skill that turns natural language, code, Terraform/K8s, SQL, OpenAPI, AsyncAPI, Protobuf and GraphQL sources into editable, tested draw.io architecture diagrams: incremental sync, multi-view projection, drift diff, CI architecture tests, whiteboard derasterize, interactive HTML/PPTX/Mermaid exports.
Python agent-skillsarchitecturearchitecture-diagramasyncapibpmnc4-modelclaude-codediagramdiagrams-as-codedrawioflowchartgithub-actionsgraphqlimage-to-diagramkubernetesmcp-serverprotobufsysmlterraformuml
fix: fold extend definitions into their base type (#131)
Agents365-aiccb3e0944fad
diff --git a/skills/drawio-skill/scripts/graphqlerd.py b/skills/drawio-skill/scripts/graphqlerd.pyindex 2d88a2e..bf0738f 100644--- a/skills/drawio-skill/scripts/graphqlerd.py+++ b/skills/drawio-skill/scripts/graphqlerd.py@@ -218,7 +218,8 @@ def parse_sdl(text, file_path=""):segment = segment[: nxt.start()]entry["members"] = [p.strip() for p in segment.split("|") if p.strip()]elif kind != "scalar":- impl = re.match(r"[^\{\n]*", tail).group(0)+ impl_m = re.match(r"[^\{\n]*", tail)+ impl = impl_m.group(0) if impl_m else ""if "implements" in impl:after = impl.split("implements", 1)[1].split("@")[0]entry["implements"] = [@@ -299,6 +300,26 @@ def parse_introspection(payload, file_path=""):return defs+def merge_extends(defs):+ """Fold ``extend`` definitions into their base type.++ GraphQL names are unique within a schema, so two entries sharing a name+ are a base definition and its extends, possibly across different files.+ Keeping both would emit two nodes with the same id.+ """+ merged, order = {}, []+ for d in defs:+ base = merged.get(d["name"])+ if base is None:+ merged[d["name"]] = d+ order.append(d)+ else:+ base["fields"].extend(d["fields"])+ base["implements"].extend(d["implements"])+ base["members"].extend(d["members"])+ return order++def esc(text):"""Escape HTML metacharacters for draw.io's html=1 labels.@@ -321,6 +342,7 @@ def compute_dimensions(lines):def build(defs, group=False, direction="TB", show_types=True):"""Definition dicts -> autolayout graph JSON."""+ defs = merge_extends(defs)nodes, edges, seen_edges = [], [], set()known = {d["name"] for d in defs}@@ -422,7 +444,7 @@ def main():sys.stdout.write(text)counts = {}- for d in defs:+ for d in merge_extends(defs):counts[d["kind"]] = counts.get(d["kind"], 0) + 1summary = ", ".join("%d %ss" % (counts[k], k) for k in KINDS if k in counts)sys.stderr.write("%s, %d edges\n" % (summary, len(graph["edges"])))diff --git a/tests/test_graphqlerd.py b/tests/test_graphqlerd.pyindex 1d63386..9d4ebaf 100644--- a/tests/test_graphqlerd.py+++ b/tests/test_graphqlerd.py@@ -213,6 +213,31 @@ class TestGraphqlErdGraph(unittest.TestCase):self.assertIn("\nf", graph["nodes"][0]["label"])self.assertNotIn("String", graph["nodes"][0]["label"])+ def test_extends_merge_into_a_single_node(self):+ defs = self.importer.parse_sdl(+ "type Foo { a: Int }\n"+ "extend type Foo { b: String @deprecated }\n"+ "interface Bar { c: ID! }\n"+ "extend interface Bar implements Foo { d: Foo }"+ )+ graph = self.importer.build(defs)+ self.assertEqual([n["id"] for n in graph["nodes"]], ["Foo", "Bar"])+ labels = dict((n["id"], n["label"]) for n in graph["nodes"])+ self.assertIn("a: Int", labels["Foo"])+ self.assertIn("b: String (deprecated)", labels["Foo"])+ self.assertIn(("Bar", "Foo", "implements"),+ set((e["source"], e["target"], e["label"])+ for e in graph["edges"]))++ def test_extends_merge_across_schema_files(self):+ base = self.importer.parse_sdl("union U = A | B\n", file_path="a.graphql")+ ext = self.importer.parse_sdl("extend union U = C\n", file_path="b.graphql")+ graph = self.importer.build(base + ext)+ self.assertEqual([n["id"] for n in graph["nodes"]], ["U"])+ members = [line for line in graph["nodes"][0]["label"].split("\n")+ if line in ("A", "B", "C")]+ self.assertEqual(members, ["A", "B", "C"])+class TestGraphqlErdIntrospection(unittest.TestCase):PAYLOAD = {