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