Skip to content

Commit

Permalink
Merge pull request #1302 from michaelcaterisano/mc/camelize-directives
Browse files Browse the repository at this point in the history
Mc/camelize directives
  • Loading branch information
benwilson512 authored Feb 28, 2024
2 parents 2fd4634 + 3082b12 commit 747ba05
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/absinthe/schema/notation.ex
Original file line number Diff line number Diff line change
Expand Up @@ -1991,6 +1991,7 @@ defmodule Absinthe.Schema.Notation do
defp default_name(Schema.DirectiveDefinition, identifier) do
identifier
|> Atom.to_string()
|> Absinthe.Utils.camelize(lower: true)
end

defp default_name(_, identifier) do
Expand Down
5 changes: 5 additions & 0 deletions lib/absinthe/schema/notation/sdl_render.ex
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,11 @@ defmodule Absinthe.Schema.Notation.SDL.Render do
end

defp directives(directives, type_definitions) do
directives =
Enum.map(directives, fn directive ->
%{directive | name: Absinthe.Utils.camelize(directive.name, lower: true)}
end)

concat(Enum.map(directives, &render(&1, type_definitions)))
end

Expand Down
6 changes: 6 additions & 0 deletions test/absinthe/schema/sdl_render_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,10 @@ defmodule Absinthe.Schema.SdlRenderTest do
on :field
end

directive :foo_foo do
on :field
end

enum :order_status do
value :delivered
value :processing
Expand Down Expand Up @@ -244,6 +248,8 @@ defmodule Absinthe.Schema.SdlRenderTest do
query: RootQueryType
}
directive @fooFoo on FIELD
directive @foo(baz: String) on FIELD
\"Escaped\\t\\\"descrição\\/description\\\"\"
Expand Down

0 comments on commit 747ba05

Please sign in to comment.