absinthe-graphql / absinthe_plug

Plug support for Absinthe, the GraphQL toolkit for Elixir
https://hex.pm/packages/absinthe_plug
MIT License
261 stars 163 forks source link

Better errors for schema module validation failures #279

Open grantwest opened 1 year ago

grantwest commented 1 year ago

Addresses 2 schema module validation issues:

Use Code.ensure_compiled!/1 rather than Code.ensure_compiled/1 to avoid masking compile issues and avoid potential race conditions. The existing pattern is specifically warned against in the elixir docs: https://hexdocs.pm/elixir/1.14/Code.html#module-code-loading-on-the-erlang-vm

With the current code it is possible to get theis not valid Absinthe.Schema error even though the issue is actually a failure to compile another module. This creates a painful experience.

The second improvement is to specify exactly why a schema has failed validation. If a validation fails, the next question asked is why? This change answers that question immediately, rather than making the user change absinthe_plug code to debug.

Because Code.ensure_compiled!/1 is introduced in elixir 1.12 this commit also bumps the minimum elixir version up to 1.12.

grantwest commented 1 year ago

It looks like Code.ensure_compiled!/1 was added in elixir 1.12.0. Are you open to bumping the minimum elixir version up to 1.12.0 for the next release? If so, do you want a separate PR or should I do it in this one?

benwilson512 commented 1 year ago

I am open to bumping the Elixir requirement to 1.12.0

grantwest commented 1 year ago

Ok, I bumped the min elixir version in this same commit to maintain the reason for the bump in the commit history.