Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(gatsby-source-contentful): move types into createSchemaCustomization #33207

Merged
merged 27 commits into from
Oct 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
a16e21f
refactor(contentful): move code to createSchemaCustomization
axe312ger Sep 16, 2021
12daa97
move all node manipulating code into sourceNodes
axe312ger Sep 16, 2021
53dc7f8
move asset cache dir creation to pre bootstrap
axe312ger Sep 16, 2021
2ed4927
fix(contentful): GATSBY_CONTENTFUL_EXPERIMENTAL_FORCE_CACHE now works…
axe312ger Sep 16, 2021
e5e685e
fix GATSBY_CONTENTFUL_OFFLINE
axe312ger Sep 16, 2021
ca28e3a
fix(contentful): add enableTags to plugin options
axe312ger Sep 16, 2021
cbceb73
fix(contentful): ensure enabled tags do not break warm builds
axe312ger Sep 16, 2021
d6a012f
fix unit tests
axe312ger Sep 16, 2021
e5e7526
refactor(contentful): fetch content types for schema and data for nod…
axe312ger Sep 17, 2021
845e19f
refactor(contentful): simplify fetch code and add more comments
axe312ger Sep 17, 2021
2b6f64f
refactor(contentful): remove GATSBY_CONTENTFUL_EXPERIMENTAL_FORCE_CACHE
axe312ger Sep 17, 2021
8ed2235
refactor(contentful): get latest content types on every schema custom…
axe312ger Sep 17, 2021
00e2c24
docs(contentful): plugin options - remove unused forceFullSync and pr…
axe312ger Sep 17, 2021
6bd317e
test(contentful): update e2e test snapshots for https
axe312ger Sep 25, 2021
8eed1da
chore(contentful): update e2e test schema for comparision
axe312ger Sep 25, 2021
ea2e840
chore: add dontInfer to interfaces and align code style of type creation
axe312ger Oct 8, 2021
bbebda5
Revert "refactor(contentful): get latest content types on every schem…
axe312ger Oct 8, 2021
053eb57
store sync token in plugin status
axe312ger Oct 8, 2021
e6639b8
lint
axe312ger Oct 8, 2021
56f026f
fix tests for pluginStatus change
axe312ger Oct 8, 2021
40eb0df
ensure syncProgress does tick and finish
axe312ger Oct 10, 2021
978ac43
properly create interfaces
axe312ger Oct 10, 2021
1c394ef
ensure syncProgress reports properly when no data was available for sync
axe312ger Oct 10, 2021
7978708
fix unit tests
axe312ger Oct 10, 2021
7ea2a54
style: call createTypes once
axe312ger Oct 10, 2021
f3b91b0
use cache data in PQR workers
wardpeet Oct 12, 2021
4f22ccf
fix review exports
wardpeet Oct 12, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
193 changes: 110 additions & 83 deletions e2e-tests/contentful/schema.gql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
### Type definitions saved at 2021-05-21T17:02:49.951Z ###
### Type definitions saved at 2021-09-25T11:33:25.217Z ###

type File implements Node @dontInfer {
sourceInstanceName: String!
Expand Down Expand Up @@ -96,43 +96,23 @@ type SitePage implements Node @dontInfer {
internalComponentName: String!
componentChunkName: String!
matchPath: String
pageContext: JSON
}

type MarkdownHeading {
id: String
value: String
depth: Int
}

enum MarkdownHeadingLevels {
h1
h2
h3
h4
h5
h6
}

enum MarkdownExcerptFormats {
PLAIN
HTML
MARKDOWN
}

type MarkdownWordCount {
paragraphs: Int
sentences: Int
words: Int
}

type MarkdownRemark implements Node @childOf(mimeTypes: ["text/markdown", "text/x-markdown"], types: ["contentfulTextLongPlainTextNode", "contentfulTextLongMarkdownTextNode", "contentfulTextLongLocalizedTextNode"]) @derivedTypes @dontInfer {
frontmatter: MarkdownRemarkFrontmatter
excerpt: String
rawMarkdownBody: String
type SitePlugin implements Node @dontInfer {
resolve: String
name: String
version: String
nodeAPIs: [String]
browserAPIs: [String]
ssrAPIs: [String]
pluginFilepath: String
pluginOptions: JSON
packageJson: JSON
}

type MarkdownRemarkFrontmatter {
title: String
type SiteBuildMetadata implements Node @dontInfer {
buildTime: Date @dateformat
}

interface ContentfulEntry implements Node {
Expand Down Expand Up @@ -184,15 +164,16 @@ type ContentfulNumber implements ContentfulReference & ContentfulEntry & Node @d
contentful_id: String!
node_locale: String!
title: String
decimal: Float
integerLocalized: Int
spaceId: String
createdAt: Date @dateformat
updatedAt: Date @dateformat
sys: ContentfulNumberSys
metadata: ContentfulNumberMetadata
decimal: Float
integer: Int
content_reference: [ContentfulContentReference] @link(by: "id", from: "content reference___NODE") @proxy(from: "content reference___NODE")
decimalLocalized: Float
integerLocalized: Int
}

type ContentfulNumberSys @derivedTypes {
Expand All @@ -211,22 +192,31 @@ type ContentfulNumberSysContentTypeSys {
id: String
}

type ContentfulNumberMetadata {
tags: [ContentfulTag] @link(by: "id", from: "tags___NODE")
}

type ContentfulTag implements Node @dontInfer {
name: String!
contentful_id: String!
}

type ContentfulContentReference implements ContentfulReference & ContentfulEntry & Node @derivedTypes @dontInfer {
contentful_id: String!
node_locale: String!
title: String
manyLocalized: [ContentfulNumberContentfulTextUnion] @link(by: "id", from: "manyLocalized___NODE")
one: ContentfulContentReferenceContentfulTextUnion @link(by: "id", from: "one___NODE")
content_reference: [ContentfulContentReference] @link(by: "id", from: "content reference___NODE") @proxy(from: "content reference___NODE")
spaceId: String
createdAt: Date @dateformat
updatedAt: Date @dateformat
sys: ContentfulContentReferenceSys
oneLocalized: ContentfulNumber @link(by: "id", from: "oneLocalized___NODE")
one: ContentfulContentReferenceContentfulTextUnion @link(by: "id", from: "one___NODE")
content_reference: [ContentfulContentReference] @link(by: "id", from: "content reference___NODE") @proxy(from: "content reference___NODE")
many: [ContentfulContentReferenceContentfulNumberContentfulTextUnion] @link(by: "id", from: "many___NODE")
manyLocalized: [ContentfulNumberContentfulTextUnion] @link(by: "id", from: "manyLocalized___NODE")
}

union ContentfulNumberContentfulTextUnion = ContentfulNumber | ContentfulText
union ContentfulContentReferenceContentfulTextUnion = ContentfulContentReference | ContentfulText

type ContentfulContentReferenceSys @derivedTypes {
type: String
Expand All @@ -244,10 +234,10 @@ type ContentfulContentReferenceSysContentTypeSys {
id: String
}

union ContentfulContentReferenceContentfulTextUnion = ContentfulContentReference | ContentfulText

union ContentfulContentReferenceContentfulNumberContentfulTextUnion = ContentfulContentReference | ContentfulNumber | ContentfulText

union ContentfulNumberContentfulTextUnion = ContentfulNumber | ContentfulText

type ContentfulText implements ContentfulReference & ContentfulEntry & Node @derivedTypes @dontInfer {
contentful_id: String!
node_locale: String!
Expand All @@ -257,12 +247,12 @@ type ContentfulText implements ContentfulReference & ContentfulEntry & Node @der
createdAt: Date @dateformat
updatedAt: Date @dateformat
sys: ContentfulTextSys
shortLocalized: String
longMarkdown: contentfulTextLongMarkdownTextNode @link(by: "id", from: "longMarkdown___NODE")
shortLocalized: String
longPlain: contentfulTextLongPlainTextNode @link(by: "id", from: "longPlain___NODE")
shortList: [String]
short: String
content_reference: [ContentfulContentReference] @link(by: "id", from: "content reference___NODE") @proxy(from: "content reference___NODE")
shortList: [String]
}

type contentfulTextLongLocalizedTextNode implements Node @derivedTypes @childOf(types: ["ContentfulText"]) @dontInfer {
Expand Down Expand Up @@ -312,14 +302,14 @@ type ContentfulMediaReference implements ContentfulReference & ContentfulEntry &
contentful_id: String!
node_locale: String!
title: String
manyLocalized: [ContentfulAsset] @link(by: "id", from: "manyLocalized___NODE")
one: ContentfulAsset @link(by: "id", from: "one___NODE")
spaceId: String
createdAt: Date @dateformat
updatedAt: Date @dateformat
sys: ContentfulMediaReferenceSys
many: [ContentfulAsset] @link(by: "id", from: "many___NODE")
oneLocalized: ContentfulAsset @link(by: "id", from: "oneLocalized___NODE")
one: ContentfulAsset @link(by: "id", from: "one___NODE")
many: [ContentfulAsset] @link(by: "id", from: "many___NODE")
manyLocalized: [ContentfulAsset] @link(by: "id", from: "manyLocalized___NODE")
}

type ContentfulMediaReferenceSys @derivedTypes {
Expand Down Expand Up @@ -370,14 +360,14 @@ type ContentfulDate implements ContentfulReference & ContentfulEntry & Node @der
contentful_id: String!
node_locale: String!
title: String
dateLocalized: Date @dateformat
dateTimeTimezone: Date @dateformat
spaceId: String
createdAt: Date @dateformat
updatedAt: Date @dateformat
sys: ContentfulDateSys
dateTime: Date @dateformat
dateTimeTimezone: Date @dateformat
date: Date @dateformat
dateLocalized: Date @dateformat
dateTime: Date @dateformat
}

type ContentfulDateSys @derivedTypes {
Expand Down Expand Up @@ -409,8 +399,8 @@ type ContentfulLocation implements ContentfulReference & ContentfulEntry & Node
}

type ContentfulLocationLocationLocalized {
lat: Float
lon: Float
lat: Float
}

type ContentfulLocationSys @derivedTypes {
Expand Down Expand Up @@ -438,25 +428,39 @@ type ContentfulJson implements ContentfulReference & ContentfulEntry & Node @der
contentful_id: String!
node_locale: String!
title: String
jsonLocalized: contentfulJsonJsonLocalizedJsonNode @link(by: "id", from: "jsonLocalized___NODE")
json: contentfulJsonJsonJsonNode @link(by: "id", from: "json___NODE")
spaceId: String
createdAt: Date @dateformat
updatedAt: Date @dateformat
sys: ContentfulJsonSys
json: contentfulJsonJsonJsonNode @link(by: "id", from: "json___NODE")
jsonLocalized: contentfulJsonJsonLocalizedJsonNode @link(by: "id", from: "jsonLocalized___NODE")
}

type contentfulJsonJsonLocalizedJsonNode implements Node @derivedTypes @childOf(types: ["ContentfulJson"]) @dontInfer {
type contentfulJsonJsonJsonNode implements Node @derivedTypes @childOf(types: ["ContentfulJson"]) @dontInfer {
age: Int
city: String
name: String
sys: contentfulJsonJsonLocalizedJsonNodeSys
sys: contentfulJsonJsonJsonNodeSys
Actors: [contentfulJsonJsonJsonNodeActors]
}

type contentfulJsonJsonLocalizedJsonNodeSys {
type contentfulJsonJsonJsonNodeSys {
type: String
}

type contentfulJsonJsonJsonNodeActors {
age: Int
name: String
wife: String
photo: String
weight: Float
Born_At: String @proxy(from: "Born At")
children: [String]
Birthdate: String
hasChildren: Boolean
hasGreyHair: Boolean
}

type ContentfulJsonSys @derivedTypes {
type: String
revision: Int
Expand All @@ -473,50 +477,36 @@ type ContentfulJsonSysContentTypeSys {
id: String
}

type contentfulJsonJsonJsonNode implements Node @derivedTypes @childOf(types: ["ContentfulJson"]) @dontInfer {
Actors: [contentfulJsonJsonJsonNodeActors]
sys: contentfulJsonJsonJsonNodeSys
type contentfulJsonJsonLocalizedJsonNode implements Node @derivedTypes @childOf(types: ["ContentfulJson"]) @dontInfer {
name: String
age: Int
city: String
sys: contentfulJsonJsonLocalizedJsonNodeSys
}

type contentfulJsonJsonJsonNodeActors {
name: String
age: Int
Born_At: String @proxy(from: "Born At")
Birthdate: String
photo: String
wife: String
weight: Float
hasChildren: Boolean
hasGreyHair: Boolean
children: [String]
}

type contentfulJsonJsonJsonNodeSys {
type contentfulJsonJsonLocalizedJsonNodeSys {
type: String
}

type ContentfulRichText implements ContentfulReference & ContentfulEntry & Node @derivedTypes @dontInfer {
contentful_id: String!
node_locale: String!
title: String
richTextValidated: ContentfulRichTextRichTextValidated
richText: ContentfulRichTextRichText
spaceId: String
createdAt: Date @dateformat
updatedAt: Date @dateformat
sys: ContentfulRichTextSys
richTextValidated: ContentfulRichTextRichTextValidated
richTextLocalized: ContentfulRichTextRichTextLocalized
richText: ContentfulRichTextRichText
}

type ContentfulRichTextRichTextValidated {
type ContentfulRichTextRichText {
raw: String
references: [ContentfulAssetContentfulLocationContentfulNumberContentfulTextUnion] @link(by: "id", from: "references___NODE")
references: [ContentfulAssetContentfulContentReferenceContentfulLocationContentfulTextUnion] @link(by: "id", from: "references___NODE")
}

union ContentfulAssetContentfulLocationContentfulNumberContentfulTextUnion = ContentfulAsset | ContentfulLocation | ContentfulNumber | ContentfulText
union ContentfulAssetContentfulContentReferenceContentfulLocationContentfulTextUnion = ContentfulAsset | ContentfulContentReference | ContentfulLocation | ContentfulText

type ContentfulRichTextSys @derivedTypes {
type: String
Expand All @@ -534,22 +524,59 @@ type ContentfulRichTextSysContentTypeSys {
id: String
}

type ContentfulRichTextRichTextLocalized {
type ContentfulRichTextRichTextValidated {
raw: String
references: [ContentfulAssetContentfulLocationContentfulNumberContentfulTextUnion] @link(by: "id", from: "references___NODE")
}

type ContentfulRichTextRichText {
union ContentfulAssetContentfulLocationContentfulNumberContentfulTextUnion = ContentfulAsset | ContentfulLocation | ContentfulNumber | ContentfulText

type ContentfulRichTextRichTextLocalized {
raw: String
references: [ContentfulAssetContentfulContentReferenceContentfulLocationContentfulTextUnion] @link(by: "id", from: "references___NODE")
}

union ContentfulAssetContentfulContentReferenceContentfulLocationContentfulTextUnion = ContentfulAsset | ContentfulContentReference | ContentfulLocation | ContentfulText

type ContentfulValidatedContentReference implements ContentfulReference & ContentfulEntry & Node @dontInfer {
contentful_id: String!
node_locale: String!
}

type MarkdownHeading {
id: String
value: String
depth: Int
}

enum MarkdownHeadingLevels {
h1
h2
h3
h4
h5
h6
}

enum MarkdownExcerptFormats {
PLAIN
HTML
MARKDOWN
}

type MarkdownWordCount {
paragraphs: Int
sentences: Int
words: Int
}

type MarkdownRemark implements Node @childOf(mimeTypes: ["text/markdown", "text/x-markdown"], types: ["contentfulTextLongPlainTextNode", "contentfulTextLongMarkdownTextNode", "contentfulTextLongLocalizedTextNode"]) @derivedTypes @dontInfer {
frontmatter: MarkdownRemarkFrontmatter
excerpt: String
rawMarkdownBody: String
}

type MarkdownRemarkFrontmatter {
title: String
}

type ContentfulContentType implements Node @derivedTypes @dontInfer {
name: String
displayField: String
Expand Down
Loading