Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query error when adding custom XML field #5

Closed
mikeriley131 opened this issue Jan 29, 2019 · 4 comments
Closed

Query error when adding custom XML field #5

mikeriley131 opened this issue Jan 29, 2019 · 4 comments

Comments

@mikeriley131
Copy link

mikeriley131 commented Jan 29, 2019

Getting error GraphQL Error Unknown field youTubeUrl on type FeedLibSynRss after adding a custom field to the RSS XML.

query:

export const pageQuery = graphql`
  query {
    allFeedLibSynRss {
      edges {
        node {
          title
          youTubeUrl
          enclosure {
            url
          }
          itunes {
            season
            episode
            summary
            keywords
            duration
          }
        }
      }
    }
  }

snippet of RSS feed:

<item>
    ...
    <itunes:season>1</itunes:season>
    <itunes:episode>1</itunes:episode>
    <itunes:episodeType>full</itunes:episodeType>
    <!-- START ITEM EXTRA TAGS -->
    <youTubeUrl>https://www.youtube.com/watch?v=YE7VzlLtp-4</youTubeUrl>
    <!-- CLOSE ITEM EXTRA TAGS -->
</item>

Are the comments causing the issue? Unfortunately I don't have any control over them.

@mottox2 mottox2 pinned this issue Jan 30, 2019
@mottox2
Copy link
Owner

mottox2 commented Jan 31, 2019

@mikeriley131
Did you add youTubeUrl to options.parserOption.customFields.item in gatsby-config.js?

// In your gatsby-config.js
module.exports = {
  plugins: [
    {
      resolve: `gatsby-source-rss-feed`,
      options: {
        url: `https://www.gatsbyjs.org/blog/rss.xml`,
        name: `GatsbyBlog`,
        // Optional
        // Read parser document: https://github.com/bobby-brennan/rss-parser#readme
        parserOption: {
          customFields: {
            item: ['itunes:duration']
          }
        }
      }
    }
  ]
}

@mikeriley131
Copy link
Author

mikeriley131 commented Jan 31, 2019

I didn't. My understanding was that the customFields object would just be for properties containing a colon (:). Will try today and see if that makes a difference.

@mikeriley131
Copy link
Author

Well that does indeed work. Thank you!
Could you help me understand what needs to go in that customFields object and what does not?

@mottox2
Copy link
Owner

mottox2 commented Feb 2, 2019

@mikeriley131
gatsby-source-rss-feed use rss-parser as RSS parser.
rss-parser has default fields, so we have to define custom fields.

We can check default fields in this file.
https://github.com/bobby-brennan/rss-parser/blob/master/lib/fields.js

@mottox2 mottox2 closed this as completed Feb 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants