I’m having trouble with the Algolia plugin for Gatsby. When I run my build, the plugin doesn’t update my search index with the latest data from Airtable.
I can manually push data to Algolia using their JavaScript client and JSON files, but I need this to happen automatically during builds so my search stays in sync with my Airtable content.
Here’s my current setup in gatsby-config.js:
const searchQuery = `{
allContentPages {
nodes {
objectID: id
pagePath
template
slug
metadata {
category
hash
creator
}
}
}
}`;
const indexQueries = [
{
query: searchQuery,
transformer: ({ data }) => data.allContentPages.nodes,
indexName: 'siteContent',
},
];
module.exports = {
plugins: [
{
resolve: 'gatsby-source-airtable-linked',
options: {
apiKey: process.env.AIRTABLE_KEY,
tables: [
{
baseId: process.env.AIRTABLE_BASE,
tableName: 'Content',
tableView: 'Published',
},
],
},
},
{
resolve: 'gatsby-plugin-algolia',
options: {
appId: process.env.ALGOLIA_APP_ID,
apiKey: process.env.ALGOLIA_ADMIN_KEY,
indexName: 'siteContent',
queries: indexQueries,
chunkSize: 10000,
},
},
],
};
I also tried using a more specific query for my Airtable data:
const searchQuery = `{
articles: allAirtableLinked(
filter: {
table: { eq: "Articles" }
}
) {
nodes {
id
data {
headline
image_url
image_description
permalink
stream_reference
content_id
}
}
}
}`;
Has anyone gotten this plugin working properly? The documentation is pretty limited and I’m not sure what I’m missing.
Hit this exact problem 8 months ago building a content site for marketing. It’s usually a timing issue - Algolia plugin runs before your Airtable data finishes processing during build.
First, check if your GraphQL query actually returns data. Run gatsby develop and test in GraphiQL at http://localhost:8000/___graphql. Empty results? There’s your problem.
Here’s what fixed it for me - added enablePartialUpdates to prevent unnecessary re-indexing and made sure the plugin runs after Airtable:
{
resolve: 'gatsby-plugin-algolia',
options: {
appId: process.env.ALGOLIA_APP_ID,
apiKey: process.env.ALGOLIA_ADMIN_KEY,
queries: indexQueries,
enablePartialUpdates: true,
matchFields: ['slug', 'modified'],
},
}
Also log your transformer function to see what data it’s getting:
transformer: ({ data }) => {
console.log('Algolia data:', data);
return data.allContentPages.nodes;
}
Still getting empty results? Your Airtable plugin config might be wrong. Double check your base ID and table name match exactly what’s in Airtable.
Had the same headaches with this setup last year. Try adding skipIndexing: false to your Algolia config - it sometimes defaults to true in production builds. Also check that your Airtable API key has read permissions, not just admin access. Admin-only keys can cause weird sync issues during automated builds.
This looks like a classic build order dependency issue. The Algolia plugin is probably running before your Airtable data loads into Gatsby’s GraphQL layer. I hit this exact problem on a client site earlier this year. Try wrapping your Algolia plugin in a conditional check so it only runs in production, then add some debugging to see what’s actually happening: javascript const shouldIndex = process.env.NODE_ENV === 'production' || process.env.GATSBY_ALGOLIA_INDEX_NOW === 'true'; module.exports = { plugins: [ // ... your airtable plugin first shouldIndex && { resolve: 'gatsby-plugin-algolia', options: { // your existing config dryRun: false, }, }, ].filter(Boolean), }; Also double-check your Airtable base ID format - it should start with ‘app’ followed by alphanumeric characters. Wrong base ID will make the plugin fail silently during builds. Check your build logs for any Airtable connection errors that might be buried in the output.