From 78d13d172d6f9b8e18a37c73b761e83ac8032e16 Mon Sep 17 00:00:00 2001 From: Vince Foley Date: Thu, 4 Feb 2021 14:21:25 -0800 Subject: [PATCH 1/2] Fix update_config --- lib/absinthe/plug.ex | 5 +++-- test/lib/absinthe/plug_test.exs | 13 +++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/lib/absinthe/plug.ex b/lib/absinthe/plug.ex index aa2ebaf..5952346 100644 --- a/lib/absinthe/plug.ex +++ b/lib/absinthe/plug.ex @@ -320,11 +320,12 @@ defmodule Absinthe.Plug do end end - defp update_config(conn, config) do + @doc false + def update_config(conn, config) do config - |> update_config(:pubsub, conn) |> update_config(:raw_options, conn) |> update_config(:init_options, conn) + |> update_config(:pubsub, conn) end defp update_config(config, :pubsub, conn) do diff --git a/test/lib/absinthe/plug_test.exs b/test/lib/absinthe/plug_test.exs index 7a5364e..2f5ce2a 100644 --- a/test/lib/absinthe/plug_test.exs +++ b/test/lib/absinthe/plug_test.exs @@ -559,6 +559,19 @@ defmodule Absinthe.PlugTest do assert %{"errors" => [%{"message" => "No query!!"}]} = resp_body assert {"content-type", "text/who-knows; charset=utf-8"} in resp_headers end + + test "don't wipe out pubsub" do + config = Absinthe.Plug.init(schema: TestSchema, context: %{user_id: 1}) + + conn = + conn(:post, "/") + |> Absinthe.Plug.put_options(pubsub: PubSub) + + updated_config = Absinthe.Plug.update_config(conn, config) + + assert updated_config.context.pubsub == PubSub + assert updated_config.context.user_id == 1 + end end describe "assign_context/2" do From a8de373cc946c24b3a81471576e55bd3b53f53d3 Mon Sep 17 00:00:00 2001 From: Vince Foley Date: Thu, 4 Feb 2021 14:25:53 -0800 Subject: [PATCH 2/2] Changelog & version bump --- CHANGELOG.md | 4 ++++ mix.exs | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 39adbc1..d0312e2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v1.5.5 + +- Bug Fix: [Don't wipe out an existing pubsub value in context](https://github.com/absinthe-graphql/absinthe_plug/pull/249) + ## v1.5.4 - Feature: [Set all plug options via put_options](https://github.com/absinthe-graphql/absinthe_plug/pull/243) diff --git a/mix.exs b/mix.exs index ab09979..db4c349 100644 --- a/mix.exs +++ b/mix.exs @@ -1,7 +1,7 @@ defmodule Absinthe.Plug.Mixfile do use Mix.Project - @version "1.5.4" + @version "1.5.5" def project do [