From 5d39f09faac030f807e9b1d563f8fd7e4385c724 Mon Sep 17 00:00:00 2001 From: bradschwartz Date: Thu, 26 Sep 2024 09:57:24 -0500 Subject: [PATCH] Handle Union Return Types to Union Guide Instead of Scalars --- CHANGELOG.md | 6 ++++++ lib/graphql_markdown/multi_page.ex | 3 +++ mix.exs | 2 +- test/graphql_markdown_test.exs | 4 ++++ 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bbb3cc4..24d1bd8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## 0.4.2 - 2024-09-26 + +### Fixed + +* Links to union return types handled correctly + ## 0.4.1 - 2024-09-25 ### Fixed diff --git a/lib/graphql_markdown/multi_page.ex b/lib/graphql_markdown/multi_page.ex index 9147dd6..e7b5663 100644 --- a/lib/graphql_markdown/multi_page.ex +++ b/lib/graphql_markdown/multi_page.ex @@ -192,6 +192,9 @@ defmodule GraphqlMarkdown.MultiPage do "ENUM" -> "enums.html#" <> Schema.field_type(field["type"]) + "UNION" -> + "unions.html#" <> Schema.field_type(field["type"]) + _ -> "scalars.html#" <> Schema.field_type(field["type"]) end diff --git a/mix.exs b/mix.exs index 4372b15..2444936 100644 --- a/mix.exs +++ b/mix.exs @@ -2,7 +2,7 @@ defmodule GraphqlMarkdown.MixProject do use Mix.Project @project_url "https://github.com/podium/graphql_markdown" - @version "0.4.1" + @version "0.4.2" def project do [ diff --git a/test/graphql_markdown_test.exs b/test/graphql_markdown_test.exs index e55a9e2..0783d5b 100644 --- a/test/graphql_markdown_test.exs +++ b/test/graphql_markdown_test.exs @@ -81,6 +81,10 @@ defmodule GraphqlMarkdownTest do # anchors need to be downcased to match other parts of the generated markdown content = File.read!("guides/queries.md") assert content =~ "Type: [Droid](scalars.html#droid)" + + # union types need to be a valid type for links + content = File.read!("guides/mutations.md") + assert content =~ "Type: [LoginResponseV2](unions.html#loginresponsev2)" end test "fails to load the file" do