Skip to content

Commit

Permalink
fix(gatsby-source-drupal): Add tests for meta.count support & fix bug…
Browse files Browse the repository at this point in the history
… with i18n (#33423) (#33440)

* feat(gatsby-source-drupal): port hot-fixes for Drupal/Gatsby customer to package

* Add tests for meta.count URL creation

The main guerentee that this is working is that only the first articles json file has a
next href so the only way all articles are fetched is if we create the URLs upfront.

* Add tests for meta.count for i18n (and fix bug for it)

* Make paths windows-happy

Co-authored-by: gatsbybot <mathews.kyle+gatsbybot@gmail.com>
(cherry picked from commit 22805bd)

Co-authored-by: Kyle Mathews <mathews.kyle@gmail.com>
  • Loading branch information
GatsbyJS Bot and KyleAMathews authored Oct 5, 2021
1 parent d0a152f commit aae86b5
Show file tree
Hide file tree
Showing 12 changed files with 430 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"data": [
{
"type": "node--article",
"id": "article-1",
"attributes": {
"id": 21,
"uuid": "article-1",
"title": "Article #1",
"body": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent accumsan nisl nulla, a commodo neque luctus viverra. Praesent sed elit nisl. In sagittis, velit lacinia varius cursus, lectus urna aliquet tortor, in convallis lacus justo ut enim. Nullam tempus diam non mattis pulvinar. Fusce viverra vitae ex eget efficitur. Nunc sed ligula magna. Fusce ligula diam, lobortis et neque vel, finibus laoreet augue. Duis tristique lacinia odio, tincidunt lacinia nunc cursus a. Vivamus nec mauris sed lectus commodo bibendum vel a felis.",
"langcode": "i18n-test"
},
"relationships": {
"field_main_image": {
"data": null
},
"field_tags": {
"data": [
{
"type": "taxonomy_term--tags",
"id": "tag-1"
},
{
"type": "taxonomy_term--tags",
"id": "tag-2"
}
]
}
}
}
],
"links": {
"next": {
"href": "http://fixture/jsonapi-meta.count-i18n/node/articlemeta.count-i18n?page[limit]=3&page[offset]=1"
}
},
"meta": {
"count": 4
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"data": [
{
"type": "node--article",
"id": "article-1",
"attributes": {
"id": 21,
"uuid": "article-1",
"title": "Article #1",
"body": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent accumsan nisl nulla, a commodo neque luctus viverra. Praesent sed elit nisl. In sagittis, velit lacinia varius cursus, lectus urna aliquet tortor, in convallis lacus justo ut enim. Nullam tempus diam non mattis pulvinar. Fusce viverra vitae ex eget efficitur. Nunc sed ligula magna. Fusce ligula diam, lobortis et neque vel, finibus laoreet augue. Duis tristique lacinia odio, tincidunt lacinia nunc cursus a. Vivamus nec mauris sed lectus commodo bibendum vel a felis."
},
"relationships": {
"field_main_image": {
"data": null
},
"field_tags": {
"data": [
{
"type": "taxonomy_term--tags",
"id": "tag-1"
},
{
"type": "taxonomy_term--tags",
"id": "tag-2"
}
]
}
}
}
],
"links": {
"next": {
"href": "http://fixture/jsonapi/node/articlemeta.count?page[limit]=3&page[offset]=1"
}
},
"meta": {
"count": 7
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"data": [
{
"type": "node--article",
"id": "article-2",
"attributes": {
"id": 22,
"uuid": "article-2",
"title": "Article #2",
"body": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent accumsan nisl nulla, a commodo neque luctus viverra. Praesent sed elit nisl. In sagittis, velit lacinia varius cursus, lectus urna aliquet tortor, in convallis lacus justo ut enim. Nullam tempus diam non mattis pulvinar. Fusce viverra vitae ex eget efficitur. Nunc sed ligula magna. Fusce ligula diam, lobortis et neque vel, finibus laoreet augue. Duis tristique lacinia odio, tincidunt lacinia nunc cursus a. Vivamus nec mauris sed lectus commodo bibendum vel a felis."
},
"relationships": {
"field_main_image": {
"data": null
},
"field_tags": {
"data": [
{
"type": "taxonomy_term--tags",
"id": "tag-1"
},
{
"type": "taxon,omy_term--tags",
"id": "tag-2"
}
]
}
}
}
]
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"data": [
{
"type": "node--article",
"id": "article-3",
"attributes": {
"id": 23,
"uuid": "article-3",
"title": "Article #3",
"body": "Proin pulvinar hendrerit magna nec maximus. Donec rhoncus libero ac nisi porttitor pulvinar. Quisque semper ultricies nulla sit amet vestibulum. Ut vel libero erat. Ut ultrices eleifend scelerisque. Nam non massa sit amet magna molestie tempus vel non neque. Praesent ac est congue, euismod mi ut, tristique mi. Etiam dapibus feugiat lectus, vel condimentum nisl maximus et. Praesent et placerat magna. Sed nec risus non ipsum venenatis placerat. Vestibulum vitae felis eget nunc mattis congue. Morbi volutpat odio purus. Donec placerat massa sed neque molestie, sed finibus nibh scelerisque. In faucibus ante tortor, in efficitur lectus feugiat vitae. Aliquam sodales mollis consectetur."
},
"relationships": {
"field_main_image": {
"data": {
"type": "file--file",
"id": "file-1"
}
},
"field_secondary_image": {
"data": [
{
"type": "file--file",
"id": "file-4"
}
]
},
"field_secondary_multiple_image": {
"data": [
{
"type": "file--file",
"id": "file-3"
},
{
"type": "file--file",
"id": "file-4"
}
]
},
"field_tertiary_image": {
"data": {
"type": "file--file",
"id": "file-4"
}
},
"field_tags": {
"data": null
}
}
}
]
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"data": [
{
"type": "node--article",
"id": "article-2",
"attributes": {
"id": 22,
"uuid": "article-2",
"title": "Article #2",
"body": "Proin pulvinar hendrerit magna nec maximus. Donec rhoncus libero ac nisi porttitor pulvinar. Quisque semper ultricies nulla sit amet vestibulum. Ut vel libero erat. Ut ultrices eleifend scelerisque. Nam non massa sit amet magna molestie tempus vel non neque. Praesent ac est congue, euismod mi ut, tristique mi. Etiam dapibus feugiat lectus, vel condimentum nisl maximus et. Praesent et placerat magna. Sed nec risus non ipsum venenatis placerat. Vestibulum vitae felis eget nunc mattis congue. Morbi volutpat odio purus. Donec placerat massa sed neque molestie, sed finibus nibh scelerisque. In faucibus ante tortor, in efficitur lectus feugiat vitae. Aliquam sodales mollis consectetur."
},
"relationships": {
"field_main_image": {
"data": {
"type": "file--file",
"id": "file-1"
}
},
"field_secondary_image": {
"data": [
{
"type": "file--file",
"id": "file-4"
}
]
},
"field_secondary_multiple_image": {
"data": [
{
"type": "file--file",
"id": "file-3"
},
{
"type": "file--file",
"id": "file-4"
}
]
},
"field_tertiary_image": {
"data": {
"type": "file--file",
"id": "file-4"
}
},
"field_tags": {
"data": null
}
}
}
]
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"data": [
{
"type": "node--article",
"id": "article-4",
"attributes": {
"id": 24,
"uuid": "article-4",
"title": "Article #4",
"body": "Proin pulvinar hendrerit magna nec maximus. Donec rhoncus libero ac nisi porttitor pulvinar. Quisque semper ultricies nulla sit amet vestibulum. Ut vel libero erat. Ut ultrices eleifend scelerisque. Nam non massa sit amet magna molestie tempus vel non neque. Praesent ac est congue, euismod mi ut, tristique mi. Etiam dapibus feugiat lectus, vel condimentum nisl maximus et. Praesent et placerat magna. Sed nec risus non ipsum venenatis placerat. Vestibulum vitae felis eget nunc mattis congue. Morbi volutpat odio purus. Donec placerat massa sed neque molestie, sed finibus nibh scelerisque. In faucibus ante tortor, in efficitur lectus feugiat vitae. Aliquam sodales mollis consectetur."
},
"relationships": {
"field_main_image": {
"data": {
"type": "file--file",
"id": "file-1"
}
},
"field_secondary_image": {
"data": [
{
"type": "file--file",
"id": "file-4"
}
]
},
"field_secondary_multiple_image": {
"data": [
{
"type": "file--file",
"id": "file-3"
},
{
"type": "file--file",
"id": "file-4"
}
]
},
"field_tertiary_image": {
"data": {
"type": "file--file",
"id": "file-4"
}
},
"field_tags": {
"data": null
}
}
}
],
"links": {
"next": {
"href": "http://fixture/jsonapi/node/articlemeta.count?page[limit]=1&page[offset]=1"
}
},
"meta": {
"count": 3
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"data": [
{
"type": "node--article",
"id": "article-1-i18n",
"attributes": {
"id": 31,
"uuid": "article-1-i18n",
"title": "Article #1 i18n",
"body": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent accumsan nisl nulla, a commodo neque luctus viverra. Praesent sed elit nisl. In sagittis, velit lacinia varius cursus, lectus urna aliquet tortor, in convallis lacus justo ut enim. Nullam tempus diam non mattis pulvinar. Fusce viverra vitae ex eget efficitur. Nunc sed ligula magna. Fusce ligula diam, lobortis et neque vel, finibus laoreet augue. Duis tristique lacinia odio, tincidunt lacinia nunc cursus a. Vivamus nec mauris sed lectus commodo bibendum vel a felis.",
"langcode": "i18n-test"
},
"relationships": {
"field_main_image": {
"data": null
},
"field_tags": {
"data": [
{
"type": "taxonomy_term--tags",
"id": "tag-1"
},
{
"type": "taxonomy_term--tags",
"id": "tag-2"
}
]
}
}
}
],
"links": {
"next": {
"href": "http://fixture/jsonapi-meta.count-i18n/node/i18n-test-articlemeta.count-i18n?page[limit]=3&page[offset]=1"
}
},
"meta": {
"count": 4
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"data": [
{
"type": "node--article",
"id": "article-2-18n",
"attributes": {
"id": 32,
"uuid": "article-2-i18n",
"title": "Article #2 i18n",
"body": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent accumsan nisl nulla, a commodo neque luctus viverra. Praesent sed elit nisl. In sagittis, velit lacinia varius cursus, lectus urna aliquet tortor, in convallis lacus justo ut enim. Nullam tempus diam non mattis pulvinar. Fusce viverra vitae ex eget efficitur. Nunc sed ligula magna. Fusce ligula diam, lobortis et neque vel, finibus laoreet augue. Duis tristique lacinia odio, tincidunt lacinia nunc cursus a. Vivamus nec mauris sed lectus commodo bibendum vel a felis."
},
"relationships": {
"field_main_image": {
"data": null
},
"field_tags": {
"data": [
{
"type": "taxonomy_term--tags",
"id": "tag-1"
},
{
"type": "taxon,omy_term--tags",
"id": "tag-2"
}
]
}
}
}
]
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"data": [],
"links": {
"self": "http://fixture/jsonapi",
"node--article": {
"href": "http://fixture/jsonapi-meta.count-i18n/node/article-meta.count-i18n"
},
"describedby": {
"href":"http://fixture/jsonapi/schema"
}
}
}


Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"data": [],
"links": {
"self": "http://fixture/jsonapi",
"node--article": "http://fixture/jsonapi/node/article-meta.count",
"describedby": {
"href":"http://fixture/jsonapi/schema"
}
}
}

Loading

0 comments on commit aae86b5

Please sign in to comment.