Skip to content

Query fails when rss feed has no items. #19

@jhoude5

Description

@jhoude5

Im trying to post job feeds. But I want to make we capture when there are no jobs to show a message, but the build fails because the name of the feed doesnt have items in the rss feed to add to the database.

Activity

lettie16

lettie16 commented on Mar 23, 2023

@lettie16

Was there any fix for this?

It also relates to the other issue here:

There was an error in your GraphQL query:
Cannot query field "allFeedGatsbyBlog" on type "Query".

The problem is with a vacancy/jobs feed there are likely times when the rss data returns nothing or no items. This then causes the graphql query to break as none of the nodes it is expecting have been returned. So a solution for this would be handy otherwise the plugin is unusable in when the feed returns no items.

mottox2

mottox2 commented on Mar 23, 2023

@mottox2
Owner

@lettie16
Thanks for the reminder. I missed this Issue and the problem still exists.
I will investigate around the end of this month.

jdahdah

jdahdah commented on Jan 19, 2024

@jdahdah

I just found a solution for this. You can provide a custom schema in gatsby-node.js that sets up the GraphQL nodes regardless of whether the feed has items or not. This tutorial explains why it happens and how to write the schema.

In my case it's also a job board, served by the TeamTailor service. This is my schema customization:

// gatsby-node.js

exports.createSchemaCustomization = ({ actions }) => {
  const { createTypes } = actions

  createTypes(`
    type FeedTeamTailorRss implements Node {
      guid: String
      department: String
      title: String
      locations: [Location]
      link: String
    }
    type Location {
      tt_location: TTLocation
    }
    type TTLocation {
      tt_city: String
      tt_country: String
    }
  `)
}

I based it on the original GraphQL query, which in my case is:

allFeedTeamTailorRss {
  nodes {
    guid
    department
    title
    locations {
      tt_location {
        tt_city
        tt_country
      }
    }
    link
  }
}

Hope this helps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Query fails when rss feed has no items. · Issue #19 · mottox2/gatsby-source-rss-feed