Skip to main content

Command Palette

Search for a command to run...

Blog with a View: Update

Updated
2 min read
Blog with a View: Update
S

"Bumpy roads lead to beautiful places"

  • Senior Director @ Oracle 🧑‍💻
  • #orclapex fan since '99 🛠️
  • https://spendolini.blog 💻
  • Oracle Ace Alumni ♠️
  • Bleed Syracuse Orange 🍊
  • Golf when I can ⛳️
  • Austin, TX 🎸🍻
  • Views are my own 🫢

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.


Title Photo by David Kemptner-Rauscher on Unsplash

More from this blog

S

Spendolini Blog

30 posts

Long-time Oracle APEX developer currently managing a development team @ Oracle.

The views expressed on this blog are my own and do not necessarily reflect the views of Oracle.