Skip to content

Commit 7495d88

Browse files
committed
fix: use Code.ensure_compiled! at compile time
While investigating the changes in this PR: elixir-lang/elixir#14451 I encountered an error about not being able to load a module at this line, implying this is called at compile time. @josevalim pointed out that `Code.ensure_loaded!/1` will have no effect at compile time, and so this was really just relying on compile order and would be non-deterministic. `Code.ensure_compiled!/1` is a superset of `Code.ensure_loaded!/1` and will work at compile time to ensure the depended on module is compiled. This would appear to solve absinthe-graphql#1351.
1 parent f88c226 commit 7495d88

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/absinthe/schema.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ defmodule Absinthe.Schema do
365365
def apply_modifiers(pipeline, schema, opts \\ []) do
366366
Enum.reduce(schema.__absinthe_pipeline_modifiers__(), pipeline, fn
367367
{module, function}, pipeline ->
368-
Code.ensure_loaded!(module)
368+
Code.ensure_compiled!(module)
369369

370370
cond do
371371
function_exported?(module, function, 1) ->
@@ -379,7 +379,7 @@ defmodule Absinthe.Schema do
379379
end
380380

381381
module, pipeline ->
382-
Code.ensure_loaded!(module)
382+
Code.ensure_compiled!(module)
383383

384384
cond do
385385
function_exported?(module, :pipeline, 1) ->

0 commit comments

Comments
 (0)