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

CTF-next: Generate GraphQL schema based on Contentful Content Types #30855

Open
wants to merge 177 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
177 commits
Select commit Hold shift + click to select a range
d6a6752
WIP - initial schema generation
axe312ger Apr 12, 2021
38f1f2a
allow complex field types and add date formatter for date fields
axe312ger Apr 12, 2021
e6b8be1
move generic fields to reference type
axe312ger Apr 12, 2021
9a647e8
use generic types for entry sys and content types
axe312ger Apr 12, 2021
608f26f
use generic types for rich text fields
axe312ger Apr 12, 2021
09b4ac9
use generic types for location fields
axe312ger Apr 12, 2021
45f5cce
use generic types for JSON fields
axe312ger Apr 12, 2021
b546b4f
use generic types for Text fields
axe312ger Apr 12, 2021
a049f87
fix: ensure links from is set properly
axe312ger Apr 12, 2021
509c7ce
rename internal interfaces to avoid name collisions
axe312ger Apr 12, 2021
c0bcaa7
properly set links for references to new generic types
axe312ger Apr 12, 2021
4915a3f
no more create nodes for JSON, RichText and Location
axe312ger Apr 13, 2021
8bfd1a9
refactor: clean up code
axe312ger Apr 13, 2021
1fcdb65
refactor: reintroduce contentful sys common resource attribute #31007
axe312ger Apr 29, 2021
4c843b9
refactor: align Rich Text field structure to Contentful GraphQL API (…
axe312ger May 5, 2021
78904aa
refactor: flatten Contentful asset data structure to match GraphQL AP…
axe312ger May 5, 2021
90f5b59
update e2e snapshots
axe312ger May 20, 2021
15fd737
fix: render RichText without links
axe312ger Jun 11, 2021
ce6ce57
test(e2e): update snapshots
axe312ger Jun 11, 2021
f44c518
Revert "test(e2e): update snapshots"
axe312ger Jun 11, 2021
02860a6
refactor: rename schema types to avoid conflicts
axe312ger Jun 11, 2021
d4716a4
feat: tags are now enabled by default
axe312ger Jul 21, 2021
06ab362
fix: tags schema
axe312ger Jul 27, 2021
3c2307e
refactor: clean up code and improve comments
axe312ger Jul 27, 2021
2c72828
clean up, fix tests, get downloadAssets working again
axe312ger Nov 18, 2021
cde8173
more small fixes
axe312ger Nov 19, 2021
cefa3fa
fix: align downloadLocal scheme and gatsby-plugin-image
axe312ger Nov 26, 2021
c5349f5
style: use object syntax everywhere to define schema
axe312ger Nov 26, 2021
9656127
fix: make unit tests pass. Solution for deleted entries still needs work
axe312ger Nov 29, 2021
5e43517
feat: use union for reference fields with validation (#31395)
axe312ger Nov 29, 2021
9cae6f8
style: rename ContentfulReference interface to ContentfulEntity
axe312ger Jan 14, 2022
69e2688
fix: readd tag support for assets
axe312ger Jan 20, 2022
e47612e
fix reference resolving and adjust tests
axe312ger Feb 2, 2022
dee4ae2
fix merge issues and make unit tests pass
axe312ger Mar 9, 2022
a4fba18
cleanup
axe312ger Mar 11, 2022
e9b1ee1
fix: remove asset url protocol duplication
axe312ger Mar 16, 2022
0909aa3
update code and tests from rebase
axe312ger Apr 14, 2022
e22b310
refactor asset data structure to satisfy tests and imageCDN from rebase
axe312ger Apr 14, 2022
e05902e
update e2e test schema file
axe312ger Apr 14, 2022
7813794
style: rename generateReferenceId to createRefId
axe312ger Apr 14, 2022
71bb38a
style: move all schema customization related code back to original file
axe312ger Apr 14, 2022
b591950
fix: change contentType to mimeType and fileName to filename in asset…
axe312ger May 17, 2022
bdfcdd4
fix: allow assets without files for preview
axe312ger Mar 25, 2022
7ea4514
feat: throw error on reservated field names
axe312ger Mar 25, 2022
dde57b3
Merge branch 'master' into feat/contentful-schema-generation
axe312ger Nov 3, 2022
414d2b6
style: update contentful e2e test filter syntax
axe312ger Nov 9, 2022
12f3a7e
test(e2e): update snapshot version
axe312ger Nov 9, 2022
5f02b04
test(e2e): fix path to SVG files in gatsby plugin image test
axe312ger Nov 9, 2022
6997bb1
feat: resolve Rich Text links only from within the same space
axe312ger Nov 9, 2022
684a13d
tre: use link extension instead of adding ___NODE to field names (#37…
axe312ger Nov 17, 2022
e2c0812
Merge branch 'master' into feat/contentful-schema-generation
axe312ger Feb 22, 2023
c699541
Merge branch 'master' into feat/contentful-schema-generation
axe312ger Feb 24, 2023
8ca82f7
chore: rewrite to TypeScript (#37123)
axe312ger Mar 17, 2023
53ef083
Merge branch 'master' into feat/contentful-schema-generation
axe312ger Mar 17, 2023
f089bf4
fix: align imports to match new export pattern of the plugin
axe312ger Mar 17, 2023
55cdb64
fix: remove duplication of https in image generation hook
axe312ger Mar 17, 2023
1180b0a
Merge branch 'master' into feat/contentful-schema-generation
axe312ger Mar 30, 2023
0848e82
fix: small performance improvements and cleanups
axe312ger Mar 30, 2023
6e3ab6f
Merge branch 'master' into feat/contentful-schema-generation
axe312ger Apr 3, 2023
edc9039
build: update yarn.lock
axe312ger Apr 3, 2023
f44d616
build: fix dependency version
axe312ger Apr 3, 2023
64c0fb7
build: undirty lock file
axe312ger Apr 3, 2023
c8edd7e
test: align content type names in rich text e2e test
axe312ger Apr 3, 2023
63fbccf
Merge branch 'master' into feat/contentful-schema-generation
axe312ger Apr 3, 2023
64feb4d
Merge branch 'master' into feat/contentful-schema-generation
axe312ger Apr 12, 2023
689c035
fix: move typing for enableStatefulSourceNodes into Actions
axe312ger Apr 12, 2023
a45b3a7
metadata is now a reserved field name as well
axe312ger Apr 12, 2023
2faa545
Merge branch 'master' into feat/contentful-schema-generation
axe312ger Apr 12, 2023
96d5ce8
Merge branch 'master' into feat/contentful-schema-generation
axe312ger Apr 12, 2023
51d7d0b
refactor: reverse references via linkedFrom field (#37811)
axe312ger Apr 12, 2023
d46370e
Merge branch 'master' into feat/contentful-schema-generation
axe312ger Apr 24, 2023
be4f085
Merge branch 'feat/contentful-schema-generation' of github.com:gatsby…
axe312ger Apr 24, 2023
fed60ee
fix: caching with back references should work out fine now
axe312ger May 2, 2023
37ba20c
build: update yarn.lock
axe312ger May 2, 2023
47273d2
build: update yarn.lock
axe312ger May 2, 2023
f00f2ab
make typegen happy for now
axe312ger May 8, 2023
272097b
tests: make sure temp images are not comitted to git
axe312ger May 8, 2023
73dcd5a
refactor: rewrite typeing to make CI happy
axe312ger May 8, 2023
4b1fed2
fix import
axe312ger May 8, 2023
bae4fa2
load data store async as its not available on initial typegen
axe312ger May 8, 2023
8959736
tell typegen to hush for the not yet type exposed getDataStore
axe312ger May 8, 2023
e48c01c
rewrite utils.js to ts
axe312ger May 17, 2023
1ca6c82
Merge branch 'feat/contentful-schema-generation' of github.com:gatsby…
axe312ger May 17, 2023
6aa0f5c
build: migrate to latest Contentful JS SDK
axe312ger May 23, 2023
71cfc3f
fix: ensure sync results are not resolved
axe312ger Jun 5, 2023
5507318
Merge branch 'master' into feat/contentful-schema-generation
axe312ger Jun 5, 2023
14964d1
build: migrate dependencies to latest or most fitting version
axe312ger Jun 5, 2023
cb0e093
chore: remove unused test fixture
axe312ger Jun 5, 2023
9285b11
refactor: use proper types for localFile and gatsbyImageData
axe312ger Jun 5, 2023
df9e439
Merge branch 'master' into feat/contentful-schema-generation
axe312ger Jun 12, 2023
1c8c37f
build: fix yarn.lock
axe312ger Jun 12, 2023
3f2729b
Merge branch 'master' into feat/contentful-schema-generation
axe312ger Jun 16, 2023
fdd331a
build: clean up lock file
axe312ger Jun 16, 2023
3d01f47
feat: support CPA by nulling unresolvable linked nodes
axe312ger Jun 16, 2023
a0bd975
chore: remove no more supported traced_svg placeholder
axe312ger Jun 16, 2023
c6a3aa2
chore: remove no more used snapshots
axe312ger Jun 16, 2023
6f2b8ea
test: add missing reporter.warn mock
axe312ger Jun 16, 2023
8f01f62
test(e2e): introduce a second e2e run that tests Contentfuls preview API
axe312ger Jun 19, 2023
2b7d726
chore: type CTF API error message
axe312ger Jun 19, 2023
44142a9
feat: integrate space id into reference linking to prepare for cross …
axe312ger Jun 20, 2023
4626cf1
Merge branch 'master' into feat/contentful-schema-generation
axe312ger Jun 28, 2023
0106ede
Merge branch 'master' into feat/contentful-schema-generation
axe312ger Jun 29, 2023
cdede37
feat: large projects now can decide which text fields are turned into…
axe312ger Jun 29, 2023
bc218a2
chore: remove TODO comment about already solved issue
axe312ger Jun 29, 2023
ed5990c
chore: remove TODO comment about already solved issue #2
axe312ger Jun 29, 2023
b9f689c
Merge branch 'master' into feat/contentful-schema-generation
axe312ger Jul 13, 2023
83105be
chore: fix type error
axe312ger Jul 13, 2023
134404e
chore: improve typing of gatsby-plugin-image implementation
axe312ger Jul 13, 2023
5c1208a
chore: remove outdated TODO comment
axe312ger Jul 13, 2023
51e28a3
chore: removed obsolete TODO suggestion\ndelete node should take care…
axe312ger Jul 13, 2023
01df3bb
chore: removed obsolete TODO suggestion\nGatsby drastically improved …
axe312ger Jul 13, 2023
6418327
perf: create a map of field configurations instead of getting it mult…
axe312ger Jul 13, 2023
44bfc63
chore: remove obsolete TODO comment
axe312ger Jul 13, 2023
f131315
chore: remove obsolete TODO comment - we can not fully replicate Cont…
axe312ger Jul 13, 2023
62ccc7d
fix: prevent local file nodes from being flagged as stale
axe312ger Jul 26, 2023
ee994cd
Merge branch 'master' into feat/contentful-schema-generation
axe312ger Jul 26, 2023
d37d98d
build: clean up lock file
axe312ger Jul 26, 2023
4ecd4f0
build: fix version requirement
axe312ger Jul 26, 2023
f1a338e
build: update yarn.lock
axe312ger Jul 26, 2023
37af2ba
chore: fix type error
axe312ger Jul 28, 2023
935d132
chore: fix typing issue
axe312ger Jul 28, 2023
feab1d9
chore: fix typing issue #2
axe312ger Jul 28, 2023
4305f70
fix: typing issue
axe312ger Aug 11, 2023
9b955e1
Merge branch 'master' into feat/contentful-schema-generation
axe312ger Aug 31, 2023
1847bb8
chore: improve typing to satisfy typegen on CI
axe312ger Aug 31, 2023
24c07bd
fix: improve reporter progress (bar) implementation
axe312ger Aug 31, 2023
96772cd
chore: another tryo to fix CI typegen
axe312ger Aug 31, 2023
4dc79b4
test: adjust fetch test for last merge
axe312ger Aug 31, 2023
00c047c
fix: add linkedFrom field to restricted/reserved field names
axe312ger Aug 15, 2023
ff71a27
fix: use same list of restricted node fields everywhere
axe312ger Aug 15, 2023
cd15a05
fix: rename metadata field to contentfulMetadata
axe312ger Aug 15, 2023
ddd8396
fix: take useNameForId into account when creating reference fields
axe312ger Aug 15, 2023
fcf3930
test: update test snapshots to reflect metadata rename
axe312ger Aug 31, 2023
b892878
test: fix e2e test to reflect metadata rename
axe312ger Sep 4, 2023
f906618
Merge branch 'master' into feat/contentful-schema-generation
axe312ger Sep 4, 2023
2fc145c
fix: big projects no more break due to vaulty foreign reference map
axe312ger Sep 4, 2023
e72da87
fix: ensure unions do not point on no more existing content types
axe312ger Sep 4, 2023
93e09d2
Merge branch 'master' into feat/contentful-schema-generation
axe312ger Sep 14, 2023
0d4f3c7
fix: sys.contentType is now properly linked
axe312ger Sep 14, 2023
36a2933
test: update snapshot
axe312ger Sep 14, 2023
6e68121
CTF-next: codemods to help for migration (#35113)
axe312ger Sep 18, 2023
d0a381e
Update .gitignore
axe312ger Sep 27, 2023
ad31c92
test: fix codemods test by adding new test name to expect
axe312ger Sep 27, 2023
8cfe253
build: add missing lodash to gatsby-codemods for ctf codemod
axe312ger Sep 27, 2023
c0a0ba5
fix: custom content type prefix option now actually affects the gener…
axe312ger Oct 13, 2023
27cb57c
test(e2e): add tests for custom fields and custom resolvers
axe312ger Oct 13, 2023
8d58c39
fix: no more skip fields that are hidden from editing
axe312ger Nov 22, 2023
9e61200
fix(contentful): rich text linked asset filter (#38716)
FrivalszkyP Dec 6, 2023
f84fbf6
Merge branch 'feat/contentful-schema-generation' of github.com:gatsby…
axe312ger Dec 6, 2023
c4903b9
fix(gatsby-source-contentful): don't apply parent node links to child…
axe312ger Dec 6, 2023
badaef3
Merge branch 'master' into feat/contentful-schema-generation
axe312ger Dec 6, 2023
9fa54ba
fix: set children on entries for markdown fields so Gatsby can automa…
axe312ger Dec 6, 2023
4975e7e
build: ensure e2e test points on correct version (bumped for X.99.0 c…
axe312ger Dec 6, 2023
075284a
build: remove gatsby-plugin-sharp and sharp from peer dependenceis as…
axe312ger Dec 6, 2023
7cae5fc
docs: revamp README.md and add MIGRATION.md
axe312ger Dec 14, 2023
b229a5f
chore: fix tests and typing
axe312ger Dec 21, 2023
feaea0d
Merge branch 'master' into feat/contentful-schema-generation
axe312ger Dec 21, 2023
e084c3d
chore: adjust package versions to make build process happy
axe312ger Dec 21, 2023
384a825
docs: simplify codemods
axe312ger Dec 21, 2023
3105a7a
docs: add hint that we now no more have a spam of @link directive war…
axe312ger Dec 21, 2023
5e719c2
fix: avoid deletion of node properties"
axe312ger Dec 21, 2023
ced0cb0
chore: clean up package.json/workspace
axe312ger Dec 21, 2023
329566c
fix: improve typings for rich text rendering
axe312ger Dec 28, 2023
cfd7b29
fix: further improve rich text types
axe312ger Dec 28, 2023
e96c389
fix: schema building no more fails when Content Model has none or onl…
axe312ger Dec 28, 2023
42540e9
test: update snapshots
axe312ger Dec 28, 2023
d53b2cf
docs: improve Rich Text rendering section for migration
axe312ger Dec 28, 2023
7bef97a
docs: format migration.md to make linting happy
axe312ger Dec 28, 2023
b8421a7
Merge branch 'master' into feat/contentful-schema-generation
axe312ger Dec 28, 2023
fb4bc50
docs: improve codemod instructions
axe312ger Jan 31, 2024
bf2b92f
docs: further improve codemod instructions
axe312ger Jan 31, 2024
343a9ef
fix: add missing date format extension/directive to sys properties of…
axe312ger Jan 31, 2024
798006b
chore: remove joi config for old and removed config option enableTags
axe312ger Feb 2, 2024
aa63a16
feat: support required Contentful fields while giving CPA users an op…
axe312ger Feb 2, 2024
2c364df
feat: log to console from which CTF environment the data is loaded
axe312ger Feb 20, 2024
1ce2026
perf(gatsby): add a way to skip tracking inline objects (#38805)
axe312ger Feb 29, 2024
aacdd40
Merge branch 'master' into feat/contentful-schema-generation
axe312ger Feb 29, 2024
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
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ packages/gatsby-source-shopify/**/*.js
packages/gatsby-plugin-preload-fonts/prepare/*.js
packages/gatsby/cache-dir/commonjs/**/*
packages/gatsby-codemods/transforms
packages/gatsby-source-contentful/src/types/contentful-js-sdk
packages/gatsby-source-graphql/batching
packages/gatsby-plugin-gatsby-cloud/components
packages/gatsby-plugin-gatsby-cloud/context
Expand Down
23 changes: 14 additions & 9 deletions e2e-tests/contentful/cypress.config.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,35 @@
import { defineConfig } from "cypress"
import { addMatchImageSnapshotPlugin } from "@simonsmith/cypress-image-snapshot/plugin"

const specFolder = process.env.CTF_API === "preview" ? "preview" : "delivery"

export default defineConfig({
e2e: {
baseUrl: `http://localhost:9000`,
specPattern: `cypress/integration/**/*.{js,ts}`,
specPattern: `cypress/integration/${specFolder}/**/*.{js,ts}`,
projectId: `2193cm`,
viewportWidth: 1440,
viewportHeight: 900,
retries: {
runMode: 0,
openMode: 0
openMode: 0,
},
videoUploadOnPasses: false,
setupNodeEvents(on, config) {
addMatchImageSnapshotPlugin(on, config)
on("before:browser:launch", (browser = {} as Cypress.Browser, launchOptions) => {
if (browser.family === "chromium" || browser.name === "chrome") {
// Make retina screens run at 1x density so they match the versions in CI
launchOptions.args.push("--force-device-scale-factor=1")
on(
"before:browser:launch",
(browser = {} as Cypress.Browser, launchOptions) => {
if (browser.family === "chromium" || browser.name === "chrome") {
// Make retina screens run at 1x density so they match the versions in CI
launchOptions.args.push("--force-device-scale-factor=1")
}
return launchOptions
}
return launchOptions
})
)
},
},
env: {
requireSnapshots: true,
}
},
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
// Make sure to keep test from this file in sync with previews/content-reverence.js
describe(`content-reference`, () => {
beforeEach(() => {
cy.visit("/content-reference").waitForRouteChange()
})
it(`content-reference-many-2nd-level-loop`, () => {
cy.get(
'[data-cy-id="default-content-reference-many-2nd-level-loop"]'
).snapshot()
})
it(`content-reference-many-loop-a-greater-b`, () => {
cy.get(
'[data-cy-id="default-content-reference-many-loop-a-greater-b"]'
).snapshot()
})
it(`content-reference-many-loop-b-greater-a`, () => {
cy.get(
'[data-cy-id="default-content-reference-many-loop-b-greater-a"]'
).snapshot()
})
it(`content-reference-many-self-reference`, () => {
cy.get(
'[data-cy-id="default-content-reference-many-self-reference"]'
).snapshot()
})
it(`content-reference-one`, () => {
cy.get('[data-cy-id="default-content-reference-one"]').snapshot()
})
it(`content-reference-one-loop-a-greater-b`, () => {
cy.get(
'[data-cy-id="default-content-reference-one-loop-a-greater-b"]'
).snapshot()
})
it(`content-reference-one-loop-b-greater-a`, () => {
cy.get(
'[data-cy-id="default-content-reference-one-loop-b-greater-a"]'
).snapshot()
})
it(`content-reference-one-self-reference`, () => {
cy.get(
'[data-cy-id="default-content-reference-one-self-reference"]'
).snapshot()
})
// Previe api test. Content should not exist on delivery
it(`content-reference-preview-api-test`, () => {
cy.get(
'[data-cy-id="default-preview-api-test-unpublished-and-linking-to-non-existing-entry"]'
).should("not.exist")
})
})

describe(`content-reference localized`, () => {
beforeEach(() => {
cy.visit("/content-reference").waitForRouteChange()
})
it(`english-content-reference-one-localized`, () => {
cy.get('[data-cy-id="english-content-reference-one-localized"]').snapshot()
})
it(`english-content-reference-many-localized`, () => {
cy.get('[data-cy-id="english-content-reference-many-localized"]').snapshot()
})
it(`german-content-reference-one-localized`, () => {
cy.get('[data-cy-id="german-content-reference-one-localized"]').snapshot()
})
it(`german-content-reference-many-localized`, () => {
cy.get('[data-cy-id="german-content-reference-many-localized"]').snapshot()
})
})
19 changes: 19 additions & 0 deletions e2e-tests/contentful/cypress/integration/delivery/custom-fields.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
describe(`custom-fields`, () => {
beforeEach(() => {
cy.visit("/custom-fields").waitForRouteChange()
})

it(`custom-fields: custom field`, () => {
cy.get(`[data-cy-id="field"] [data-cy-value]`).should(
`have.text`,
`customFieldValue`
)
})

it(`custom-fields: custom resolver`, () => {
cy.get(`[data-cy-id="resolver"] [data-cy-value]`).should(
`have.text`,
`customResolverResult`
)
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,6 @@ describe(`gatsby-plugin-image`, () => {
it(`dominant-color`, testConfig, () =>
testGatsbyPluginImage(`dominant-color`, hasColorPlaceholder)
)
it(`traced`, testConfig, () =>
testGatsbyPluginImage(`traced`, hasColorPlaceholder)
)
it(`blurred`, testConfig, () =>
testGatsbyPluginImage(`blurred`, hasBase64Placeholder)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ describe(`media-reference`, () => {
cy.get("img")
.should("have.length", 2)
.should("have.attr", "src")
.should("match", /^\/\/images\.ctfassets\.net/)
.should("match", /^https:\/\/images\.ctfassets\.net/)
})
})

it(`media-reference: one`, () => {
cy.get('[data-cy-id="media-reference-one"]').within(() => {
cy.get("img")
.should("have.attr", "src")
.should("match", /^\/\/images\.ctfassets\.net/)
.should("match", /^https:\/\/images\.ctfassets\.net/)
})
})
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
describe(`content-reference`, () => {
describe(`prewview-content-reference`, () => {
beforeEach(() => {
cy.visit("/content-reference").waitForRouteChange()
})
Expand Down Expand Up @@ -40,6 +40,12 @@ describe(`content-reference`, () => {
'[data-cy-id="default-content-reference-one-self-reference"]'
).snapshot()
})
// Most relevant preview api test (the others are still good to test!)
it(`content-reference-preview-api-test`, () => {
cy.get(
'[data-cy-id="default-preview-api-test-unpublished-and-linking-to-non-existing-entry"]'
).snapshot()
})
})

describe(`content-reference localized`, () => {
Expand Down
Binary file not shown.
Binary file not shown.
24 changes: 15 additions & 9 deletions e2e-tests/contentful/gatsby-config.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
const ctfOptions = {
// This space is for testing purposes only.
// Never store your Contentful credentials in your projects config file.
// Use: https://www.gatsbyjs.com/docs/how-to/local-development/environment-variables/
spaceId: `k8iqpp6u0ior`,
accessToken: `hO_7N0bLaCJFbu5nL3QVekwNeB_TNtg6tOCB_9qzKUw`,
downloadLocal: true,
}

if (process.env.CTF_API === "preview") {
ctfOptions.host = `preview.contentful.com`
ctfOptions.accessToken = `IkSw3qEFt8NHKQUko2hIVDgu6x3AMtAkNecQZvg2034`
}

module.exports = {
siteMetadata: {
title: `Gatsby Contentful e2e`,
},
plugins: [
{
resolve: `gatsby-source-contentful`,
options: {
// This space is for testing purposes only.
// Never store your Contentful credentials in your projects config file.
// Use: https://www.gatsbyjs.com/docs/how-to/local-development/environment-variables/
spaceId: `k8iqpp6u0ior`,
accessToken: `hO_7N0bLaCJFbu5nL3QVekwNeB_TNtg6tOCB_9qzKUw`,
enableTags: true,
downloadLocal: true,
},
options: ctfOptions,
},
`gatsby-transformer-remark`,
`gatsby-transformer-sharp`,
Expand Down
39 changes: 39 additions & 0 deletions e2e-tests/contentful/gatsby-node.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
exports.onCreateNode = ({ node, actions }) => {
const { createNodeField } = actions

if (node.internal.type === "ContentfulContentTypeText") {
createNodeField({
node,
name: "customField",
value: "customFieldValue",
})
}
}

exports.createSchemaCustomization = ({ actions, schema }) => {
const { createTypes } = actions

const typeDefs = `
type ContentfulContentTypeTextFields {
customField: String!
}
type ContentfulContentTypeText {
fields: ContentfulContentTypeTextFields!
}
`

createTypes(typeDefs)
}

exports.createResolvers = ({ createResolvers }) => {
createResolvers({
ContentfulContentTypeText: {
customResolver: {
type: 'String!',
resolve(source, args, context, info) {
return "customResolverResult"
},
},
},
})
}
5 changes: 4 additions & 1 deletion e2e-tests/contentful/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"cross-env": "^7.0.3",
"cypress": "^12.16.0",
"gatsby-cypress": "next",
"npm-run-all": "^4.1.5",
"prettier": "^2.8.8",
"srcset": "^5.0.0",
"start-server-and-test": "^2.0.3",
Expand All @@ -38,7 +39,9 @@
"build": "gatsby build",
"develop": "gatsby develop",
"format": "prettier --write '**/*.js'",
"test": "cross-env CYPRESS_SUPPORT=y npm run build && npm run start-server-and-test",
"test": "npm-run-all -c -s test:delivery test:preview",
"test:delivery": "gatsby clean && cross-env CYPRESS_SUPPORT=y CTF_API=delivery npm run build && CTF_API=delivery npm run start-server-and-test",
"test:preview": "gatsby clean && cross-env CYPRESS_SUPPORT=y CTF_API=preview npm run build && CTF_API=preview npm run start-server-and-test",
"start-server-and-test": "start-server-and-test serve http://localhost:9000 cy:run",
"serve": "gatsby serve",
"cy:open": "cypress open --browser chrome --e2e",
Expand Down
Loading