Skip to content

Cannot generate SDL for :persistent_term schema #1054

@dolfinus

Description

@dolfinus

Environment

  • Elixir version (elixir -v): 1.11.3
  • Absinthe version (mix deps | grep absinthe): 1.6.3
  • Client Framework and version (Relay, Apollo, etc): -

Expected behavior

If I try to execute absinthe.schema.sdl or absinthe.schema.json, I expect to see a file output:

absinthe.schema.sdl --schema ArkenstonWeb.Schema graphql/schema.graphql
# graphql/schema.graphql is created and filled up with schema SDL

absinthe.schema.json --schema ArkenstonWeb.Schema --pretty graphql/schema.json
# graphql/schema.json is created and filled up with schema JSON

Actual behavior

It is broken when I use a :persistent_term schema:
https://github.com/dolfinus/arkenston-backend/runs/2160087638

* creating graphql
* creating graphql/schema.graphql
** (ArgumentError) argument error
    :persistent_term.get({Absinthe.Schema.PersistentTerm, ArkenstonWeb.Schema})
    (absinthe 1.6.3) lib/absinthe/schema/persistent_term.ex:91: Absinthe.Schema.PersistentTerm.get/1
    (absinthe 1.6.3) lib/absinthe/schema/persistent_term.ex:51: Absinthe.Schema.PersistentTerm.__absinthe_type__/2
    (absinthe 1.6.3) lib/absinthe/phase/schema.ex:107: Absinthe.Phase.Schema.set_schema_node/4
    (absinthe 1.6.3) lib/absinthe/phase/schema.ex:71: anonymous fn/4 in Absinthe.Phase.Schema.set_children/3
    (absinthe 1.6.3) lib/absinthe/blueprint/transform.ex:16: anonymous fn/3 in Absinthe.Blueprint.Transform.prewalk/2
    (absinthe 1.6.3) lib/absinthe/blueprint/transform.ex:109: Absinthe.Blueprint.Transform.walk/4
    (elixir 1.11.3) lib/enum.ex:1533: Enum."-map_reduce/3-lists^mapfoldl/2-0-"/3

Relevant Schema/Middleware Code

https://github.com/dolfinus/arkenston-backend/blob/68b588fa0b56aaed256d4836a136e4cff1b6f25f/lib/arkenston_web/schema.ex#L1-L5

defmodule ArkenstonWeb.Schema do
  use Absinthe.Schema

  @schema_provider Absinthe.Schema.PersistentTerm
...
end

According to documentation https://hexdocs.pm/absinthe/Absinthe.Schema.PersistentTerm.html I've added this line to my supervisor tree:
https://github.com/dolfinus/arkenston-backend/blob/68b588fa0b56aaed256d4836a136e4cff1b6f25f/lib/arkenston/application.ex#L19

{Absinthe.Schema, MyAppWeb.Schema}

It works absolutely fine in staging or tests because Application is being started here.
But schema export command does not start it, and IMHO is should not do that because it may require to start too many things, like a database.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions