mottox2 / gatsby-source-rss-feed

Gatsby source plugin for rss feed.
https://www.npmjs.com/package/gatsby-source-rss-feed
24 stars 6 forks source link

How to add namespaced elements to query? #3

Closed mikeriley131 closed 5 years ago

mikeriley131 commented 5 years ago

I am having trouble figuring out how I can add namespaced elements to my GraphQL query.

For example, when trying to get: <itunes:duration>14:53</itunes:duration>

query {
    allFeedLibSynRss {
      edges {
        node {
          itunes:duration
        }
      }
    }
  }

I get the following error: error Cannot query field "duration" on type "FeedLibSynRss" graphql/template-strings

Any idea how I can access namespaced elements?

mottox2 commented 5 years ago

@mikeriley131 I just released 1.1.1. Would you try this version with this gatsby-config.js and these GraphQL?

    {
      resolve: `gatsby-source-rss-feed`,
      options: {
        url: 'YOUR RSS URL',
        name: `LibSynRss`,
        parserOption: {
          customFields: {
            item: ['itunes:duration']
          }
        }
      }
    },

graphql

query {
    allFeedLibSynRss {
      edges {
        node {
          itunes {
            duration
          }
        }
      }
    }
  }

or this graphql

query {
    allFeedLibSynRss {
      edges {
        node {
          duration
        }
      }
    }
  }
mikeriley131 commented 5 years ago

Works perfectly! Thank you.