Skip to content

Commit

Permalink
Support for non null args
Browse files Browse the repository at this point in the history
  • Loading branch information
SvenW committed Oct 8, 2021
1 parent 7ed5f98 commit affa92c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
1 change: 0 additions & 1 deletion lib/absinthe/blueprint/schema/enum_type_definition.ex
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ defmodule Absinthe.Blueprint.Schema.EnumTypeDefinition do
errors: [Absinthe.Phase.Error.t()]
}

@spec build(t, any) :: Absinthe.Type.Enum.t()
def build(type_def, _schema) do
%Absinthe.Type.Enum{
identifier: type_def.identifier,
Expand Down
9 changes: 8 additions & 1 deletion lib/absinthe/schema/notation/sdl_render.ex
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,14 @@ defmodule Absinthe.Schema.Notation.SDL.Render do
nil

value when is_atom(value) ->
definition = Enum.find(type_definitions, fn d -> input_value.type == d.identifier end)
typ =
case input_value.type do
%Absinthe.Blueprint.TypeReference.NonNull{of_type: t} -> t
%Absinthe.Blueprint.TypeReference.List{of_type: t} -> t
t -> t
end

definition = Enum.find(type_definitions, fn d -> typ == d.identifier end)

case definition do
nil ->
Expand Down
4 changes: 2 additions & 2 deletions test/absinthe/schema/sdl_render_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ defmodule Absinthe.Schema.SdlRenderTest do
arg :times, :integer, default_value: 10, description: "The number of times"
arg :time_interval, :integer
arg :time_string, :string, default_value: "2021"
arg :order_status, :order_status, default_value: :processing
arg :order_status, non_null(:order_status), default_value: :processing
end

field :search, :search_result
Expand Down Expand Up @@ -259,7 +259,7 @@ defmodule Absinthe.Schema.SdlRenderTest do
timeString: String = "2021"
orderStatus: OrderStatus = PROCESSING
orderStatus: OrderStatus! = PROCESSING
): String
search: SearchResult
}
Expand Down

0 comments on commit affa92c

Please sign in to comment.