Better errors for schema module validation failures #279
+34
−33
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Addresses 2 schema module validation issues:
Use
Code.ensure_compiled!/1
rather thanCode.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-vmWith the current code it is possible to get the
is 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.