Skip to content
New issue

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

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

Already on GitHub? # to your account

Render null default values in SDL #1032

Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions lib/absinthe/language/input_value_definition.ex
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ defmodule Absinthe.Language.InputValueDefinition do
defp to_term(%Language.ListValue{values: values}),
do: Enum.map(values, &to_term/1)

defp to_term(%Language.NullValue{}),
do: nil

defp to_term(%Language.ObjectValue{fields: fields}),
do: Enum.into(fields, %{}, &{String.to_atom(&1.name), to_term(&1.value)})

Expand Down
3 changes: 3 additions & 0 deletions lib/absinthe/schema/notation/sdl_render.ex
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,9 @@ defmodule Absinthe.Schema.Notation.SDL.Render do
defp render_value(%Blueprint.Input.Value{raw: raw}),
do: render_value(raw)

defp render_value(%Blueprint.Input.Null{}),
do: "null"

defp render_value(%Blueprint.Input.Object{fields: fields}) do
default_fields = Enum.map(fields, &render_value/1)
concat(["{", join(default_fields, ", "), "}"])
Expand Down
1 change: 1 addition & 0 deletions test/absinthe/schema/sdl_render_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ defmodule Absinthe.Schema.SdlRenderTest do
defaultInputArg(input: ComplexInput = {foo: "bar"}): String
defaultListArg(things: [String] = ["ThisThing"]): [String]
defaultEnumArg(category: Category = NEWS): Category
defaultNullStringArg(name: String = null): String
animal: Animal
}

Expand Down