gatsbyjs/gatsby · error

Invalid plugin options for "gatsby-plugin-feed": "quer

Error message

Invalid plugin options for "gatsby-plugin-feed":
      "query" must be a valid GraphQL query. Received the error "${e.message}"

What it means

Thrown by the per-feed Joi external validator in gatsby-plugin-feed's plugin-options when an individual feed's `query` string fails graphql parse. It is a config-time error fired during plugin option validation, distinct from the runtime runQuery error — it catches malformed query syntax before any execution.

Source

Thrown at packages/gatsby-plugin-feed/src/plugin-options.js:19

import { parse } from "gatsby/graphql"
import { stripIndent } from "common-tags"

const feed = ({ Joi }) =>
  Joi.object({
    output: Joi.string().required(),
    query: Joi.string().required(),
    title: Joi.string().required(),
    serialize: Joi.func().required(),
    match: Joi.string(),
    link: Joi.string(),
  })
    .unknown(true)
    .external(({ query }) => {
      if (query) {
        try {
          parse(query)
        } catch (e) {
          throw new Error(
            stripIndent`
      Invalid plugin options for "gatsby-plugin-feed":
      "query" must be a valid GraphQL query. Received the error "${e.message}"`
          )
        }
      }
    })

export default ({ Joi }) =>
  Joi.object({
    generator: Joi.string(),
    query: Joi.string(),
    setup: Joi.func(),
    feeds: Joi.array().items(feed({ Joi })).required(),
  })
    .unknown(true)
    .external(({ query }) => {
      if (query) {

View on GitHub (pinned to 8b06340921)

Solutions

  1. Paste the feed's `query` into GraphiQL to find the syntax error.
  2. Remove any JS interpolation from the query string literal.
  3. Confirm the query is a complete, balanced GraphQL operation.
  4. Re-run `gatsby develop` — config validation fires early and will name the error from the message.

Example fix

// before
feeds: [{ query: `{ allMarkdownRemark { edges { node { id } } `, serialize: f }]
// after
feeds: [{ query: `{ allMarkdownRemark { edges { node { id } } } }`, serialize: f }]
Defensive patterns

Strategy: validation

Validate before calling

const { parse } = require('graphql')
feeds.forEach(f => { try { parse(f.query) } catch (e) { console.error(`Feed query invalid: ${e.message}`) } })

Type guard

const isParseableGraphQL = (q: string): boolean => { try { parse(q); return true } catch { return false } }

Prevention

When it happens

Trigger: Defining a feed in the `feeds` array whose `query` string is not parseable GraphQL (unclosed brace, invalid token, stray interpolation); calling setPluginOptions with such a feed config. The validator runs `parse(query)` inside the Joi .external hook.

Common situations: Writing a custom feed query with a syntax typo; copying a query template that left a placeholder like ${var} un-interpolated; mixing tabs/odd quotes; upgrading the graphql parser to a stricter version.

Related errors


AI-assisted analysis of gatsbyjs/gatsby@8b06340921 (2026-08-13). Data as JSON: /api/errors/32817b4dee996b5f. Report an issue: GitHub.