Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Contentful : Unable to access contentful data from different(develop) environment #5101

Closed
vigneshgowrabathuni opened this issue Apr 24, 2018 · 9 comments
Labels
type: question or discussion Issue discussing or asking a question about Gatsby

Comments

@vigneshgowrabathuni
Copy link

Hi,
In Contentful we have created a space, let say ABC and within that we have created two environments, like master and develop.

ABC

  • master
  • develop

We have created API key and selected develop environment as well.

Problem:

we are unable to access the contentful data from develop environment.

@vigneshgowrabathuni vigneshgowrabathuni changed the title Contentful : Unable access contentful data from different(develop) environment Contentful : Unable to access contentful data from different(develop) environment Apr 24, 2018
@m-allanson m-allanson added the type: question or discussion Issue discussing or asking a question about Gatsby label Apr 24, 2018
@m-allanson
Copy link
Contributor

Hey @vigneshgowrabathuni, there's not enough information here to help you. Could you fill out the issue template?

@vigneshgowrabathuni
Copy link
Author

Hi @m-allanson

Code Sample for Java Script:

const contentful = require('contentful')

const client = contentful.createClient({
  space: '<space_id>',
  environment: '<environment_id>', // defaults to 'master' if not set
  accessToken: '<content_delivery_api_key>'
})

client.getSpace()
.then((space) => console.log(space))
.catch(console.error)

Reference :

Code sample for gatsby contentful plugin:

// In your gatsby-config.js
plugins: [
  {
    resolve: `gatsby-source-contentful`,
    options: {
      spaceId: `your_space_id`,
      accessToken: `your_access_token`,
    },
  },
];

Reference:

In Javascript we can mention respective environment let say master or stage or develop
But in gatsby contentful plugin, how we can access specific environment data,

I have tried like this, but still i am unable to access data.

// In your gatsby-config.js
plugins: [
  {
    resolve: `gatsby-source-contentful`,
    options: {
      spaceId: `your_space_id`,
      **environment: '<environment_id>', // defaults to 'master' if not set**
      accessToken: `your_access_token`,
    },
  },
];

Here the challenge is I am unable to access data from develop environment, is there any alternative way to access data from specific environment?

@Khaledgarbaya
Copy link
Contributor

Khaledgarbaya commented Apr 25, 2018

Hey @m-allanson and @vigneshgowrabathuni,

Just to explain Here, we introduced recently a new feature at Contentful, so you can have different environments for your space think of it like branches.

master is the default environment so that's why you can only see that, to get content from a different environment you need to tell the SDK that you are using a different one. One problem here is that the sync API, unfortunately, is only available in the master environment.

This will hopefully change soon.
Best,
Khaled

@m-allanson
Copy link
Contributor

Ah that explains it, thanks for the update @Khaledgarbaya! What's the best way to track updates to the sync API?

@m-allanson m-allanson added the status: blocked This issue/PR can't be solved at the moment and shouldn't be closed/merged label Apr 25, 2018
@Khaledgarbaya
Copy link
Contributor

Things might change very soon hopefully, I am discussing this with our backend team.
Expect an update soon hopefully with a PR

@vigneshgowrabathuni
Copy link
Author

Thanks for the update @Khaledgarbaya 😄

@Khaledgarbaya
Copy link
Contributor

So I had a conversation with our backend team and they just enabled the feature for environments
here is a PR to add support for it.
Hey @m-allanson this is no longer blocked

@pieh pieh added 🏷 type: feature and removed status: blocked This issue/PR can't be solved at the moment and shouldn't be closed/merged labels Apr 26, 2018
@m-allanson
Copy link
Contributor

Fast work, thanks @Khaledgarbaya :)

@KyleAMathews
Copy link
Contributor

This is awesome @kaihendry!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: question or discussion Issue discussing or asking a question about Gatsby
Projects
None yet
Development

No branches or pull requests

5 participants