From cacec2de1d0fdc04c34b9080e8ee6817a4edce06 Mon Sep 17 00:00:00 2001 From: Zach Daniel Date: Wed, 11 Nov 2020 22:53:53 -0500 Subject: [PATCH] improvement: add more NonNulls --- lib/resource/resource.ex | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/resource/resource.ex b/lib/resource/resource.ex index e63f4c4..6115d8b 100644 --- a/lib/resource/resource.ex +++ b/lib/resource/resource.ex @@ -387,7 +387,7 @@ defmodule AshGraphql.Resource do %Absinthe.Blueprint.Schema.InputValueDefinition{ name: "id", identifier: :id, - type: :id, + type: %Absinthe.Blueprint.TypeReference.NonNull{of_type: :id}, description: "The id of the record" } ] @@ -642,7 +642,7 @@ defmodule AshGraphql.Resource do identifier: :id, module: schema, name: "id", - type: :id + type: %Absinthe.Blueprint.TypeReference.NonNull{of_type: :id} } attribute -> @@ -676,7 +676,14 @@ defmodule AshGraphql.Resource do end) |> Enum.map(fn %{cardinality: :one} = relationship -> - type = Resource.type(relationship.destination) + type = + if relationship.type == :belongs_to && relationship.required? do + %Absinthe.Blueprint.TypeReference.NonNull{ + of_type: Resource.type(relationship.destination) + } + else + Resource.type(relationship.destination) + end %Absinthe.Blueprint.Schema.FieldDefinition{ identifier: relationship.name,