Skip to content

Commit

Permalink
bugfix: Downcase MultiPage Anchors for Links (#54)
Browse files Browse the repository at this point in the history
* bugfix: Downcase MultiPage Anchors for Links

* Fix credo violations

* Remove work in progress tag
  • Loading branch information
bradschwartz authored Sep 25, 2024
1 parent cf531e9 commit bfb8839
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 11 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
23 changes: 13 additions & 10 deletions lib/graphql_markdown/multi_page.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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
[
Expand Down
4 changes: 4 additions & 0 deletions test/graphql_markdown_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit bfb8839

Please sign in to comment.