Hi guys.
I am building graphql backend server using absinthe and phoenix.
My app use Youtube Data Api to get video list from specific channel.
But Api response from youtube data api seems not following elixir standard for the key of map.
It looks like this.
%GoogleApi.YouTube.V3.Model.SearchResultSnippet {
channelId: "some channel id",
channelTitle: "some channel title",
.....
}
in My schema file
object :snippet do
field :channel_id, :string
field :channel_title, :string
....
end
But query result returns null for channel_id, and channel_title.
So I just do like this.
object :snippet do
field :channel_id, :string do
resolve(fn parent, _, _ ->
channel_id = Map.get(parent, :channelId)
{:ok, channel_id}
end)
end
end
then it works.
But I don’t want to repeat this for every field.
Is there any way solve this problem using middleware in Absinthe?