[cms api][s]: setup Apollo client with WordPress API.

We're using oddk for the demo here.
This commit is contained in:
anuveyatsu 2020-06-26 17:57:56 +06:00
parent b19a37e21a
commit 24c0ced96b
2 changed files with 11 additions and 0 deletions

View File

@ -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,

View File

@ -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',
},
};
};