Handle empty object list in `prepare_activity_fields/1`
We were having reports of issues on our servers relating to fetching collections/communities, this fix attempts to solve this.
Relevant stacktrace:
07:41:00.420 [error] #PID<0.3331.2> running MoodleNetWeb.Endpoint (connection #PID<0.3330.2>, stream id 1) terminated
Server: <REDACTED> (http)
Request: POST /api/graphql
** (exit) an exception was raised:
** (ArgumentError) argument error
:erlang.hd([])
(moodle_net) lib/moodle_net_web/graph_ql/schema/activity_schema.ex:62: MoodleNetWeb.GraphQL.ActivitySchema.prepare_activity_fields/1
(moodle_net) lib/moodle_net_web/graph_ql/schema/activity_schema.ex:57: MoodleNetWeb.GraphQL.ActivitySchema.prepare/2
(elixir) lib/enum.ex:1336: Enum."-map/2-lists^map/1-0-"/2
(elixir) lib/enum.ex:1336: Enum."-map/2-lists^map/1-0-"/2
(moodle_net) lib/moodle_net_web/graph_ql/schema/moodle_net_schema.ex:364: MoodleNetWeb.GraphQL.MoodleNetSchema.calculate_connection_edges/2
(moodle_net) lib/moodle_net_web/graph_ql/schema/moodle_net_schema.ex:308: anonymous fn/4 in MoodleNetWeb.GraphQL.MoodleNetSchema.with_connection/1
(absinthe) lib/absinthe/resolution.ex:209: Absinthe.Resolution.call/2