Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Absinthe 1.7.7 mix absinthe.schema.sdl breaks when using absinthe_relay connections #1328

Closed
halostatue opened this issue Jul 19, 2024 · 6 comments

Comments

@halostatue
Copy link

halostatue commented Jul 19, 2024

Environment

  • Elixir version (elixir -v): 1.15.8
  • Absinthe version (mix deps | grep absinthe): 1.7.7
  • Client Framework and version (Relay, Apollo, etc): n/a

Expected behavior

I’m still trying to figure out how to create a minimal reproduction as well as figure out a potential fix, but I wanted to raise this ASAP in case someone else has seen it or has an idea on how to better test it and/or resolve it.

Given a Relay schema (we use modern) that looks something like this (super simplified):

node object(:foo) do
  field :bar, :string
end

connection node_type: :foo

With Absinthe 1.7.6, mix absinthe.schema.sdl generates the appropriate schema.graphql. With Absinthe 1.7.7, mix absinthe.schema.sdl fails to generate the schema. Modifying the generator to inspect the output includes an Absinthe.Phase.Error:

   %Absinthe.Phase.Error{
     message: "In field Edges, :foo_edge is not defined in your schema.\n\nTypes must exist if referenced.\n",
     phase: Absinthe.Phase.Schema.Validation.TypeReferencesExist,
     …

If, however, I modify the schema to be:

node object(:foo) do
  field :bar, :string
end

connection node_type: :foo do
  edge do
    import_fields :foo
  end
end

The foo_edge is defined again and the SDL is generated again.

@halostatue
Copy link
Author

As noted, I have a workaround, but it feels weird that I have to explicitly declare the edges for the case where I am generating the SDL. This is not required or showing any errors during normal compile (but I’m not sure whether the references exists pass is done during compile).

@benwilson512
Copy link
Contributor

Hey have you tried using main? There was a bug fix that may be related to this.

@halostatue
Copy link
Author

I had not tried main. #1326 does fix this issue. Probably worth putting in the release notes when released, as the "workarounds" didn't actually work, they just seemed to work by suppressing the errors and not actually resolving anything.

@halostatue
Copy link
Author

Looking forward to 1.7.8 when released.

@maxsalven
Copy link

As a related issue, if you use PersistentTerm with Absinthe.Schema in the application children, then the application will compile initially, but will fail on subsequent compilations.

mix test
** (Mix) Could not start application absinthe_bug: AbsintheBug.Application.start(:normal, []) returned an error: shutdown: failed to start child: {Absinthe.Schema, AbsintheBugWeb.Schema}
    ** (EXIT) an exception was raised:
        ** (Absinthe.Schema.Error) Compilation failed:
---------------------------------------
## Locations
/Volumes/Development/github/absinthe_bug/lib/absinthe_bug_web/schema/queries.ex:5

In field Edges, :post_edge is not defined in your schema.

Types must exist if referenced.

It looks like main fixes this flavor of the problem as well.

This is a breaking error, hopefully a patch release can be published soon.

@benwilson512
Copy link
Contributor

v1.7.8 has been pushed with this fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants