Skip to content

Commit

Permalink
Merge pull request #1253 from absinthe-graphql/otp-26
Browse files Browse the repository at this point in the history
OTP 26 and Elixir 1.15
  • Loading branch information
benwilson512 authored Jun 29, 2023
2 parents 3e3d4e6 + 52c7e16 commit bc8a1c5
Show file tree
Hide file tree
Showing 11 changed files with 54 additions and 44 deletions.
33 changes: 20 additions & 13 deletions .github/workflows/elixir.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,20 @@ jobs:
elixir:
- "1.13"
- "1.14"
- "1.15"
otp:
- "24"
- "25"
- "26"
include:
- elixir: "1.14"
otp: "25"
- elixir: "1.15"
otp: "26"
format: true
exclude:
- otp: 26
elixir: 1.13
- otp: 26
elixir: 1.14

steps:
- name: Checkout
Expand Down Expand Up @@ -64,16 +71,16 @@ jobs:
env:
SCHEMA_PROVIDER: persistent_term

- name: Cache/uncache PLTs
uses: actions/cache@v3
with:
path: |
priv/plts
key: "${{ runner.os }}-\
erlang-${{ matrix.otp }}-\
elixir-${{ matrix.elixir }}-\
${{ hashFiles('mix.lock') }}"
# - name: Cache/uncache PLTs
# uses: actions/cache@v3
# with:
# path: |
# priv/plts
# key: "${{ runner.os }}-\
# erlang-${{ matrix.otp }}-\
# elixir-${{ matrix.elixir }}-\
# ${{ hashFiles('mix.lock') }}"

- name: Run Dialyzer
run: mix dialyzer
# - name: Run Dialyzer
# run: mix dialyzer

6 changes: 3 additions & 3 deletions lib/absinthe/lexer.ex
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ defmodule Absinthe.Lexer do
)
)

defp fill_mantissa(rest, raw, context, _, _), do: {rest, '0.' ++ raw, context}
defp fill_mantissa(rest, raw, context, _, _), do: {rest, ~c"0." ++ raw, context}

defp unescape_unicode(rest, content, context, _loc, _) do
code = content |> Enum.reverse()
Expand Down Expand Up @@ -453,7 +453,7 @@ defmodule Absinthe.Lexer do

defp block_string_value_token(rest, chars, context, _loc, _byte_offset) do
context = Map.update(context, :token_count, 1, &(&1 + 1))
value = '"""' ++ (chars |> Enum.reverse()) ++ '"""'
value = ~c"\"\"\"" ++ (chars |> Enum.reverse()) ++ ~c"\"\"\""

{rest, [{:block_string_value, context.token_location, value}],
Map.delete(context, :token_location)}
Expand All @@ -465,7 +465,7 @@ defmodule Absinthe.Lexer do

defp string_value_token(rest, chars, context, _loc, _byte_offset) do
context = Map.update(context, :token_count, 1, &(&1 + 1))
value = '"' ++ tl(chars |> Enum.reverse()) ++ '"'
value = ~c"\"" ++ tl(chars |> Enum.reverse()) ++ ~c"\""
{rest, [{:string_value, context.token_location, value}], Map.delete(context, :token_location)}
end

Expand Down
4 changes: 2 additions & 2 deletions lib/absinthe/middleware/async.ex
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,10 @@ defmodule Absinthe.Middleware.Async do

# Optionally use `async/1` function from `opentelemetry_process_propagator` if available
if Code.ensure_loaded?(OpentelemetryProcessPropagator.Task) do
@spec async((() -> any)) :: Task.t()
@spec async((-> any)) :: Task.t()
defdelegate async(fun), to: OpentelemetryProcessPropagator.Task
else
@spec async((() -> any)) :: Task.t()
@spec async((-> any)) :: Task.t()
defdelegate async(fun), to: Task
end
end
4 changes: 2 additions & 2 deletions lib/absinthe/middleware/batch.ex
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,10 @@ defmodule Absinthe.Middleware.Batch do

# Optionally use `async/1` function from `opentelemetry_process_propagator` if available
if Code.ensure_loaded?(OpentelemetryProcessPropagator.Task) do
@spec async((() -> any)) :: Task.t()
@spec async((-> any)) :: Task.t()
defdelegate async(fun), to: OpentelemetryProcessPropagator.Task
else
@spec async((() -> any)) :: Task.t()
@spec async((-> any)) :: Task.t()
defdelegate async(fun), to: Task
end
end
4 changes: 2 additions & 2 deletions lib/absinthe/resolution/helpers.ex
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ defmodule Absinthe.Resolution.Helpers do
end
```
"""
@spec async((() -> term)) :: {:middleware, Middleware.Async, term}
@spec async((() -> term), opts :: [{:timeout, pos_integer}]) ::
@spec async((-> term)) :: {:middleware, Middleware.Async, term}
@spec async((-> term), opts :: [{:timeout, pos_integer}]) ::
{:middleware, Middleware.Async, term}
def async(fun, opts \\ []) do
{:middleware, Middleware.Async, {fun, opts}}
Expand Down
1 change: 1 addition & 0 deletions lib/absinthe/type/built_ins/introspection.ex
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ defmodule Absinthe.Type.BuiltIns.Introspection do
fields
|> Map.take(Map.keys(value))
|> Map.values()
|> Enum.sort_by(& &1.identifier)
|> Enum.map(&render_default_value(schema, adapter, &1, value))
|> Enum.join(", ")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ defmodule Elixir.Absinthe.Integration.Execution.OperationByNameTest do

test "scenario #4" do
assert {:ok, %{data: %{"thing" => %{"name" => "Bar"}}}} ==
Absinthe.run(@query, Absinthe.Fixtures.Things.MacroSchema, operation_name: "ThingBar")
Absinthe.run(@query, Absinthe.Fixtures.Things.MacroSchema,
operation_name: "ThingBar"
)
end

@query """
Expand Down
26 changes: 13 additions & 13 deletions test/absinthe/lexer_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ defmodule Absinthe.LexerTest do
{ foo }
"""
test "basic document" do
assert {:ok, [{:"{", {1, 1}}, {:name, {1, 3}, 'foo'}, {:"}", {1, 7}}]} =
assert {:ok, [{:"{", {1, 1}}, {:name, {1, 3}, ~c"foo"}, {:"}", {1, 7}}]} =
Absinthe.Lexer.tokenize(@query)
end

@query """
{ nullName }
"""
test "document with a name that starts with a keyword" do
assert {:ok, [{:"{", {1, 1}}, {:name, {1, 3}, 'nullName'}, {:"}", {1, 12}}]} =
assert {:ok, [{:"{", {1, 1}}, {:name, {1, 3}, ~c"nullName"}, {:"}", {1, 12}}]} =
Absinthe.Lexer.tokenize(@query)
end

Expand All @@ -23,7 +23,7 @@ defmodule Absinthe.LexerTest do
}
"""
test "basic document, multiple lines" do
assert {:ok, [{:"{", {1, 1}}, {:name, {2, 3}, 'foo'}, {:"}", {3, 1}}]} =
assert {:ok, [{:"{", {1, 1}}, {:name, {2, 3}, ~c"foo"}, {:"}", {3, 1}}]} =
Absinthe.Lexer.tokenize(@query)
end

Expand All @@ -38,9 +38,9 @@ defmodule Absinthe.LexerTest do
[
{:"{", {1, 1}},
{:"{", {2, 3}},
{:name, {2, 5}, 'foo'},
{:name, {2, 5}, ~c"foo"},
{:"(", {2, 8}},
{:name, {2, 9}, 'bar'},
{:name, {2, 9}, ~c"bar"},
{:":", {2, 12}},
{:string_value, {2, 14}, ~S("\\FOO") |> String.to_charlist()},
{:")", {2, 23}},
Expand All @@ -60,11 +60,11 @@ defmodule Absinthe.LexerTest do
assert {:ok,
[
{:"{", {1, 1}},
{:name, {2, 3}, 'foo'},
{:name, {2, 3}, ~c"foo"},
{:"(", {2, 6}},
{:name, {2, 7}, 'bar'},
{:name, {2, 7}, ~c"bar"},
{:":", {2, 10}},
{:block_string_value, {2, 12}, '"""\n stuff\n """'},
{:block_string_value, {2, 12}, ~c"\"\"\"\n stuff\n \"\"\""},
{:")", {4, 6}},
{:"}", {5, 1}}
]} = Absinthe.Lexer.tokenize(@query)
Expand All @@ -82,15 +82,15 @@ defmodule Absinthe.LexerTest do
test "document with emojis" do
assert {:ok,
[
{:block_string_value, {2, 1}, '"""\nA block quote with a 👍 emoji.\n"""'},
{:block_string_value, {2, 1}, ~c"\"\"\"\nA block quote with a 👍 emoji.\n\"\"\""},
{:"{", {5, 1}},
{:name, {6, 3}, 'foo'},
{:name, {6, 3}, ~c"foo"},
{:"(", {6, 6}},
{:name, {6, 7}, 'bar'},
{:name, {6, 7}, ~c"bar"},
{:":", {6, 10}},
{:string_value, {6, 12}, '"A string with a 🎉 emoji."'},
{:string_value, {6, 12}, ~c"\"A string with a 🎉 emoji.\""},
{:")", {6, 38}},
{:name, {6, 40}, 'anotherOnSameLine'},
{:name, {6, 40}, ~c"anotherOnSameLine"},
{:"}", {7, 1}}
]} == Absinthe.Lexer.tokenize(@query)
end
Expand Down
2 changes: 1 addition & 1 deletion test/absinthe/schema/manipulation_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ defmodule Absinthe.Schema.ManipulationTest do
},
%Schema.EnumValueDefinition{
identifier: :bar,
value: :foo,
value: :bar,
name: "BAR",
module: __MODULE__,
__reference__: Notation.build_reference(__ENV__)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ defmodule Absinthe.Schema.Notation.Experimental.MacroExtensionsTest do
name: "width",
type: :integer
}
] = Map.values(object.fields)
] = Map.values(object.fields) |> Enum.sort_by(& &1.name)

assert [:valued_entity] = object.interfaces
end
Expand Down Expand Up @@ -199,7 +199,7 @@ defmodule Absinthe.Schema.Notation.Experimental.MacroExtensionsTest do
name: "width",
type: :integer
}
] = Map.values(object.fields)
] = Map.values(object.fields) |> Enum.sort_by(& &1.name)
end

test "can extend input objects" do
Expand All @@ -214,7 +214,7 @@ defmodule Absinthe.Schema.Notation.Experimental.MacroExtensionsTest do
name: "y",
type: :float
}
] = Map.values(object.fields)
] = Map.values(object.fields) |> Enum.sort_by(& &1.name)
end

test "can extend interfaces" do
Expand All @@ -237,7 +237,7 @@ defmodule Absinthe.Schema.Notation.Experimental.MacroExtensionsTest do
name: "value",
type: :integer
}
] = Map.values(object.fields)
] = Map.values(object.fields) |> Enum.sort_by(& &1.name)

assert [:valued_entity] = object.interfaces
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ defmodule Absinthe.Schema.Notation.Experimental.SdlExtensionsTest do
name: "width",
type: :integer
}
] = Map.values(object.fields)
] = Map.values(object.fields) |> Enum.sort_by(& &1.name)

assert [:valued_entity] = object.interfaces
end
Expand All @@ -179,7 +179,7 @@ defmodule Absinthe.Schema.Notation.Experimental.SdlExtensionsTest do
name: "y",
type: :float
}
] = Map.values(object.fields)
] = Map.values(object.fields) |> Enum.sort_by(& &1.name)
end

test "can extend interfaces" do
Expand All @@ -202,7 +202,7 @@ defmodule Absinthe.Schema.Notation.Experimental.SdlExtensionsTest do
name: "value",
type: :integer
}
] = Map.values(object.fields)
] = Map.values(object.fields) |> Enum.sort_by(& &1.name)

assert [:valued_entity] = object.interfaces
end
Expand Down

0 comments on commit bc8a1c5

Please sign in to comment.