Absinthe import_types doesn't require the imported module?

When I do this

  import_types(Web.GraphQL.Types.{
    PublicKey,
    Friendship,
    User,
    Account,
    VoiceMessage,
    Contact,
    Crash,
    Complaint
  })

I get

== Compilation error in file lib/web/graphql/schema.ex ==
** (ArgumentError) module Elixir.Web.GraphQL.Types.Friendship is not available
    lib/absinthe/schema/notation.ex:1269: anonymous fn/4 in Absinthe.Schema.Notation.do_import_types/2
    (elixir) lib/enum.ex:1899: Enum."-reduce/3-lists^foldl/2-0-"/3
    lib/absinthe/schema/notation.ex:1263: Absinthe.Schema.Notation.do_import_types/2
    expanding macro: Absinthe.Schema.Notation.import_types/1
    lib/web/graphql/schema.ex:10: Web.GraphQL.Schema (module)
    (elixir) lib/kernel/parallel_compiler.ex:198: anonymous fn/4 in Kernel.ParallelCompiler.spawn_workers/6

but if I require Friendship,

  require Web.GraphQL.Types.Friendship

  import_types(Web.GraphQL.Types.{
    PublicKey,
    Friendship,
    User,
    Account,
    VoiceMessage,
    Contact,
    Crash,
    Complaint
  })

the error is raised for another module (now User)

== Compilation error in file lib/web/graphql/anon_schema.ex ==
** (ArgumentError) module Elixir.Web.GraphQL.Types.User is not available
    lib/absinthe/schema/notation.ex:1269: anonymous fn/4 in Absinthe.Schema.Notation.do_import_types/2
    (elixir) lib/enum.ex:1899: Enum."-reduce/3-lists^foldl/2-0-"/3
    lib/absinthe/schema/notation.ex:1263: Absinthe.Schema.Notation.do_import_types/2
    expanding macro: Absinthe.Schema.Notation.import_types/1
    lib/web/graphql/anon_schema.ex:9: Web.GraphQL.AnonSchema (module)
    (elixir) lib/kernel/parallel_compiler.ex:198: anonymous fn/4 in Kernel.ParallelCompiler.spawn_workers/6

and in a different schema … But that’s probably not important (requireing it there also solves the issue).

Yeah, this is a known bug, we’d be happy to get some help from people who know more about this stuff. Our best bet might honestly be to just have that form of the macro turn it into a bunch of discrete

import_types Web.GraphQL.Types.PublicKey
import_types Web.GraphQL.Types.Frienship
...
2 Likes