Skip to content

Commit

Permalink
Merge pull request #249 from binaryseed/fix-update_config
Browse files Browse the repository at this point in the history
Fix update_config bug
  • Loading branch information
benwilson512 authored Feb 5, 2021
2 parents 5e8fdb9 + a8de373 commit 63be138
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
5 changes: 3 additions & 2 deletions lib/absinthe/plug.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
defmodule Absinthe.Plug.Mixfile do
use Mix.Project

@version "1.5.4"
@version "1.5.5"

def project do
[
Expand Down
13 changes: 13 additions & 0 deletions test/lib/absinthe/plug_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 63be138

Please sign in to comment.