Reconciling old shit with new shit; Query web feeds (RSS, Atom, and RDF) with GraphQL
- What is it?
- Try it
- Installation
- Querying
- Configuration
- Testing
- Troubleshooting
Sometimes you gotta make use of an RSS/Atom/RDF web feed.graphql-web-feeds
aims to make it easy to do that in your GraphQL API.
Demo Todo :-(
The package makes the assumption that, because you're using GraphQL, you're probably also using ES6+ and therefore your project handles any necessary transpilation, when required.
First, install the package:
npm install graphql-web-feeds --save
Then, add it to your project's GraphQL schema:
import{GraphQLSchema}from'graphql/type'import{feedTypeFactory}from'web-feeds-graphql'constsimpleField=feedTypeFactory()constschema=GraphQLSchema({query:simpleField,})
query {waitButWhy:feed(url:"http://waitbutwhy.com/feed") {titlelinkdescriptionitems {titlelinkdescription } }}
Single, default feed:
import{GraphQLSchema}from'graphql/type'import{feedTypeFactory}from'web-feeds-graphql'constfeedUrl='http://waitbutwhy.com/feed'constfield=feedTypeFactory(feedUrl)constschema=GraphQLSchema({query:field,})
query {feed {titlelinkdescriptionitems {titlelinkdescription } }}
With cache and selected feeds:
import{GraphQLSchema}from'graphql/type'import{S3Cache}from'web-feeds-graphql/cache'import{feedTypeFactory}from'web-feeds-graphql'constcache=newS3Cache({ secret, accesskey,ttl:true,..etc})constfeeds={waitButWhy:'http://waitbutwhy.com/feed',spacex:'http://www.space.com/home/feed/site.xml',}constfield=feedTypeFactory(feeds,cache)constschema=GraphQLSchema({query:field,})
query {waitButWhy:feed(name: waitButWhy) {titlelinkdescriptionitems {titlelinkdescription } }}
query {waitButWhy:feed(url:"http://waitbutwhy.com/feed") {titlelinkdescriptionitems {titlelinkdescription } }}
Todo
Todo
Cache must be an object exposing two methods:get
andset
stream get(feedUrl)
async set(feedUrl, feedStream)
git clone https://github.com/adieuadieu/graphql-web-feeds.gitcd graphql-web-feedsnpmtest
Todo?
Todo.