Apparently, Hashnode has updated its GraphQL API - so much so that the view in my old post - Blog with a View - is no longer accurate. It will still run, but it won’t return any data.
Fortunately, the fix is pretty simple. Use this view instead of the one mentioned in the post, and it should still work:
create or replace view blog_v
as
with json as
(
select
apex_web_service.make_rest_request
(
p_url=> 'https://gql.hashnode.com'
,p_http_method => 'POST'
,p_body => '{ "query" : "query Publication '
|| ' { publication(host: \"spendolini.blog\") '
|| ' { id title posts(first: 10) '
|| ' { edges '
|| ' { node '
|| ' { id title subtitle url slug brief publishedAt reactionCount responseCount content { markdown } coverImage { url } '
|| ' } '
|| ' } totalDocuments '
|| ' } '
|| ' } '
|| ' }" '
|| ' }'
) as val
from
dual
)
select
t.id
,to_timestamp(t.date_added, 'YYYY-MM-DD"T"HH24:MI:SS.FF"Z"') as date_added
,t.slug
,'https://spendolini.blog/' || t.slug as url
,t.title
,t.brief
,t.cover_image
,t.popularity
,t.total_reactions
,t.content
from
json,
json_table
(
json.val
,'$.data.publication.posts.edges.node[*]'
columns
(
id varchar2(1000) path '$.id'
,slug varchar2(1000) path '$.slug'
,title varchar2(1000) path '$.title'
,brief varchar2(1000) path '$.brief'
,cover_image varchar2(1000) path '$.coverImage.url'
,date_added varchar2(1000) path '$.publishedAt'
,popularity number path '$.popularity'
,total_reactions number path '$.reactionCount'
,content clob path '$.content.markdown'
)
) as t;
There’s also a new GraphQL Playground for Hashnode’s APIs that’s worth checking out.