Ash FrameworkAF
Ash Framework3y ago
5 replies
skander

GraphQL NewType Non-null?

I'm surfacing a calculated map as its own type in GraphQL and trying to make the fields non-nullable, but can't seem to get it working. I've also tried dropping the allow_nil?s into constraints key. Am I holding it wrong?

defmodule MyApp.Types.LatLng do
  use Ash.Type.NewType,
    subtype_of: :map,
    constraints: [
      fields: [
        lat: [type: :float, allow_nil?: false],
        lng: [type: :float, allow_nil?: false]
      ]
    ]

  def graphql_type(_), do: :lat_lng
end
image.png
Was this page helpful?