Skip to content
Open
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
26 changes: 8 additions & 18 deletions .github/workflows/elixir.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,43 +16,33 @@ jobs:
# see https://hexdocs.pm/elixir/compatibility-and-deprecations.html#between-elixir-and-erlang-otp
matrix:
elixir:
- "1.13"
- "1.14"
- "1.15"
- "1.16"
- "1.17"
- "1.18"
otp:
- "24"
- "25"
- "26"
- "27"
- "28"
include:
- elixir: "1.18"
otp: "27"
otp: "28"
format: true
exclude:
- elixir: "1.13"
otp: "27"
- elixir: "1.13"
otp: "26"
- elixir: "1.13"
otp: "25"
- elixir: "1.14"
otp: "26"
- elixir: "1.14"
otp: "27"
- elixir: "1.15"
otp: "27"
- elixir: "1.15"
otp: "28"
- elixir: "1.16"
otp: "27"
- elixir: "1.16"
otp: "28"
- elixir: "1.17"
otp: "24"
- elixir: "1.18"
otp: "24"
otp: "28"

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5

- uses: erlef/setup-beam@v1
with:
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ defmodule Absinthe.Plug.Mixfile do
[
app: :absinthe_plug,
version: @version,
elixir: "~> 1.13",
elixir: "~> 1.15",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

build_embedded: Mix.env() == :prod,
start_permanent: Mix.env() == :prod,
elixirc_paths: elixirc_paths(Mix.env()),
Expand Down
25 changes: 13 additions & 12 deletions mix.lock
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
%{
"absinthe": {:hex, :absinthe, "1.7.3", "128f9de8d8feab761a50483011c2652074de0a670316d0e24a4979daeb460c8f", [:mix], [{:dataloader, "~> 1.0.0", [hex: :dataloader, repo: "hexpm", optional: true]}, {:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}, {:nimble_parsec, "~> 1.2.2 or ~> 1.3.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}, {:opentelemetry_process_propagator, "~> 0.2.1", [hex: :opentelemetry_process_propagator, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "6def91514f023832dbb3433baa166366881648932211f2e8146f9792b08b7bb3"},
"dialyxir": {:hex, :dialyxir, "1.4.5", "ca1571ac18e0f88d4ab245f0b60fa31ff1b12cbae2b11bd25d207f865e8ae78a", [:mix], [{:erlex, ">= 0.2.7", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "b0fb08bb8107c750db5c0b324fa2df5ceaa0f9307690ee3c1f6ba5b9eb5d35c3"},
"absinthe": {:hex, :absinthe, "1.7.10", "b33471b593260f148d05e4d771d1857e07b70a680f89cfa75184098bef4ec893", [:mix], [{:dataloader, "~> 1.0.0 or ~> 2.0", [hex: :dataloader, repo: "hexpm", optional: true]}, {:decimal, "~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}, {:nimble_parsec, "~> 1.2.2 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}, {:opentelemetry_process_propagator, "~> 0.2.1 or ~> 0.3", [hex: :opentelemetry_process_propagator, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "ffda95735364c041a65a4b0e02ffb04eabb1e52ab664fa7eeecefb341449e8c2"},
"dialyxir": {:hex, :dialyxir, "1.4.6", "7cca478334bf8307e968664343cbdb432ee95b4b68a9cba95bdabb0ad5bdfd9a", [:mix], [{:erlex, ">= 0.2.7", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "8cf5615c5cd4c2da6c501faae642839c8405b49f8aa057ad4ae401cb808ef64d"},
"earmark": {:hex, :earmark, "1.4.4", "4821b8d05cda507189d51f2caeef370cf1e18ca5d7dfb7d31e9cafe6688106a4", [:mix], [], "hexpm", "1f93aba7340574847c0f609da787f0d79efcab51b044bb6e242cae5aca9d264d"},
"earmark_parser": {:hex, :earmark_parser, "1.4.10", "6603d7a603b9c18d3d20db69921527f82ef09990885ed7525003c7fe7dc86c56", [:mix], [], "hexpm", "8e2d5370b732385db2c9b22215c3f59c84ac7dda7ed7e544d7c459496ae519c0"},
"earmark_parser": {:hex, :earmark_parser, "1.4.44", "f20830dd6b5c77afe2b063777ddbbff09f9759396500cdbe7523efd58d7a339c", [:mix], [], "hexpm", "4778ac752b4701a5599215f7030989c989ffdc4f6df457c5f36938cc2d2a2750"},
"erlex": {:hex, :erlex, "0.2.7", "810e8725f96ab74d17aac676e748627a07bc87eb950d2b83acd29dc047a30595", [:mix], [], "hexpm", "3ed95f79d1a844c3f6bf0cea61e0d5612a42ce56da9c03f01df538685365efb0"},
"ex_doc": {:hex, :ex_doc, "0.23.0", "a069bc9b0bf8efe323ecde8c0d62afc13d308b1fa3d228b65bca5cf8703a529d", [:mix], [{:earmark_parser, "~> 1.4.0", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}], "hexpm", "f5e2c4702468b2fd11b10d39416ddadd2fcdd173ba2a0285ebd92c39827a5a16"},
"jason": {:hex, :jason, "1.2.2", "ba43e3f2709fd1aa1dce90aaabfd039d000469c05c56f0b8e31978e03fa39052", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "18a228f5f0058ee183f29f9eae0805c6e59d61c3b006760668d8d18ff0d12179"},
"makeup": {:hex, :makeup, "1.0.5", "d5a830bc42c9800ce07dd97fa94669dfb93d3bf5fcf6ea7a0c67b2e0e4a7f26c", [:mix], [{:nimble_parsec, "~> 0.5 or ~> 1.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "cfa158c02d3f5c0c665d0af11512fed3fba0144cf1aadee0f2ce17747fba2ca9"},
"makeup_elixir": {:hex, :makeup_elixir, "0.14.1", "4f0e96847c63c17841d42c08107405a005a2680eb9c7ccadfd757bd31dabccfb", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "f2438b1a80eaec9ede832b5c41cd4f373b38fd7aa33e3b22d9db79e640cbde11"},
"mime": {:hex, :mime, "2.0.5", "dc34c8efd439abe6ae0343edbb8556f4d63f178594894720607772a041b04b02", [:mix], [], "hexpm", "da0d64a365c45bc9935cc5c8a7fc5e49a0e0f9932a761c55d6c52b142780a05c"},
"nimble_parsec": {:hex, :nimble_parsec, "1.3.1", "2c54013ecf170e249e9291ed0a62e5832f70a476c61da16f6aac6dca0189f2af", [:mix], [], "hexpm", "2682e3c0b2eb58d90c6375fc0cc30bc7be06f365bf72608804fb9cffa5e1b167"},
"plug": {:hex, :plug, "1.14.2", "cff7d4ec45b4ae176a227acd94a7ab536d9b37b942c8e8fa6dfc0fff98ff4d80", [:mix], [{:mime, "~> 1.0 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_crypto, "~> 1.1.1 or ~> 1.2", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4.3 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "842fc50187e13cf4ac3b253d47d9474ed6c296a8732752835ce4a86acdf68d13"},
"plug_crypto": {:hex, :plug_crypto, "1.2.5", "918772575e48e81e455818229bf719d4ab4181fcbf7f85b68a35620f78d89ced", [:mix], [], "hexpm", "26549a1d6345e2172eb1c233866756ae44a9609bd33ee6f99147ab3fd87fd842"},
"telemetry": {:hex, :telemetry, "1.2.1", "68fdfe8d8f05a8428483a97d7aab2f268aaff24b49e0f599faa091f1d4e7f61c", [:rebar3], [], "hexpm", "dad9ce9d8effc621708f99eac538ef1cbe05d6a874dd741de2e689c47feafed5"},
"ex_doc": {:hex, :ex_doc, "0.38.4", "ab48dff7a8af84226bf23baddcdda329f467255d924380a0cf0cee97bb9a9ede", [:mix], [{:earmark_parser, "~> 1.4.44", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_c, ">= 0.1.0", [hex: :makeup_c, repo: "hexpm", optional: true]}, {:makeup_elixir, "~> 0.14 or ~> 1.0", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1 or ~> 1.0", [hex: :makeup_erlang, repo: "hexpm", optional: false]}, {:makeup_html, ">= 0.1.0", [hex: :makeup_html, repo: "hexpm", optional: true]}], "hexpm", "f7b62346408a83911c2580154e35613eb314e0278aeea72ed7fedef9c1f165b2"},
"jason": {:hex, :jason, "1.4.4", "b9226785a9aa77b6857ca22832cffa5d5011a667207eb2a0ad56adb5db443b8a", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "c5eb0cab91f094599f94d55bc63409236a8ec69a21a67814529e8d5f6cc90b3b"},
"makeup": {:hex, :makeup, "1.2.1", "e90ac1c65589ef354378def3ba19d401e739ee7ee06fb47f94c687016e3713d1", [:mix], [{:nimble_parsec, "~> 1.4", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "d36484867b0bae0fea568d10131197a4c2e47056a6fbe84922bf6ba71c8d17ce"},
"makeup_elixir": {:hex, :makeup_elixir, "1.0.1", "e928a4f984e795e41e3abd27bfc09f51db16ab8ba1aebdba2b3a575437efafc2", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "7284900d412a3e5cfd97fdaed4f5ed389b8f2b4cb49efc0eb3bd10e2febf9507"},
"makeup_erlang": {:hex, :makeup_erlang, "1.0.2", "03e1804074b3aa64d5fad7aa64601ed0fb395337b982d9bcf04029d68d51b6a7", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "af33ff7ef368d5893e4a267933e7744e46ce3cf1f61e2dccf53a111ed3aa3727"},
"mime": {:hex, :mime, "2.0.7", "b8d739037be7cd402aee1ba0306edfdef982687ee7e9859bee6198c1e7e2f128", [:mix], [], "hexpm", "6171188e399ee16023ffc5b76ce445eb6d9672e2e241d2df6050f3c771e80ccd"},
"nimble_parsec": {:hex, :nimble_parsec, "1.4.2", "8efba0122db06df95bfaa78f791344a89352ba04baedd3849593bfce4d0dc1c6", [:mix], [], "hexpm", "4b21398942dda052b403bbe1da991ccd03a053668d147d53fb8c4e0efe09c973"},
"plug": {:hex, :plug, "1.18.1", "5067f26f7745b7e31bc3368bc1a2b818b9779faa959b49c934c17730efc911cf", [:mix], [{:mime, "~> 1.0 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_crypto, "~> 1.1.1 or ~> 1.2 or ~> 2.0", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4.3 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "57a57db70df2b422b564437d2d33cf8d33cd16339c1edb190cd11b1a3a546cc2"},
"plug_crypto": {:hex, :plug_crypto, "2.1.1", "19bda8184399cb24afa10be734f84a16ea0a2bc65054e23a62bb10f06bc89491", [:mix], [], "hexpm", "6470bce6ffe41c8bd497612ffde1a7e4af67f36a15eea5f921af71cf3e11247c"},
"telemetry": {:hex, :telemetry, "1.3.0", "fedebbae410d715cf8e7062c96a1ef32ec22e764197f70cda73d82778d61e7a2", [:rebar3], [], "hexpm", "7015fc8919dbe63764f4b4b87a95b7c0996bd539e0d499be6ec9d7f3875b79e6"},
}
3 changes: 2 additions & 1 deletion test/lib/absinthe/graphiql_test.exs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
defmodule Absinthe.Plug.GraphiQLTest do
use ExUnit.Case, async: true
use Plug.Test
import Plug.Test
import Plug.Conn
alias Absinthe.Plug.TestSchema

@query """
Expand Down
104 changes: 53 additions & 51 deletions test/lib/absinthe/plug_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ defmodule Absinthe.PlugTest do
alias Absinthe.Plug.TestSchema
alias Absinthe.Plug.TestPubSub

setup_all do
TestPubSub.start_link()
Absinthe.Subscription.start_link(TestPubSub)
:ok
end
Comment on lines +6 to +10
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sporadic error in CI:

  1) test Subscriptions over HTTP with Server Sent Events chunked response (standard) (Absinthe.PlugTest)
Error:      test/lib/absinthe/plug_test.exs:485
     ** (EXIT from #PID<0.332.0>) shutdown: failed to start child: Absinthe.Plug.TestPubSub.Registry
         ** (EXIT) already started: #PID<0.315.0>

.........................
Finished in 0.7 seconds (0.7s async, 0.00s sync)
86 tests, 1 failure

Randomized with seed 116773
Error: Process completed with exit code 2.


@foo_result ~s({"data":{"item":{"name":"Foo"}}})
@bar_result ~s({"data":{"item":{"name":"Bar"}}})

Expand Down Expand Up @@ -449,69 +455,65 @@ defmodule Absinthe.PlugTest do
assert expected == resp_body
end

test "Subscriptions over HTTP with Server Sent Events chunked response (non standard)" do
TestPubSub.start_link()
Absinthe.Subscription.start_link(TestPubSub)

query = "subscription {update}"
opts = Absinthe.Plug.init(schema: TestSchema, pubsub: TestPubSub, standard_sse: false)
describe "subscriptions" do
test "Subscriptions over HTTP with Server Sent Events chunked response (non standard)" do
query = "subscription {update}"
opts = Absinthe.Plug.init(schema: TestSchema, pubsub: TestPubSub, standard_sse: false)

request =
Task.async(fn ->
conn(:post, "/", query: query)
|> put_req_header("content-type", "application/json")
|> plug_parser
|> Absinthe.Plug.call(opts)
end)
request =
Task.async(fn ->
conn(:post, "/", query: query)
|> put_req_header("content-type", "application/json")
|> plug_parser
|> Absinthe.Plug.call(opts)
end)

Process.sleep(200)
Absinthe.Subscription.publish(TestPubSub, "FOO", update: "*")
Absinthe.Subscription.publish(TestPubSub, "BAR", update: "*")
send(request.pid, :close)
Process.sleep(200)
Absinthe.Subscription.publish(TestPubSub, "FOO", update: "*")
Absinthe.Subscription.publish(TestPubSub, "BAR", update: "*")
send(request.pid, :close)

conn = Task.await(request)
{_module, state} = conn.adapter
conn = Task.await(request)
{_module, state} = conn.adapter

events =
state.chunks
|> String.split()
|> Enum.map(&Jason.decode!/1)
events =
state.chunks
|> String.split()
|> Enum.map(&Jason.decode!/1)

assert length(events) == 2
assert Enum.member?(events, %{"data" => %{"update" => "FOO"}})
assert Enum.member?(events, %{"data" => %{"update" => "BAR"}})
end

test "Subscriptions over HTTP with Server Sent Events chunked response (standard)" do
TestPubSub.start_link()
Absinthe.Subscription.start_link(TestPubSub)
assert length(events) == 2
assert Enum.member?(events, %{"data" => %{"update" => "FOO"}})
assert Enum.member?(events, %{"data" => %{"update" => "BAR"}})
end

query = "subscription {update}"
opts = Absinthe.Plug.init(schema: TestSchema, pubsub: TestPubSub, standard_sse: true)
test "Subscriptions over HTTP with Server Sent Events chunked response (standard)" do
query = "subscription {update}"
opts = Absinthe.Plug.init(schema: TestSchema, pubsub: TestPubSub, standard_sse: true)

request =
Task.async(fn ->
conn(:post, "/", query: query)
|> put_req_header("content-type", "application/json")
|> plug_parser
|> Absinthe.Plug.call(opts)
end)
request =
Task.async(fn ->
conn(:post, "/", query: query)
|> put_req_header("content-type", "application/json")
|> plug_parser
|> Absinthe.Plug.call(opts)
end)

Process.sleep(200)
Absinthe.Subscription.publish(TestPubSub, "FOO", update: "*")
Absinthe.Subscription.publish(TestPubSub, "BAR", update: "*")
send(request.pid, :close)
Process.sleep(200)
Absinthe.Subscription.publish(TestPubSub, "FOO", update: "*")
Absinthe.Subscription.publish(TestPubSub, "BAR", update: "*")
send(request.pid, :close)

conn = Task.await(request)
{_module, state} = conn.adapter
conn = Task.await(request)
{_module, state} = conn.adapter

[event1, event2] = String.split(state.chunks, "\n\n", trim: true)
[event1, event2] = String.split(state.chunks, "\n\n", trim: true)

assert "event: next\ndata: " <> event1_data = event1
assert "event: next\ndata: " <> event2_data = event2
assert "event: next\ndata: " <> event1_data = event1
assert "event: next\ndata: " <> event2_data = event2

assert Jason.decode!(event1_data) == %{"data" => %{"update" => "FOO"}}
assert Jason.decode!(event2_data) == %{"data" => %{"update" => "BAR"}}
assert Jason.decode!(event1_data) == %{"data" => %{"update" => "FOO"}}
assert Jason.decode!(event2_data) == %{"data" => %{"update" => "BAR"}}
end
end

@query """
Expand Down
3 changes: 2 additions & 1 deletion test/support/test_case.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ defmodule Absinthe.Plug.TestCase do
defmacro __using__(_) do
quote do
use ExUnit.Case, async: true
use Plug.Test
import Plug.Test
import Plug.Conn
Comment on lines +5 to +6
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

    warning: use Plug.Test is deprecated. Please use `import Plug.Test` and `import Plug.Conn` directly instead.                          
                                               
    │                                                                                                                                     
  2 │   use Absinthe.Plug.TestCase             
    │   ~~~~~~~~~~~~~~~~~~~~~~~~~~                                                                                                                                                            
    │                             
    └─ test/lib/absinthe/plug_test.exs:2: Absinthe.PlugTest (module)                                                                                                                          
                                  
    warning: use Plug.Test is deprecated. Please use `import Plug.Test` and `import Plug.Conn` directly instead.                          
                                               
    │                                                                                                                                     
  3 │   use Absinthe.Plug.TestCase             
    │   ~~~~~~~~~~~~~~~~~~~~~~~~~~                                                                                                                                                            
    │                             
    └─ test/lib/absinthe/plug/transport_batching_test.exs:3: Absinthe.Plug.TransportBatchingTest (module)                                                                                     
                                  
    warning: use Plug.Test is deprecated. Please use `import Plug.Test` and `import Plug.Conn` directly instead.                          
                                               
    │                                                                                                                                     
  3 │   use Plug.Test                          
    │   ~~~~~~~~~~~~~                                                                                                                                                                         
    │                             
    └─ test/lib/absinthe/graphiql_test.exs:3: Absinthe.Plug.GraphiQLTest (module)                                                                                                             

    warning: use Plug.Test is deprecated. Please use `import Plug.Test` and `import Plug.Conn` directly instead.                                                                                                         
                                               
    │                                          
  2 │   use Absinthe.Plug.TestCase             
    │   ~~~~~~~~~~~~~~~~~~~~~~~~~~                                                                                                                                                            
    │                                                 
    └─ test/lib/absinthe/plug/document_provider_test.exs:2: Absinthe.Plug.DocumentProviderTest (module)                                                                                       
                                                                                               
    warning: use Plug.Test is deprecated. Please use `import Plug.Test` and `import Plug.Conn` directly instead.                                                                                                         
                                                                                               
    │                                                 
  2 │   use Absinthe.Plug.TestCase                    
    │   ~~~~~~~~~~~~~~~~~~~~~~~~~~                    
    │                                                 
    └─ test/lib/absinthe/plug/document_provider/compiled_test.exs:2: Absinthe.Plug.DocumentProvider.CompiledTest (module) 


import unquote(__MODULE__)
end
Expand Down