Skip to content

Commit 68b9ecc

Browse files
jwaldripclaude
andcommitted
fix: resolve clause ordering, moduledoc, and test issues
- Move :directive atom clauses before generic clauses in coordinate_for/2 and coordinate_for/3 to prevent shadowing by pattern match order - Escape string interpolation in @moduledoc to prevent compile-time eval - Fix coordinate resolution tests to use "RootQueryType" (Absinthe's default query type name) instead of "Query" Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 71f503f commit 68b9ecc

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

lib/absinthe/schema/coordinate/error_helpers.ex

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ defmodule Absinthe.Schema.Coordinate.ErrorHelpers do
1010
import Absinthe.Schema.Coordinate.ErrorHelpers
1111
1212
# In an error message
13-
"Field #{coordinate_for(type, field)} is deprecated"
13+
"Field \#{coordinate_for(type, field)} is deprecated"
1414
1515
# Adding coordinate to error extras
1616
error
@@ -46,26 +46,26 @@ defmodule Absinthe.Schema.Coordinate.ErrorHelpers do
4646
Coordinate.for_type(type_name)
4747
end
4848

49-
@spec coordinate_for(String.t(), String.t()) :: String.t()
50-
def coordinate_for(type_name, field_name) do
51-
Coordinate.for_field(to_string(type_name), to_string(field_name))
52-
end
53-
5449
@spec coordinate_for(:directive, String.t()) :: String.t()
5550
def coordinate_for(:directive, directive_name) do
5651
Coordinate.for_directive(to_string(directive_name))
5752
end
5853

59-
@spec coordinate_for(String.t(), String.t(), String.t()) :: String.t()
60-
def coordinate_for(type_name, field_name, arg_name) do
61-
Coordinate.for_argument(to_string(type_name), to_string(field_name), to_string(arg_name))
54+
@spec coordinate_for(String.t(), String.t()) :: String.t()
55+
def coordinate_for(type_name, field_name) do
56+
Coordinate.for_field(to_string(type_name), to_string(field_name))
6257
end
6358

6459
@spec coordinate_for(:directive, String.t(), String.t()) :: String.t()
6560
def coordinate_for(:directive, directive_name, arg_name) do
6661
Coordinate.for_directive_argument(to_string(directive_name), to_string(arg_name))
6762
end
6863

64+
@spec coordinate_for(String.t(), String.t(), String.t()) :: String.t()
65+
def coordinate_for(type_name, field_name, arg_name) do
66+
Coordinate.for_argument(to_string(type_name), to_string(field_name), to_string(arg_name))
67+
end
68+
6969
@doc """
7070
Add a schema coordinate to an error's extra data.
7171

test/absinthe/schema/coordinate_test.exs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ defmodule Absinthe.Schema.CoordinateTest do
152152
end
153153

154154
test "resolve/2 resolves argument coordinates" do
155-
assert {:ok, arg} = Coordinate.resolve(TestSchema, "Query.user(id:)")
155+
assert {:ok, arg} = Coordinate.resolve(TestSchema, "RootQueryType.user(id:)")
156156
assert arg.identifier == :id
157157
end
158158

@@ -175,8 +175,8 @@ defmodule Absinthe.Schema.CoordinateTest do
175175
end
176176

177177
test "resolve/2 returns error for non-existent argument" do
178-
assert {:error, "Argument not found: Query.user(nonexistent:)"} =
179-
Coordinate.resolve(TestSchema, "Query.user(nonexistent:)")
178+
assert {:error, "Argument not found: RootQueryType.user(nonexistent:)"} =
179+
Coordinate.resolve(TestSchema, "RootQueryType.user(nonexistent:)")
180180
end
181181

182182
test "resolve/2 returns error for non-existent directive" do

0 commit comments

Comments
 (0)