datocms / gatsby-source-datocms

Official GatsbyJS source plugin to pull content from DatoCMS
MIT License
140 stars 50 forks source link

Gatsby queries return data from the master environment when I setup dev environment #133

Closed AM-NiceDay closed 3 years ago

AM-NiceDay commented 3 years ago

Hello, I have an issue working with Dato CMS environments.

Initially I have a fully working website integrated with Dato CMS using gatsby-source-datocms plugin.

Here're the steps I take to setup development environment for Gatsby project:

  1. Fork master environment and name it dev.
  2. Switch to dev environment in the header of Dato CMS.
  3. In the Dato CMS setting I add new language "Franch".
  4. Update piece of content in French.
  5. Update gatsby plugin configuraion. Final verions looks like:
    {
    resolve: `gatsby-source-datocms`,
    options: {
    apiToken: process.env.DATO_CMS_API_TOKEN,
    previewMode: false,
    disableLiveReload: false,
    environment: "dev",
    },
    }
  6. Start gatsby server yarn start and go to http://localhost:8000/___graphql.
  7. Run query
    query MyQuery {
    datoCmsSite {
    locales
    }
    }

returns

{
  "data": {
    "datoCmsSite": {
      "locales": [
        "en"
      ]
    }
  },
  "extensions": {}
}

While should return two locales: "en" and "fr". Same goes for the rest, querying any fields return the data from the master branch. Also when I query datoCmsSomething(locale: {eq: "fr"}) { ... } it always return null for this query.

At the same time API explorer on Dato CMS returns expected results for the French locale.

Let me know if I should provide additional info.

matjack1 commented 3 years ago

hey @AM-NiceDay have you written already some content in French?

matjack1 commented 3 years ago

yes, sorry, just read now :)

matjack1 commented 3 years ago

which version of the Gatsby source plugin are you using? It's something we've added/fixed recently, can you please check that?

AM-NiceDay commented 3 years ago

2.2.6

matjack1 commented 3 years ago

yes, you should upgrade then, we've introduced support in v2.3.0: https://github.com/datocms/gatsby-source-datocms/blob/master/CHANGELOG.md#v230

AM-NiceDay commented 3 years ago

Works now, thanks

matjack1 commented 3 years ago

excellent! :)