How to exclude a locale in V4?

In the old plugin "gatsby-source-prismic-graphql", there was an option of langs, which was an array of strings where you could define the locales you wanted to fetch.

Now, on "gatsby-source-prismic", there is no such option, but there is a lang option, which according to the docs: "Set a default language when fetching documents. The default value is '*', which will fetch all languages."
And takes a string as value.

So the question is, how can I exclude a locale that exists in Prismic, but I don't want in my gatsby site (just yet)?

thanks

1 Like

Hello Juan Manuel, thanks for reaching out and for bringing this to our attention.

I'm not entirely sure if this is possible at the moment. I will communicate this concern with the team in charge of maintaining the plugin and inform you about any news.

Thanks

1 Like

Hello again Juan Manuel hope you're doing great!

So, there won't be a similar option for the new plugin but the workaround is as follows: For excluding a lang you can use the filter option when writing a GraphQL query

It would look something like this:

query MyQuery {
  allPrismicPage(filter: {lang: {nin: ["fr-fr"]}}) {
    nodes {
      id
      lang
    }
  }
}

Where nin is a list of languages to exclude (nin = “not in”)

Let me know if this is helpful for you.
Thanks.
Pau

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.