Skip to content

Commit c9d98a4

Browse files
LekoArtspieh
andauthored
feat(gatsby): Initial GraphQL Typegen Implementation (#35487)
Co-authored-by: Michal Piechowiak <[email protected]>
1 parent 17cbc7c commit c9d98a4

File tree

36 files changed

+1343
-64
lines changed

36 files changed

+1343
-64
lines changed

e2e-tests/development-runtime/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,5 @@ cypress/fixtures
7474
cypress/videos
7575

7676
__history__.json
77+
78+
src/gatsby-types.d.ts
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
describe('fragments.graphql', () => {
2+
it('exists in .cache folder', () => {
3+
cy.readFile('.cache/typegen/fragments.graphql')
4+
})
5+
})
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
describe('graphql-config', () => {
2+
it('exists in .cache folder with correct data', () => {
3+
cy.readFile('.cache/typegen/graphql.config.json', 'utf-8').then((json) => {
4+
expect(json).to.deep.equal({
5+
"schema": ".cache/typegen/schema.graphql",
6+
"documents": [
7+
"src/**/**.{ts,js,tsx,jsx}",
8+
".cache/typegen/fragments.graphql"
9+
],
10+
"extensions": {
11+
"endpoints": {
12+
"default": {
13+
"url": "http://localhost:8000/___graphql"
14+
}
15+
}
16+
}
17+
})
18+
})
19+
})
20+
})
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
describe('schema.graphql', () => {
2+
it('exists in .cache folder', () => {
3+
cy.readFile('.cache/typegen/schema.graphql')
4+
})
5+
})
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
describe('gatsby-types.d.ts', () => {
2+
it('exists in src folder', () => {
3+
cy.readFile('src/gatsby-types.d.ts')
4+
})
5+
})

e2e-tests/development-runtime/gatsby-config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ module.exports = {
88
},
99
flags: {
1010
DEV_SSR: false,
11+
GRAPHQL_TYPEGEN: true,
1112
},
1213
plugins: [
1314
`gatsby-plugin-react-helmet`,

e2e-tests/development-runtime/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"prop-types": "^15.6.2",
2626
"react": "^17.0.2",
2727
"react-dom": "^17.0.2",
28-
"react-helmet": "^5.2.1",
28+
"react-helmet": "^6.1.0",
2929
"sass": "^1.32.8"
3030
},
3131
"keywords": [
@@ -35,7 +35,7 @@
3535
"license": "MIT",
3636
"scripts": {
3737
"build": "gatsby build",
38-
"develop": "cross-env CYPRESS_SUPPORT=y ENABLE_GATSBY_REFRESH_ENDPOINT=true GATSBY_EXPERIMENTAL_QUERY_ON_DEMAND=y gatsby develop",
38+
"develop": "cross-env CYPRESS_SUPPORT=y ENABLE_GATSBY_REFRESH_ENDPOINT=true GATSBY_EXPERIMENTAL_QUERY_ON_DEMAND=y GATSBY_GRAPHQL_TYPEGEN=y gatsby develop",
3939
"serve": "gatsby serve",
4040
"clean": "gatsby clean",
4141
"start": "npm run develop",

e2e-tests/development-runtime/src/pages/collection-routing/hogwarts/{FakeData.uuid}.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export default function FakeDataHogwarts({ data: { fake }, pageContext: { uuid }
1515
}
1616

1717
export const blogPostQuery = graphql`
18-
query($id: String!) {
18+
query FakeDataHogwarts($id: String!) {
1919
fake: fakeData(id: { eq: $id }) {
2020
fields {
2121
slug

e2e-tests/development-runtime/src/pages/collection-routing/prefix-{FakeData.uuid}.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export default function FakeDataPrefix({ data: { fake }, pageContext: { uuid } }
1515
}
1616

1717
export const blogPostQuery = graphql`
18-
query($id: String!) {
18+
query FakeDataPrefix($id: String!) {
1919
fake: fakeData(id: { eq: $id }) {
2020
fields {
2121
slug

e2e-tests/development-runtime/src/pages/collection-routing/{FakeData.title}/{FakeData.uuid}.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export default function FakeDataNested({ data: { fake }, pageContext: { uuid } }
1515
}
1616

1717
export const blogPostQuery = graphql`
18-
query($id: String!) {
18+
query FakeDataNested($id: String!) {
1919
fake: fakeData(id: { eq: $id }) {
2020
fields {
2121
slug

0 commit comments

Comments
 (0)