Skip to content

Commit 627fd9d

Browse files
author
Jan Lenoch
authored
Merge pull request #10 from Kentico/class-to-plain
Class to plain
2 parents bad2ae6 + 516b445 commit 627fd9d

File tree

11 files changed

+828
-648
lines changed

11 files changed

+828
-648
lines changed

.babelrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
"presets": [ "@babel/preset-env" ],
33
"plugins": [
44
"@babel/plugin-transform-regenerator"
5-
]
5+
],
6+
"sourceMaps": "both"
67
}

.npmignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,3 @@
99
!package.json
1010
!.npmignore
1111
!README.md
12-
!*.js

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@ deploy:
1111
email: $NPM_EMAIL
1212
api_key: $NPM_API_KEY
1313
skip_cleanup: true
14+
tag: beta
1415
on:
1516
tags: true

.vscode/launch.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"--runInBand",
1515
"--no-cache"
1616
],
17-
"sourceMaps": false,
17+
"sourceMaps": true,
1818
"console": "integratedTerminal",
1919
"internalConsoleOptions": "neverOpen",
2020
"windows": {

README.md

Lines changed: 43 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@ This repo contains a [Gatsby v2 source plugin](https://www.gatsbyjs.org/docs/rec
1010
You can use the plugin in any of the following ways:
1111

1212
* Install the [gatsby-source-kentico-cloud](https://www.npmjs.com/package/gatsby-source-kentico-cloud) NPM package in your Gatsby site via `npm install --save gatsby-source-kentico-cloud`.
13-
* (Coming soon) Use the [gatsby-starter-kentico-cloud](https://github.com/Kentico/gatsby-starter-kentico-cloud) starter site, which uses the NPM package.
13+
* Use the [gatsby-starter-kentico-cloud](https://github.com/Kentico/gatsby-starter-kentico-cloud) starter site, which uses the NPM package.
1414

1515
### Features
1616

17+
**Breaking change: All Kentico Cloud content element values now reside inside of the `elements` property of `kenticoCloudItem` nodes.**
18+
1719
The plugin creates GraphQL nodes for all Kentico Cloud content types, content items, and language variants.
1820

1921
The node names are prefixed with `kenticoCloud`. More specifically, content type nodes are prefixed with `kenticoCloudType` and content items and their language variants are prefixed with `kenticoCloudItem`.
@@ -22,23 +24,33 @@ The plugin creates the following relationships among the Kentico Cloud nodes. Yo
2224

2325
#### Content item <-> content type relationships
2426

25-
This relationship is captured in the `contentItems` navigation property of all *content type* nodes. For all *content item* nodes, it can be found in the `contentType` navigation property.
27+
This relationship is captured in the `contentItems` navigation property of all `kenticoCloudType` nodes. In the opposite direction, in all `kenticoCloudItem` nodes, it can be found in the `contentType` navigation property.
2628

27-
You can use the GraphiQL interface to experiment with the data structures produced by the source plugin. For instance, you can fetch a content item of the *Project reference* type (by querying `kenticoCloudItemProjectReference`) and use the `contentType` navigation property to get a full list of all of the elements in the underlying content type. Like so:
29+
You can use the GraphiQL interface to experiment with the data structures produced by the source plugin. For instance, you can fetch a content item of the *Project reference* type (by querying `allKenticoCloudItemProjectReference`) and use the `contentType` navigation property to get a full list of all of the elements in the underlying content type. Like so:
2830

2931
{
30-
kenticoCloudItemProjectReference {
31-
name___teaser_image__name {
32-
value
32+
allKenticoCloudItemProjectReference {
33+
edges {
34+
node {
35+
elements {
36+
name___teaser_image__name {
37+
value
38+
}
3339
}
34-
contentType {
35-
elements {
36-
codename
40+
contentType {
41+
elements {
42+
name___teaser_image__name {
43+
name
3744
}
45+
}
3846
}
39-
}
47+
}
48+
}
49+
}
4050
}
4151

52+
This kind of relationship comes handy when no content item has a particular element populated with data. In that case Gatsby won't recognize that element and won't include it in its internal schema. Neither the (null) value nor the name of the element will be visible through the `kenticoCloudItem` GraphQL nodes. Tapping into the related `kenticoCloudType` GraphQL node might be a proper fallback mechanism.
53+
4254
#### Language variant relationships
4355

4456
This relationship is captured by the `otherLanguages` navigation property of all content item nodes. For instance, you can get the names of all content items of the *Speaking engagement* type (by querying `kenticoCloudItemSpeakingEngagement`) in their default language as well as other languages all at once:
@@ -47,14 +59,18 @@ This relationship is captured by the `otherLanguages` navigation property of all
4759
allKenticoCloudItemSpeakingEngagement {
4860
edges {
4961
node {
50-
name {
51-
value
52-
}
53-
otherLanguages {
62+
elements {
5463
name {
5564
value
5665
}
5766
}
67+
otherLanguages {
68+
elements {
69+
name {
70+
value
71+
}
72+
}
73+
}
5874
}
5975
}
6076
}
@@ -68,13 +84,8 @@ Each modular content property is accompanied by a sibling property suffixed with
6884
allKenticoCloudItemProjectReference {
6985
edges {
7086
node {
71-
related_project_references {
72-
name___teaser_image__name {
73-
value
74-
}
75-
}
76-
related_project_references_nodes {
77-
name___teaser_image__name {
87+
elements {
88+
related_project_references {
7889
value
7990
}
8091
related_project_references_nodes {
@@ -94,15 +105,17 @@ As with the previous example, all rich text properties with modular content also
94105
allKenticoCloudItemBlogpostReference {
95106
edges {
96107
node {
97-
name___teaser_image__name {
98-
value
99-
}
100-
summary {
101-
value
102-
}
103-
summary_nodes {
104-
system {
105-
codename
108+
elements {
109+
name___teaser_image__name {
110+
value
111+
}
112+
summary {
113+
value
114+
}
115+
summary_nodes {
116+
system {
117+
codename
118+
}
106119
}
107120
}
108121
}
@@ -118,16 +131,6 @@ All nodes have a `usedByContentItems` property that reflects the other nodes in
118131

119132
* [Node.js](https://nodejs.org/) with NPM installed
120133

121-
### Troubleshooting
122-
123-
In case you encounter the following error:
124-
125-
`GraphQL Error Unknown field 'system' on type '...'`
126-
127-
just rebuild the site using `npm run develop` or (if you have the Gatsby CLI installed) `gatsby develop`.
128-
129-
This [error](https://github.com/gatsbyjs/gatsby/issues/8053) occurs mostly due to issues with building of the internal schema. If it cannot be solved by rebuilding with `npm run develop` or raising the `version` field in the [package.json](https://github.com/Kentico/gatsby-source-kentico-cloud/blob/master/package.json) of the source plugin, then you should look for other root causes (not related to [building of the schema](https://github.com/gatsbyjs/gatsby/issues/2674#issuecomment-340510736)).
130-
131134
## Further information
132135

133136
For more developer resources, visit the Kentico Cloud Developer Hub at https://developer.kenticocloud.com.

0 commit comments

Comments
 (0)