Skip to content

Commit

Permalink
refactor: reintroduce contentful sys common resource attribute #31007
Browse files Browse the repository at this point in the history
  • Loading branch information
axe312ger committed Jun 10, 2021
1 parent e99fa08 commit a1cc204
Show file tree
Hide file tree
Showing 25 changed files with 4,001 additions and 4,547 deletions.
2 changes: 1 addition & 1 deletion e2e-tests/contentful/src/components/references/text.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react"

export const ContentfulText = ({ short, longPlain }) => (
<p data-cy-id="text">[ContentfulText] {short || longPlain?.longPlain}</p>
<p data-cy-id="text">[ContentfulText] {short || longPlain?.raw}</p>
)
21 changes: 15 additions & 6 deletions e2e-tests/contentful/src/pages/boolean.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,26 +50,35 @@ export default BooleanPage
export const pageQuery = graphql`
query BooleanQuery {
default: allContentfulBoolean(
sort: { fields: contentful_id }
filter: { node_locale: { eq: "en-US" }, booleanLocalized: { eq: null } }
sort: { fields: sys___id }
filter: {
sys: { locale: { eq: "en-US" } }
booleanLocalized: { eq: null }
}
) {
nodes {
title
boolean
}
}
english: allContentfulBoolean(
sort: { fields: contentful_id }
filter: { node_locale: { eq: "en-US" }, booleanLocalized: { ne: null } }
sort: { fields: sys___id }
filter: {
sys: { locale: { eq: "en-US" } }
booleanLocalized: { ne: null }
}
) {
nodes {
title
booleanLocalized
}
}
german: allContentfulBoolean(
sort: { fields: contentful_id }
filter: { node_locale: { eq: "de-DE" }, booleanLocalized: { ne: null } }
sort: { fields: sys___id }
filter: {
sys: { locale: { eq: "de-DE" } }
booleanLocalized: { ne: null }
}
) {
nodes {
title
Expand Down
79 changes: 57 additions & 22 deletions e2e-tests/contentful/src/pages/content-reference.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const ContentReferencePage = ({ data }) => {
return (
<Layout>
<h1>Default</h1>
{defaultEntries.map(({ contentful_id, title, one, many }) => {
{defaultEntries.map(({ sys: { id }, title, one, many }) => {
const slug = slugify(title, { strict: true, lower: true })

let content = null
Expand All @@ -37,15 +37,15 @@ const ContentReferencePage = ({ data }) => {
}

return (
<div data-cy-id={`default-${slug}`} key={contentful_id}>
<div data-cy-id={`default-${slug}`} key={id}>
<h2>{title}</h2>
{content}
</div>
)
})}
<h1>English Locale</h1>
{englishEntries.map(
({ contentful_id, title, oneLocalized, manyLocalized }) => {
({ sys: { id }, title, oneLocalized, manyLocalized }) => {
const slug = slugify(title, { strict: true, lower: true })

let content = null
Expand All @@ -58,7 +58,7 @@ const ContentReferencePage = ({ data }) => {
}

return (
<div data-cy-id={`english-${slug}`} key={contentful_id}>
<div data-cy-id={`english-${slug}`} key={id}>
<h2>{title}</h2>
{content}
</div>
Expand All @@ -67,7 +67,7 @@ const ContentReferencePage = ({ data }) => {
)}
<h1>German Locale</h1>
{germanEntries.map(
({ contentful_id, title, oneLocalized, manyLocalized }) => {
({ sys: { id }, title, oneLocalized, manyLocalized }) => {
const slug = slugify(title, { strict: true, lower: true })

let content = null
Expand All @@ -80,7 +80,7 @@ const ContentReferencePage = ({ data }) => {
}

return (
<div data-cy-id={`german-${slug}`} key={contentful_id}>
<div data-cy-id={`german-${slug}`} key={id}>
<h2>{title}</h2>
{content}
</div>
Expand All @@ -97,25 +97,40 @@ export const pageQuery = graphql`
query ContentReferenceQuery {
default: allContentfulContentReference(
sort: { fields: title }
filter: { node_locale: { eq: "en-US" }, title: { glob: "!*Localized*" } }
filter: {
sys: { locale: { eq: "en-US" } }
title: { glob: "!*Localized*" }
}
) {
nodes {
title
contentful_id
sys {
id
}
one {
__typename
contentful_id
sys {
id
}
... on ContentfulText {
title
short
}
... on ContentfulNumber {
title
integer
}
... on ContentfulContentReference {
title
one {
... on ContentfulText {
title
short
}
... on ContentfulNumber {
title
integer
}
... on ContentfulContentReference {
title
}
Expand All @@ -137,7 +152,9 @@ export const pageQuery = graphql`
}
many {
__typename
contentful_id
sys {
id
}
... on ContentfulText {
title
short
Expand All @@ -153,6 +170,10 @@ export const pageQuery = graphql`
title
short
}
... on ContentfulNumber {
title
integer
}
... on ContentfulContentReference {
title
}
Expand All @@ -176,16 +197,23 @@ export const pageQuery = graphql`
}
english: allContentfulContentReference(
sort: { fields: title }
filter: { node_locale: { eq: "en-US" }, title: { glob: "*Localized*" } }
filter: {
sys: { locale: { eq: "en-US" } }
title: { glob: "*Localized*" }
}
) {
nodes {
title
contentful_id
sys {
id
}
oneLocalized {
__typename
title
decimal
integer
... on ContentfulNumber {
title
decimal
integer
}
}
manyLocalized {
__typename
Expand All @@ -198,24 +226,31 @@ export const pageQuery = graphql`
title
short
longPlain {
longPlain
raw
}
}
}
}
}
german: allContentfulContentReference(
sort: { fields: title }
filter: { node_locale: { eq: "de-DE" }, title: { glob: "*Localized*" } }
filter: {
sys: { locale: { eq: "de-DE" } }
title: { glob: "*Localized*" }
}
) {
nodes {
title
contentful_id
sys {
id
}
oneLocalized {
__typename
title
decimal
integer
... on ContentfulNumber {
title
decimal
integer
}
}
manyLocalized {
__typename
Expand All @@ -228,7 +263,7 @@ export const pageQuery = graphql`
title
short
longPlain {
longPlain
raw
}
}
}
Expand Down
12 changes: 5 additions & 7 deletions e2e-tests/contentful/src/pages/date.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,34 +32,32 @@ export default DatePage

export const pageQuery = graphql`
query DateQuery {
dateTime: contentfulDate(contentful_id: { eq: "38akBjGb3T1t4AjB87wQjo" }) {
dateTime: contentfulDate(sys: { id: { eq: "38akBjGb3T1t4AjB87wQjo" } }) {
title
date: dateTime
formatted: dateTime(formatString: "D.M.YYYY - hh:mm")
}
dateTimeTimezone: contentfulDate(
contentful_id: { eq: "6dZ8pK4tFWZDZPHgSC0tNS" }
sys: { id: { eq: "6dZ8pK4tFWZDZPHgSC0tNS" } }
) {
title
date: dateTimeTimezone
formatted: dateTimeTimezone(formatString: "D.M.YYYY - hh:mm (z)")
}
date: contentfulDate(contentful_id: { eq: "5FuULz0jl0rKoKUKp2rshf" }) {
date: contentfulDate(sys: { id: { eq: "5FuULz0jl0rKoKUKp2rshf" } }) {
title
date
formatted: date(formatString: "D.M.YYYY")
}
dateEnglish: contentfulDate(
contentful_id: { eq: "1ERWZvDiYELryAZEP1dmKG" }
node_locale: { eq: "en-US" }
sys: { id: { eq: "1ERWZvDiYELryAZEP1dmKG" }, locale: { eq: "en-US" } }
) {
title
date: dateLocalized
formatted: dateLocalized(formatString: "D.M.YYYY - HH:mm:ss")
}
dateGerman: contentfulDate(
contentful_id: { eq: "1ERWZvDiYELryAZEP1dmKG" }
node_locale: { eq: "de-DE" }
sys: { id: { eq: "1ERWZvDiYELryAZEP1dmKG" }, locale: { eq: "de-DE" } }
) {
title
date: dateLocalized
Expand Down
28 changes: 14 additions & 14 deletions e2e-tests/contentful/src/pages/gatsby-image.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,16 +157,18 @@ export const pageQuery = graphql`
query GatsbyImageQuery {
default: allContentfulAsset(
filter: {
contentful_id: {
in: [
"3ljGfnpegOnBTFGhV07iC1"
"3BSI9CgDdAn1JchXmY5IJi"
"65syuRuRVeKi03HvRsOkkb"
]
sys: {
id: {
in: [
"3ljGfnpegOnBTFGhV07iC1"
"3BSI9CgDdAn1JchXmY5IJi"
"65syuRuRVeKi03HvRsOkkb"
]
}
locale: { eq: "en-US" }
}
node_locale: { eq: "en-US" }
}
sort: { fields: contentful_id }
sort: { fields: sys___id }
) {
nodes {
title
Expand Down Expand Up @@ -194,10 +196,9 @@ export const pageQuery = graphql`
}
english: allContentfulAsset(
filter: {
contentful_id: { in: ["4FwygYxkL3rAteERtoxxNC"] }
node_locale: { eq: "en-US" }
sys: { id: { in: ["4FwygYxkL3rAteERtoxxNC"] }, locale: { eq: "en-US" } }
}
sort: { fields: contentful_id }
sort: { fields: sys___id }
) {
nodes {
title
Expand All @@ -213,10 +214,9 @@ export const pageQuery = graphql`
}
german: allContentfulAsset(
filter: {
contentful_id: { in: ["4FwygYxkL3rAteERtoxxNC"] }
node_locale: { eq: "de-DE" }
sys: { id: { in: ["4FwygYxkL3rAteERtoxxNC"] }, locale: { eq: "de-DE" } }
}
sort: { fields: contentful_id }
sort: { fields: sys___id }
) {
nodes {
title
Expand Down
28 changes: 14 additions & 14 deletions e2e-tests/contentful/src/pages/gatsby-plugin-image.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,16 +196,18 @@ export const pageQuery = graphql`
query GatsbyPluginImageQuery {
default: allContentfulAsset(
filter: {
contentful_id: {
in: [
"3ljGfnpegOnBTFGhV07iC1"
"3BSI9CgDdAn1JchXmY5IJi"
"65syuRuRVeKi03HvRsOkkb"
]
sys: {
id: {
in: [
"3ljGfnpegOnBTFGhV07iC1"
"3BSI9CgDdAn1JchXmY5IJi"
"65syuRuRVeKi03HvRsOkkb"
]
}
locale: { eq: "en-US" }
}
node_locale: { eq: "en-US" }
}
sort: { fields: contentful_id }
sort: { fields: sys___id }
) {
nodes {
title
Expand Down Expand Up @@ -239,10 +241,9 @@ export const pageQuery = graphql`
}
english: allContentfulAsset(
filter: {
contentful_id: { in: ["4FwygYxkL3rAteERtoxxNC"] }
node_locale: { eq: "en-US" }
sys: { id: { in: ["4FwygYxkL3rAteERtoxxNC"] }, locale: { eq: "en-US" } }
}
sort: { fields: contentful_id }
sort: { fields: sys___id }
) {
nodes {
title
Expand All @@ -256,10 +257,9 @@ export const pageQuery = graphql`
}
german: allContentfulAsset(
filter: {
contentful_id: { in: ["4FwygYxkL3rAteERtoxxNC"] }
node_locale: { eq: "de-DE" }
sys: { id: { in: ["4FwygYxkL3rAteERtoxxNC"] }, locale: { eq: "de-DE" } }
}
sort: { fields: contentful_id }
sort: { fields: sys___id }
) {
nodes {
title
Expand Down
Loading

0 comments on commit a1cc204

Please sign in to comment.