Skip to content

Commit

Permalink
Upgrade dependencies (#34)
Browse files Browse the repository at this point in the history
elixir 1.6 -> 1.10
absinthe 1.4.0 -> 1.5
phoenix 1.4 -> 1.5
absinthe_phoenix 1.4.0 -> 2.0

Update resolution logic from local subscription changes
  • Loading branch information
athal7 authored Aug 30, 2021
1 parent 024e482 commit 1d98651
Show file tree
Hide file tree
Showing 13 changed files with 69 additions and 38 deletions.
4 changes: 2 additions & 2 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ services:
dockerfile: Dockerfile
args:
# Elixir Version: 1.9, 1.10, 1.10.4, ...
VARIANT: "1.9"
VARIANT: "1.10"
# Phoenix Version: 1.4.17, 1.5.4, ...
PHOENIX_VERSION: "1.4.17"
PHOENIX_VERSION: "1.5.4"
# Node Version: 10, 11, ...
NODE_VERSION: "10"

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest

container:
image: elixir:1.9.1-slim
image: elixir:1.10.4-slim

steps:
- uses: actions/checkout@v2.3.4
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ erl_crash.dump
/config/*.secret.exs
/priv/plts/*.plt
/priv/plts/*.plt.hash
/.elixir_ls
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ The package can be installed by adding `dvr` to your list of dependencies in `mi
```elixir
def deps do
[
{:dvr, "~> 1.0.0"}
{:dvr, "~> 1.1.0"}
]
end
```
Expand Down Expand Up @@ -180,7 +180,7 @@ defmodule MyApp.UserSocket do
assigns: %{__absinthe_schema__: MyApp.Schema}
)

defdelegate put_opts(socket, opts), to: Absinthe.Phoenix.Socket
defdelegate put_options(socket, opts), to: Absinthe.Phoenix.Socket
defdelegate put_schema(socket, schema), to: Absinthe.Phoenix.Socket
end
```
Expand Down
2 changes: 1 addition & 1 deletion config/test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ config :dvr_phoenix, DVR.Phoenix.TestEndpoint,
root: Path.dirname(__DIR__),
secret_key_base: "GSGmIoMRxcLfHBfBhtD/Powy7WaucKbLuB7BTMt41nkm5xS+8LfnXZYNsk6qKOo1",
render_errors: [accepts: ~w(json)],
pubsub: [name: DVR.Phoenix.PubSub, adapter: Phoenix.PubSub.PG2]
pubsub_server: DVR.Phoenix.PubSub
38 changes: 28 additions & 10 deletions lib/dvr/absinthe_channel.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ defmodule DVR.AbsintheChannel do
"""

if Code.ensure_loaded?(Absinthe.Subscription) do
@pipeline [
Absinthe.Phase.Document.Execution.Resolution,
Absinthe.Phase.Document.Result
]
alias Absinthe.{Phase, Pipeline, Subscription}

def handle_in("replay", %{"replayId" => replay_id, "subscriptionId" => doc_id}, socket) do
case DVR.search(replay_id) do
Expand Down Expand Up @@ -42,7 +39,7 @@ defmodule DVR.AbsintheChannel do

defp doc_id_topics(doc_id, socket) do
socket.endpoint
|> Absinthe.Subscription.registry_name()
|> Subscription.registry_name()
|> Registry.lookup({self(), doc_id})
|> Enum.map(fn {_self, field_key} -> field_key end)
end
Expand All @@ -51,16 +48,37 @@ defmodule DVR.AbsintheChannel do
topics
|> Enum.flat_map(fn topic ->
socket.endpoint
|> Absinthe.Subscription.get(topic)
|> Subscription.get(topic)
|> Enum.filter(fn {id, _doc} -> id == doc_id end)
|> Enum.map(fn {_id, doc} -> doc end)
end)
end

defp resolve(payload, %Absinthe.Blueprint{} = doc) do
doc.execution.root_value
|> put_in(payload)
|> Absinthe.Pipeline.run(@pipeline)
# From https://github.com/absinthe-graphql/absinthe/blob/master/lib/absinthe/subscription/local.ex#run_docset

defp resolve(payload, doc) do
pipeline =
doc.initial_phases
|> Pipeline.replace(
Phase.Telemetry,
{Phase.Telemetry, event: [:subscription, :publish, :start]}
)
|> Pipeline.without(Phase.Subscription.SubscribeSelf)
|> Pipeline.insert_before(
Phase.Document.Execution.Resolution,
{Phase.Document.OverrideRoot, root_value: payload}
)
|> Pipeline.upto(Phase.Document.Execution.Resolution)

pipeline = [
pipeline,
[
Phase.Document.Result,
{Phase.Telemetry, event: [:subscription, :publish, :stop]}
]
]

Pipeline.run(doc.source, pipeline)
end
end
end
11 changes: 6 additions & 5 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ defmodule DVR.MixProject do
def project do
[
app: :dvr,
version: "1.0.4",
elixir: "~> 1.6",
version: "1.1.0",
elixir: "~> 1.10",
elixirc_paths: elixirc_paths(Mix.env()),
docs: [main: "readme", extras: ["README.md"]],
package: package(),
Expand Down Expand Up @@ -45,9 +45,10 @@ defmodule DVR.MixProject do
[
{:ex_doc, "~> 0.19", only: :dev, runtime: false},
{:dialyxir, "~> 1.1.0", only: [:dev, :test], runtime: false},
{:phoenix, "~> 1.4", optional: true},
{:absinthe, "~> 1.4.0", optional: true},
{:absinthe_phoenix, "~> 1.4.0", optional: true}
{:phoenix, "~> 1.5", optional: true},
{:absinthe, "~> 1.5", optional: true},
{:absinthe_phoenix, "~> 2.0", optional: true},
{:jason, "~> 1.0", only: [:dev, :test]}
]
end
end
23 changes: 12 additions & 11 deletions mix.lock
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
%{
"absinthe": {:hex, :absinthe, "1.4.16", "0933e4d9f12652b12115d5709c0293a1bf78a22578032e9ad0dad4efee6b9eb1", [:mix], [{:dataloader, "~> 1.0.0", [hex: :dataloader, repo: "hexpm", optional: true]}, {:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "076b8bd9552f4966ba1242f412f6c439b731169a36a0ddaaffcd3893828f5bf6"},
"absinthe_phoenix": {:hex, :absinthe_phoenix, "1.4.3", "cea34e7ebbc9a252038c1f1164878ee86bcb108905fe462be77efacda15c1e70", [:mix], [{:absinthe, "~> 1.4.0", [hex: :absinthe, repo: "hexpm", optional: false]}, {:absinthe_plug, "~> 1.4.0", [hex: :absinthe_plug, repo: "hexpm", optional: false]}, {:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:phoenix, "~> 1.2", [hex: :phoenix, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 2.10.5 or ~> 2.11", [hex: :phoenix_html, repo: "hexpm", optional: true]}, {:phoenix_pubsub, "~> 1.0", [hex: :phoenix_pubsub, repo: "hexpm", optional: false]}, {:poison, "~> 2.0 or ~> 3.0", [hex: :poison, repo: "hexpm", optional: false]}], "hexpm", "e5c0783aac2d0ded1b43157ead0c1337a36d451c942ae412b48f6f97a64260ea"},
"absinthe_plug": {:hex, :absinthe_plug, "1.4.5", "f63d52a76c870cd5f11d4bed8f61351ab5c5f572c5eb0479a0137f9f730ba33d", [:mix], [{:absinthe, "~> 1.4.11", [hex: :absinthe, repo: "hexpm", optional: false]}, {:plug, "~> 1.3.2 or ~> 1.4", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "c02644250a54757b13ebf6db2fcba275a73b05465a969d894211ed46d9c5de6a"},
"decimal": {:hex, :decimal, "1.8.1", "a4ef3f5f3428bdbc0d35374029ffcf4ede8533536fa79896dd450168d9acdf3c", [:mix], [], "hexpm", "3cb154b00225ac687f6cbd4acc4b7960027c757a5152b369923ead9ddbca7aec"},
"absinthe": {:hex, :absinthe, "1.6.5", "b7bdb507824412c447806e08d80c8f231d51a1b40b1400e5d01bd7faf77ffda1", [: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, "~> 0.5 or ~> 1.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "a4f4ed3808467f1795baadbba24f1355e287b64e6b41ec0cfeb0713575ecb7a9"},
"absinthe_phoenix": {:hex, :absinthe_phoenix, "2.0.1", "112cb3468db2748a85bd8bd3f4d6d33f37408a96cb170077026ace96ddb1bab2", [:mix], [{:absinthe, "~> 1.5", [hex: :absinthe, repo: "hexpm", optional: false]}, {:absinthe_plug, "~> 1.5", [hex: :absinthe_plug, repo: "hexpm", optional: false]}, {:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:phoenix, "~> 1.5", [hex: :phoenix, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 2.13", [hex: :phoenix_html, repo: "hexpm", optional: true]}, {:phoenix_pubsub, "~> 2.0", [hex: :phoenix_pubsub, repo: "hexpm", optional: false]}], "hexpm", "e773adc876fbc84fb05a82e125d9c263f129520b36e5576554ffcb8cf49db445"},
"absinthe_plug": {:hex, :absinthe_plug, "1.5.8", "38d230641ba9dca8f72f1fed2dfc8abd53b3907d1996363da32434ab6ee5d6ab", [:mix], [{:absinthe, "~> 1.5", [hex: :absinthe, repo: "hexpm", optional: false]}, {:plug, "~> 1.4", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "bbb04176647b735828861e7b2705465e53e2cf54ccf5a73ddd1ebd855f996e5a"},
"decimal": {:hex, :decimal, "2.0.0", "a78296e617b0f5dd4c6caf57c714431347912ffb1d0842e998e9792b5642d697", [:mix], [], "hexpm", "34666e9c55dea81013e77d9d87370fe6cb6291d1ef32f46a1600230b1d44f577"},
"dialyxir": {:hex, :dialyxir, "1.1.0", "c5aab0d6e71e5522e77beff7ba9e08f8e02bad90dfbeffae60eaf0cb47e29488", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "07ea8e49c45f15264ebe6d5b93799d4dd56a44036cf42d0ad9c960bc266c0b9a"},
"earmark": {:hex, :earmark, "1.4.5", "62ffd3bd7722fb7a7b1ecd2419ea0b458c356e7168c1f5d65caf09b4fbdd13c8", [:mix], [], "hexpm", "b7d0e6263d83dc27141a523467799a685965bf8b13b6743413f19a7079843f4f"},
"earmark_parser": {:hex, :earmark_parser, "1.4.13", "0c98163e7d04a15feb62000e1a891489feb29f3d10cb57d4f845c405852bbef8", [:mix], [], "hexpm", "d602c26af3a0af43d2f2645613f65841657ad6efc9f0e361c3b6c06b578214ba"},
"earmark_parser": {:hex, :earmark_parser, "1.4.15", "b29e8e729f4aa4a00436580dcc2c9c5c51890613457c193cc8525c388ccb2f06", [:mix], [], "hexpm", "044523d6438ea19c1b8ec877ec221b008661d3c27e3b848f4c879f500421ca5c"},
"erlex": {:hex, :erlex, "0.2.6", "c7987d15e899c7a2f34f5420d2a2ea0d659682c06ac607572df55a43753aa12e", [:mix], [], "hexpm", "2ed2e25711feb44d52b17d2780eabf998452f6efda104877a3881c2f8c0c0c75"},
"ex_doc": {:hex, :ex_doc, "0.25.1", "4b736fa38dc76488a937e5ef2944f5474f3eff921de771b25371345a8dc810bc", [:mix], [{:earmark_parser, "~> 1.4.0", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "3200b0a69ddb2028365281fbef3753ea9e728683863d8cdaa96580925c891f67"},
"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.15.1", "b5888c880d17d1cc3e598f05cdb5b5a91b7b17ac4eaf5f297cb697663a1094dd", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.1", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "db68c173234b07ab2a07f645a5acdc117b9f99d69ebf521821d89690ae6c6ec8"},
"makeup_erlang": {:hex, :makeup_erlang, "0.1.1", "3fcb7f09eb9d98dc4d208f49cc955a34218fc41ff6b84df7c75b3e6e533cc65f", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "174d0809e98a4ef0b3309256cbf97101c6ec01c4ab0b23e926a9e17df2077cbb"},
"mime": {:hex, :mime, "1.3.1", "30ce04ab3175b6ad0bdce0035cba77bba68b813d523d1aac73d9781b4d193cf8", [:mix], [], "hexpm", "6cbe761d6a0ca5a31a0931bf4c63204bceb64538e664a8ecf784a9a6f3b875f1"},
"mime": {:hex, :mime, "2.0.1", "0de4c81303fe07806ebc2494d5321ce8fb4df106e34dd5f9d787b637ebadc256", [:mix], [], "hexpm", "7a86b920d2aedce5fb6280ac8261ac1a739ae6c1a1ad38f5eadf910063008942"},
"nimble_parsec": {:hex, :nimble_parsec, "1.1.0", "3a6fca1550363552e54c216debb6a9e95bd8d32348938e13de5eda962c0d7f89", [:mix], [], "hexpm", "08eb32d66b706e913ff748f11694b17981c0b04a33ef470e33e11b3d3ac8f54b"},
"phoenix": {:hex, :phoenix, "1.4.17", "1b1bd4cff7cfc87c94deaa7d60dd8c22e04368ab95499483c50640ef3bd838d8", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix_pubsub, "~> 1.1", [hex: :phoenix_pubsub, repo: "hexpm", optional: false]}, {:plug, "~> 1.8.1 or ~> 1.9", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 1.0 or ~> 2.0", [hex: :plug_cowboy, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "3a8e5d7a3d76d452bb5fb86e8b7bd115f737e4f8efe202a463d4aeb4a5809611"},
"phoenix_pubsub": {:hex, :phoenix_pubsub, "1.1.2", "496c303bdf1b2e98a9d26e89af5bba3ab487ba3a3735f74bf1f4064d2a845a3e", [:mix], [], "hexpm", "1f13f9f0f3e769a667a6b6828d29dec37497a082d195cc52dbef401a9b69bf38"},
"plug": {:hex, :plug, "1.10.3", "c9cebe917637d8db0e759039cc106adca069874e1a9034fd6e3fdd427fd3c283", [:mix], [{:mime, "~> 1.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", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "01f9037a2a1de1d633b5a881101e6a444bcabb1d386ca1e00bb273a1f1d9d939"},
"plug_crypto": {:hex, :plug_crypto, "1.1.2", "bdd187572cc26dbd95b87136290425f2b580a116d3fb1f564216918c9730d227", [:mix], [], "hexpm", "6b8b608f895b6ffcfad49c37c7883e8df98ae19c6a28113b02aa1e9c5b22d6b5"},
"phoenix": {:hex, :phoenix, "1.5.12", "75fddb14c720388eea93d33886166a690416a7ff8633fbd93f364355b6fe1166", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix_html, "~> 2.13 or ~> 3.0", [hex: :phoenix_html, repo: "hexpm", optional: true]}, {:phoenix_pubsub, "~> 2.0", [hex: :phoenix_pubsub, repo: "hexpm", optional: false]}, {:plug, "~> 1.10", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 1.0 or ~> 2.2", [hex: :plug_cowboy, repo: "hexpm", optional: true]}, {:plug_crypto, "~> 1.1.2 or ~> 1.2", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "8f0ae6734fcc18bbaa646c161e2febc46fb899eae43f82679b92530983324113"},
"phoenix_pubsub": {:hex, :phoenix_pubsub, "2.0.0", "a1ae76717bb168cdeb10ec9d92d1480fec99e3080f011402c0a2d68d47395ffb", [:mix], [], "hexpm", "c52d948c4f261577b9c6fa804be91884b381a7f8f18450c5045975435350f771"},
"plug": {:hex, :plug, "1.12.1", "645678c800601d8d9f27ad1aebba1fdb9ce5b2623ddb961a074da0b96c35187d", [: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", "d57e799a777bc20494b784966dc5fbda91eb4a09f571f76545b72a634ce0d30b"},
"plug_crypto": {:hex, :plug_crypto, "1.2.2", "05654514ac717ff3a1843204b424477d9e60c143406aa94daf2274fdd280794d", [:mix], [], "hexpm", "87631c7ad914a5a445f0a3809f99b079113ae4ed4b867348dd9eec288cecb6db"},
"poison": {:hex, :poison, "3.1.0", "d9eb636610e096f86f25d9a46f35a9facac35609a7591b3be3326e99a0484665", [:mix], [], "hexpm", "fec8660eb7733ee4117b85f55799fd3833eb769a6df71ccf8903e8dc5447cfce"},
"telemetry": {:hex, :telemetry, "0.4.2", "2808c992455e08d6177322f14d3bdb6b625fbcfd233a73505870d8738a2f4599", [:rebar3], [], "hexpm", "2d1419bd9dda6a206d7b5852179511722e2b18812310d304620c7bd92a13fcef"},
"telemetry": {:hex, :telemetry, "0.4.3", "a06428a514bdbc63293cd9a6263aad00ddeb66f608163bdec7c8995784080818", [:rebar3], [], "hexpm", "eb72b8365ffda5bed68a620d1da88525e326cb82a75ee61354fc24b844768041"},
}
2 changes: 1 addition & 1 deletion test/dvr/absinthe_test.exs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
defmodule DVR.AbsintheTest do
use DVR.DVRCase
use Phoenix.ChannelTest
import Phoenix.ChannelTest
use Absinthe.Phoenix.SubscriptionTest, schema: DVR.Absinthe.TestSchema

import Absinthe.Subscription, only: [publish: 3]
Expand Down
2 changes: 1 addition & 1 deletion test/dvr/channel_test.exs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
defmodule DVR.PhoenixChannelTest do
use DVR.DVRCase
use Phoenix.ChannelTest
import Phoenix.ChannelTest

@endpoint DVR.Phoenix.TestEndpoint

Expand Down
13 changes: 13 additions & 0 deletions test/support/dvr_case.ex
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,19 @@ defmodule DVR.DVRCase do
quote do
use ExUnit.Case

setup_all do
Absinthe.Test.prime(DVR.Absinthe.TestSchema)

children = [
{Phoenix.PubSub, name: DVR.Phoenix.PubSub},
DVR.Phoenix.TestEndpoint,
{Absinthe.Subscription, DVR.Phoenix.TestEndpoint}
]

{:ok, _} = Supervisor.start_link(children, strategy: :one_for_one)
:ok
end

setup do
:mnesia.clear_table(:dvr)
DVR.Store.init_store()
Expand Down
2 changes: 1 addition & 1 deletion test/support/endpoint.ex
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ defmodule DVR.Phoenix.TestEndpoint do
plug(Plug.Parsers,
parsers: [:urlencoded, :multipart, :json],
pass: ["*/*"],
json_decoder: Poison
json_decoder: Jason
)

plug(Plug.MethodOverride)
Expand Down
3 changes: 0 additions & 3 deletions test/test_helper.exs
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
{:ok, _} = DVR.Phoenix.TestEndpoint.start_link()
{:ok, _} = Absinthe.Subscription.start_link(DVR.Phoenix.TestEndpoint)

ExUnit.start(exclude: [:skip])

0 comments on commit 1d98651

Please sign in to comment.