[cms api][s]: setup Apollo client with WordPress API.
We're using oddk for the demo here.
This commit is contained in:
parent
b19a37e21a
commit
24c0ced96b
@ -8,6 +8,14 @@ let apolloClient;
|
||||
|
||||
const restLink = new RestLink({
|
||||
uri: getConfig().publicRuntimeConfig.DMS + '/api/3/action/',
|
||||
endpoints: {
|
||||
wordpress: `https://public-api.wordpress.com/rest/v1.1/sites/${
|
||||
getConfig().publicRuntimeConfig.CMS
|
||||
}/posts/slug:`,
|
||||
'wordpress-posts': `https://public-api.wordpress.com/rest/v1.1/sites/${
|
||||
getConfig().publicRuntimeConfig.CMS
|
||||
}/posts/`,
|
||||
},
|
||||
typePatcher: {
|
||||
Search: (
|
||||
data: any,
|
||||
|
||||
@ -2,6 +2,7 @@ const { PHASE_DEVELOPMENT_SERVER } = require('next/constants');
|
||||
|
||||
module.exports = (phase, { defaultConfig }) => {
|
||||
const dms = process.env.DMS;
|
||||
const cms = process.env.CMS;
|
||||
if (phase === PHASE_DEVELOPMENT_SERVER) {
|
||||
if (dms) {
|
||||
console.log('\nYou are running the app in dev mode 🌀');
|
||||
@ -26,12 +27,14 @@ module.exports = (phase, { defaultConfig }) => {
|
||||
return {
|
||||
publicRuntimeConfig: {
|
||||
DMS: dms ? dms.replace(/\/?$/, '') : 'http://mock.ckan',
|
||||
CMS: cms ? cms.replace(/\/?$/, '') : 'oddk.home.blog',
|
||||
},
|
||||
};
|
||||
}
|
||||
return {
|
||||
publicRuntimeConfig: {
|
||||
DMS: dms ? dms.replace(/\/?$/, '') : 'https://demo.ckan.org',
|
||||
CMS: cms ? cms.replace(/\/?$/, '') : 'oddk.home.blog',
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user