Has anyone here managed to setup a `linkPreview` q...
# orm-help
a
Has anyone here managed to setup a
linkPreview
query in Nexus? Given a websites
url
I would like to be able to get the meta data from that site, description, images, etc. Like when you post a link here. I'm using Nexus Schema and I'm not really sure how to approach this. Any guidance would be appreciated 🙏
r
There are 3rd party REST API’s for this that provide the metadata for a given URL like site, description etc. In this case, you can create a custom type and resolver something like:
Copy code
const LinkPreview = objectType({
  type: 'LinkPreview',
  definition(t) {
    // add the fields here returned from the REST API
  }
})

const queryLinkPreview = objectType({
  type: 'getLinkPreview',
  args: {
    // the link URL
  },
  resolve(parent, root, ctx) {
    // call the rest api here and return the response
  }
})
This is the approach I would take.
a
@Ryan what are the third part rest apis called?
r
Something like this. They’re mostly known for getting the metadata of a website.
👍 1