Skip to content

Commit 26143ab

Browse files
committed
remove compile time dependency creation in import_types
1 parent 8f9816a commit 26143ab

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

lib/absinthe/schema/notation.ex

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1416,13 +1416,22 @@ defmodule Absinthe.Schema.Notation do
14161416
```
14171417
"""
14181418
defmacro import_types(type_module_ast, opts \\ []) do
1419-
env = __CALLER__
1419+
# Ideally prevent introducing compile-time dependencies.
1420+
ast =
1421+
if Macro.quoted_literal?(pipes) do
1422+
Macro.prewalk(type_module_ast, &expand_alias(&1, __CALLER__))
1423+
else
1424+
Macro.expand(type_module_ast, __CALLER__)
1425+
end
14201426

1421-
type_module_ast
1422-
|> Macro.expand(env)
1423-
|> do_import_types(env, opts)
1427+
do_import_types(ast, env, opts)
14241428
end
14251429

1430+
defp expand_alias({:__aliases__, _, _} = alias, env),
1431+
do: Macro.expand(alias, %{env | function: {:__absinthe_function_n__, 1}})
1432+
1433+
defp expand_alias(other, _env), do: other
1434+
14261435
@placement {:import_directives, [toplevel: true]}
14271436
@doc """
14281437
Import directives from another module

0 commit comments

Comments
 (0)