Allow 'locale' as an option for sourcing nodes with gatsby-source-datocms

There should be a way to tell the source plugin to only source nodes for a particular locale? This would allow having one Dato instance, but being able to break up in to multiple Gatsby sites where all that is changed is an environment variable

Currently, I believe it sources everything. There are ways to break it into multiple sites that limit the number of pages created, queried, etc. in gatsby-node, but the sourcing is still over-eager.

The option could look something like:

// In your gatsby-config.js
plugins: [
    resolve: `gatsby-source-datocms`,
    options: {
      apiToken: `YOUR_READONLY_API_TOKEN`,
      environment: `main`,
      // New option vvv
      locale: process.env.DATO_LOCALE

It looks like there is a locale filter option in the datocms-client here which I think could be passed in here.

Just noting that this is an existing option on some other Gatsby plugins. The Contentful plugin, for example, calls it localeFilter:

Done! Release v3.0.15 · datocms/gatsby-source-datocms · GitHub

Just to add a bit here @gatsbyjs you have now the option localesToGenerate.

It’s documented here: GitHub - datocms/gatsby-source-datocms: Official GatsbyJS source plugin to pull content from DatoCMS and here’s a little excerpt:

// Only source nodes for a specific set of locales. This can limit the memory usage by
// reducing the amount of nodes created. Useful if you have a large project in DatoCMS
// and only want to get the data from one selected locale
// localesToGenerate: ['it', 'en'],