diff --git a/CHANGELOG.md b/CHANGELOG.md index b03ed68..bbb3cc4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## 0.4.1 - 2024-09-25 + +### Fixed + +* Links to types from queries/mutations sets anchor properly + ## 0.4.0 - 2024-08-26 ### Added diff --git a/lib/graphql_markdown/multi_page.ex b/lib/graphql_markdown/multi_page.ex index 3a93451..9147dd6 100644 --- a/lib/graphql_markdown/multi_page.ex +++ b/lib/graphql_markdown/multi_page.ex @@ -181,19 +181,22 @@ defmodule GraphqlMarkdown.MultiPage do end defp reference_for_kind(field) do - case Schema.field_kind(field["type"]) do - "OBJECT" -> - "objects.html#" <> Schema.field_type(field["type"]) + reference = + case Schema.field_kind(field["type"]) do + "OBJECT" -> + "objects.html#" <> Schema.field_type(field["type"]) - "INPUT_OBJECT" -> - "inputs.html#" <> Schema.field_type(field["type"]) + "INPUT_OBJECT" -> + "inputs.html#" <> Schema.field_type(field["type"]) - "ENUM" -> - "enums.html#" <> Schema.field_type(field["type"]) + "ENUM" -> + "enums.html#" <> Schema.field_type(field["type"]) - _ -> - "scalars.html#" <> Schema.field_type(field["type"]) - end + _ -> + "scalars.html#" <> Schema.field_type(field["type"]) + end + + String.downcase(reference) end defp render(type, text) do diff --git a/mix.exs b/mix.exs index 3b1f6fa..4372b15 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.0" + @version "0.4.1" def project do [ diff --git a/test/graphql_markdown_test.exs b/test/graphql_markdown_test.exs index 8d19216..e55a9e2 100644 --- a/test/graphql_markdown_test.exs +++ b/test/graphql_markdown_test.exs @@ -77,6 +77,10 @@ defmodule GraphqlMarkdownTest do "guides/interfaces.md", "guides/unions.md" ]} + + # 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)" end test "fails to load the file" do