@@ -15,13 +15,17 @@ This unofficial source plugin makes Optimizely/Episerver API data available in G
1515
1616## Features
1717
18- - Support for multiple ` optimizely/episerver ` API versions
19- - Support for multiple, additional custom headers
20- - Support for custom request timeout in all ` optimizely/episerver ` API requests
21- - Support for data caching on subsequent ` gatsby ` source plugin runs
22- - Support for request timeouts in all ` optimizely/episerver ` API requests
23- - Support for throttling, debouncing, and adjusting the number of concurrent ` optimizely/episerver ` API requests
18+ Provide support for the following features:
19+
20+ - Multiple ` optimizely/episerver ` API versions
21+ - Multiple, additional custom headers
22+ - Custom request timeout in all ` optimizely/episerver ` API requests
23+ - Data caching on subsequent ` gatsby ` source plugin runs
24+ - Request timeouts in all ` optimizely/episerver ` API requests
25+ - Throttling, debouncing, and adjusting the number of concurrent ` optimizely/episerver ` API requests
2426- Add support for ` expanded ` data on some content blocks: ` images ` , ` dynamicStyles ` , ` items ` , ` form ` key fields are currently supported with more to come in the future
27+ - Image optimizations for ` optimizely/episerver ` API images
28+ - Type resolvers for ` optimizely/episerver ` API content blocks
2529
2630## Installation and Setup
2731
@@ -56,13 +60,30 @@ module.exports = {
5660 grant_type: process .env .OPTMIZELY_API_GRANT_TYPE , // // The grant type of the Optimizely/Episerver API user. Default is "password"
5761 client_id: process .env .OPTMIZELY_API_CLIENT_ID , // The client ID of the Optimizely/Episerver API user. Default is "Default"
5862 },
59- endpoints: {
60- OptimizelyLocations: " /api/locations?lang=en-us&market=US" ,
61- OptimizelyAboutUsDesignersPageContentChildren: " /api/episerver/v2.0/content/14675/children?expand=*" ,
62- OptimizelyAboutUsPageContentChildren: " /api/episerver/v2.0/content/14110/children?expand=*" ,
63- OptimizelyBedAccessoriesHeadboardsPageContentChildren: " /api/episerver/v2.0/content/14129/children?expand=*" ,
64- OptimizelyBedAccessoriesLegsPageContentChildren: " /api/episerver/v2.0/content/14131/children?expand=*" ,
65- },
63+ endpoints: [
64+ {
65+ nodeName: " OptimizelyPageContent" ,
66+ endpoint:
67+ " /api/episerver/v2.0/content?references=14099,14104,14105,14106,14107,14109,14111,14110,14112,16621,14118,14117,14119,14980&expand=*" ,
68+ schema: null
69+ },
70+ {
71+ nodeName: " OptimizelyHomePageContentChildren" ,
72+ endpoint: " /api/episerver/v2.0/content/14099/children?expand=*" ,
73+ schema: null
74+ },
75+ {
76+ nodeName: " OptimizelyLocations" ,
77+ endpoint: " /api/locations?lang=en-us&market=US" ,
78+ schema: `
79+ id: ID!
80+ images: [String]
81+ inRiverId: Int!
82+ latitude: String
83+ sharpenImages: [File] @link(from: "fields.localFile")
84+ `
85+ }
86+ ]
6687 },
6788 },
6889 ],
@@ -71,6 +92,29 @@ module.exports = {
7192
7293## Configuration Options
7394
95+ ### Additional Headers
96+
97+ Add additional headers to the request as follows:
98+
99+ ``` javascript
100+ options: {
101+ // ...
102+
103+ auth: {
104+ headers: {
105+ // Single header
106+ " X-Custom-Header" : " Custom Value" ,
107+
108+ // Mutiple headers
109+ " Access-Control-Allow-Headers" : " Custom Value" ,
110+ " Access-Control-Allow-Credentials" : " Custom Value" ,
111+ " Access-Control-Allow-Origin" : " Custom Value" ,
112+ " Access-Control-Allow-Methods" : " Custom Value"
113+ }
114+ }
115+ }
116+ ```
117+
74118### Endpoints
75119
76120Add a single or multiple ` endpoints ` .
@@ -81,39 +125,65 @@ Add a single or multiple `endpoints`.
81125options: {
82126 // ...
83127
84- endpoints: {
128+ endpoints: [
85129 // Single endpoint
86- OptimizelyAboutUsDesignersPageContentChildren: " /api/episerver/v2.0/content/14675/children?expand=*" ,
130+ {
131+ nodeName: " OptimizelyPageContent" ,
132+ endpoint: " /api/episerver/v2.0/content?references=14099,14104,14105,14106,14107,14109,14111,14110,14112,16621,14118,14117,14119,14980&expand=*" ,
133+ schema: null
134+ },
87135
88136 // Multiple endpoints
89- OptimizelyLocations: " /api/locations?lang=en-us&market=US" ,
90- OptimizelyAboutUsPageContentChildren: " /api/episerver/v2.0/content/14110/children?expand=*" ,
91- OptimizelyBedAccessoriesHeadboardsPageContentChildren: " /api/episerver/v2.0/content/14129/children?expand=*" ,
92- OptimizelyBedAccessoriesLegsPageContentChildren: " /api/episerver/v2.0/content/14131/children?expand=*" ,
93- }
137+ {
138+ nodeName: " OptimizelyHomePageContentChildren" ,
139+ endpoint: " /api/episerver/v2.0/content/14099/children?expand=*" ,
140+ schema: null
141+ },
142+ {
143+ nodeName: " OptimizelyLocations" ,
144+ endpoint: " /api/locations?lang=en-us&market=US" ,
145+ schema: `
146+ id: ID!
147+ images: [String]
148+ inRiverId: Int!
149+ latitude: String
150+ sharpenImages: [File] @link(from: "fields.localFile")
151+ `
152+ }
153+ ];
94154}
95155```
96156
97- ### Additional Headers
157+ ### Global Schema
98158
99- Add additional headers to the request as follows:
159+ Add a global schema to all ` endpoints ` . This will be merged with the ` endpoint ` schema. This is useful for adding global fields to all ` endpoints ` .
100160
101161``` javascript
102162options: {
103163 // ...
104164
105- auth: {
106- headers: {
107- // Single header
108- " X-Custom-Header" : " Custom Value" ,
109-
110- // Mutiple headers
111- " Access-Control-Allow-Headers" : " Custom Value" ,
112- " Access-Control-Allow-Credentials" : " Custom Value" ,
113- " Access-Control-Allow-Origin" : " Custom Value" ,
114- " Access-Control-Allow-Methods" : " Custom Value"
165+ globals: {
166+ schema: `
167+ type ContentLink {
168+ id: Int!
169+ url: String!
170+ expanded: Expanded @dontInfer
171+ }
172+ `
173+ },
174+ endpoints: [
175+ {
176+ nodeName: " OptimizelyPageContent" ,
177+ endpoint: " /api/episerver/v2.0/content?references=14099,14104,14105,14106,14107,14109,14111,14110,14112,16621,14118,14117,14119,14980&expand=*" ,
178+ schema: `
179+ id: ID!
180+ name: String
181+ metaTitle: String
182+ metaDescription: String
183+ contentLink: ContentLink
184+ `
115185 }
116- }
186+ ]
117187}
118188```
119189
@@ -181,142 +251,46 @@ Assuming you correctly setup the plugin in `gatsby-config.js` and you have a `Op
181251options: {
182252 // ...
183253
184- endpoints: {
185- OptimizelyAboutUsDesignersPageContentChildren: " /api/episerver/v2.0/content/14675/children?expand=*" ,
186- }
254+ globals: {
255+ schema: `
256+ type ContentLink {
257+ id: Int!
258+ url: String!
259+ expanded: Expanded @dontInfer
260+ }
261+ `
262+ },
263+ endpoints: [
264+ {
265+ nodeName: " OptimizelyPageContent" ,
266+ endpoint: " /api/episerver/v2.0/content?references=14099,14104,14105,14106,14107,14109,14111,14110,14112,16621,14118,14117,14119,14980&expand=*" ,
267+ schema: `
268+ id: ID!
269+ name: String
270+ metaTitle: String
271+ metaDescription: String
272+ contentLink: ContentLink
273+ `
274+ }
275+ ]
187276}
188277```
189278
190279you can query the data as follows:
191280
192281``` graphql
193282{
194- allOptimizelyAboutUsDesignersPageContentChildren ( filter : { status : { eq : " Published " } }) {
283+ allOptimizelyPageContent {
195284 edges {
196285 node {
197286 id
198287 name
288+ metaTitle
289+ metaDescription
199290 contentLink {
200291 id
201292 url
202293 }
203- contentType
204- language {
205- displayName
206- link
207- name
208- }
209- status
210- contentBlocks {
211- displayOption
212- contentLink {
213- expanded {
214- body
215- column1Body
216- column1PrimaryCTA {
217- text
218- target
219- title
220- url
221- }
222- column1SecondaryCTA {
223- target
224- text
225- title
226- url
227- }
228- column2PrimaryCTA {
229- target
230- text
231- title
232- url
233- }
234- column2SecondaryCTA {
235- target
236- text
237- title
238- url
239- }
240- contentLink {
241- id
242- }
243- contentType
244- disableImageZoom
245- dynamicStyles {
246- contentLink {
247- id
248- }
249- themeColor
250- }
251- eyeBrow
252- heading
253- headingH1
254- items {
255- contentLink {
256- id
257- }
258- body
259- contentType
260- eyeBrow
261- heading
262- image {
263- id
264- url
265- expanded {
266- contentLink {
267- id
268- url
269- }
270- contentType
271- height
272- name
273- status
274- url
275- width
276- size
277- }
278- }
279- link {
280- target
281- text
282- title
283- url
284- }
285- name
286- status
287- parentLink {
288- id
289- url
290- }
291- }
292- language {
293- displayName
294- name
295- }
296- layout
297- primaryCTA {
298- text
299- url
300- title
301- target
302- }
303- secondaryCTA {
304- target
305- text
306- title
307- url
308- }
309- status
310- style
311- textPosition
312- textPosition2
313- image1 {
314- id
315- url
316- }
317- }
318- }
319- }
320294 }
321295 }
322296 }
0 commit comments