Skip to content

Commit

Permalink
Merge pull request #240 from binaryseed/fix-valid-check
Browse files Browse the repository at this point in the history
Fix schema valid check
  • Loading branch information
benwilson512 authored Dec 7, 2020
2 parents b17dc11 + fc715ee commit dc234e1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions lib/absinthe/plug.ex
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,13 @@ defmodule Absinthe.Plug do
end

defp valid_schema_module?(module) do
is_atom(module) &&
Code.ensure_loaded?(module) &&
Absinthe.Schema in Keyword.get(module.__info__(:attributes), :behaviour, [])
with true <- is_atom(module),
{:module, _} <- Code.ensure_compiled(module),
true <- Absinthe.Schema in Keyword.get(module.__info__(:attributes), :behaviour, []) do
true
else
_ -> false
end
end

@doc false
Expand Down
2 changes: 1 addition & 1 deletion test/lib/absinthe/plug_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ defmodule Absinthe.PlugTest do
end

assert_raise ArgumentError, @message_matcher, fn ->
Absinthe.Plug.init(schema: "not even a module")
Absinthe.Plug.init(schema: "not even an atom")
end
end

Expand Down

0 comments on commit dc234e1

Please sign in to comment.