How do I create resources with associated relationships?

When dealing with a 1:N relationship between diaries and photos, I would like to know how to create a diary in such a way that its associated photos are also simultaneously generated. What would be the appropriate approach or method for achieving this?

diary resource

---
actions do
    defaults [:read, :update, :destroy]

    create :create do
      argument :photos, {:array, :map}
      primary? true

      change manage_relationship(
               :photos,
               type: :create
             )
    end
 end

relationships do
    has_many :photos, DiaryPhoto
  end
end

diary_photo resource

...
relationships do
    belongs_to :diary, Diary do
      attribute_writable? true
    end
 end

code

Diary
|> Ash.Changeset.for_create(:create, 
%{title: "diary title",
 ...
}, 
photos: [
    %{
      file_name: "name",
      url: "url"
    },
    %{
      file_name: "name",
      url: "url"
    },
  ])
|> Diary.create()

When running the above code, only the diary is created.
The photo resources are not being created.
I would like the photos to be created along with it.

I think it should be

Diary
|> Ash.Changeset.for_create(:create, 
%{title: "diary title",
    photos: [
      %{
        file_name: "name",
        url: "URL"
      },
      %{
        file_name: "name",
        url: "URL"
      },
     ],
 ...
})
|> Diary.create()

I’m a little embarrassed looking at your answers. Thank you for answering

I think we all have moments like this. At least I know I have :wink: