From 24c0ced96b39c7d3396ecfb9f2d1189a6b853efb Mon Sep 17 00:00:00 2001 From: anuveyatsu Date: Fri, 26 Jun 2020 17:57:56 +0600 Subject: [PATCH] [cms api][s]: setup Apollo client with WordPress API. We're using oddk for the demo here. --- lib/apolloClient.ts | 8 ++++++++ next.config.js | 3 +++ 2 files changed, 11 insertions(+) diff --git a/lib/apolloClient.ts b/lib/apolloClient.ts index c3cdecb6..53e89ec6 100644 --- a/lib/apolloClient.ts +++ b/lib/apolloClient.ts @@ -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, diff --git a/next.config.js b/next.config.js index 577f4853..bff45751 100644 --- a/next.config.js +++ b/next.config.js @@ -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', }, }; };