Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix: Downcase MultiPage Anchors for Links #54

Merged
merged 3 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading