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

Ensure @external_resource is set for import_sdl :path opt #631

Merged
merged 1 commit into from
Nov 7, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions lib/absinthe/schema/notation.ex
Original file line number Diff line number Diff line change
Expand Up @@ -1465,9 +1465,20 @@ defmodule Absinthe.Schema.Notation do
defp do_import_sdl(nil, opts) do
case Keyword.fetch(opts, :path) do
{:ok, path} ->
reader = quote do: File.read!(unquote(path))
do_import_sdl(reader, Keyword.delete(opts, :path))

[
quote do
@__absinthe_import_sdl_path__ unquote(path)
end,
do_import_sdl(
quote do
File.read!(@__absinthe_import_sdl_path__)
end,
Keyword.delete(opts, :path)
),
quote do
@external_resource @__absinthe_import_sdl_path__
end
]
:error ->
raise Absinthe.Schema.Notation.Error,
"Must provide `:path` option to `import_sdl` unless passing a raw SDL string as the first argument"
Expand Down