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): provide gql type definitions using content model introspection and schema-customization #12816

Closed
wants to merge 36 commits into from
Closed
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
cec21d1
fix(schema): fix `types` for buildUnionType config object
pieh Mar 24, 2019
a90d932
feat(gatsby-source-contentful): provide gql type definitions using co…
pieh Mar 24, 2019
c8659b6
actually let's use empty space
pieh Mar 24, 2019
ab73df4
Merge remote-tracking branch 'origin/master' into contentful-schema
pieh May 20, 2019
ddac58b
use hot new extensions to define resolvers instead of importing inter…
pieh May 20, 2019
691469e
remove old RichTextNode type extension
pieh May 20, 2019
628aa6c
revert backreferece handling removal in nodes, adjust type def genera…
pieh May 20, 2019
c3e5483
bump peerDep - we rely on extensions added in 2.5.0
pieh May 21, 2019
738a726
remove unused import
pieh May 21, 2019
d59c28a
update snapshot - json fields no longer creates child nodes - it's em…
pieh May 21, 2019
0971d54
get rid of useless comment
pieh May 21, 2019
64fbe33
name union same way Gatsby does it
pieh May 21, 2019
2e2cbb3
remove stray commented out console.log
pieh May 21, 2019
01f1938
remove more stray comments that no longer apply after using extensions
pieh May 22, 2019
7e14ce6
create unions always for reference fields
pieh May 26, 2019
7f64fbd
skip checking if createTypes is available - this is hard requirment n…
pieh May 26, 2019
bc193f7
Merge remote-tracking branch 'origin/master' into contentful-schema
pieh May 26, 2019
f768ec3
skip back references fields if fieldname is already used
pieh May 26, 2019
81996b9
Merge remote-tracking branch 'origin/master' into contentful-schema
pieh Jun 24, 2019
2113bdc
using-contentful: union on refererences
pieh Jun 24, 2019
cb47eb0
gatsby-source-contentful: use `fieldName type` as base for backrefere…
pieh Jun 24, 2019
e3a3b02
using-contentful: update to make it work with changed back reference …
pieh Jun 24, 2019
d4d101b
chore: update yarn.lock
pieh Jun 24, 2019
0350f71
handling of childMarkdownRemark
pieh Jun 24, 2019
737d3d0
docs updates
pieh Jun 24, 2019
248ba72
add migration step on json fields
pieh Jun 24, 2019
5b155a5
remove note about api limitation
pieh Jun 24, 2019
c5052c2
revert unnecesary change
pieh Jun 24, 2019
aa1dfb9
update snapshots
pieh Jun 24, 2019
9717a34
revert changes to example's config file
pieh Jun 24, 2019
abc0e15
Apply suggestions from code review
pieh Jun 26, 2019
db68354
chore: format
Jul 1, 2019
ae7a0e8
Apply suggestions from code review
pieh Jul 4, 2019
7aa2bac
Merge remote-tracking branch 'origin/master' into contentful-schema
pieh Jul 4, 2019
1c0ec2f
Merge remote-tracking branch 'origin/master' into contentful-schema
pieh Jul 15, 2019
c9c2bf2
don't create reverse links for untyped references, show warning
pieh Jul 17, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 13 additions & 2 deletions examples/using-contentful/gatsby-config.js
Expand Up @@ -3,11 +3,22 @@ module.exports = {
title: `Gatsby with Contentful`,
},
plugins: [
// {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need these comments?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added TO-DO in PR description to remove those changes later on - for now I use this to validate everything works when there is 0 content (schema is the same regardless if there is content or not, so queries do not break)

// resolve: `gatsby-source-contentful`,
// options: {
// spaceId: `rocybtov1ozk`,
// accessToken: `6f35edf0db39085e9b9c19bd92943e4519c77e72c852d961968665f1324bfc94`,
// },
// },
// below is configuration for copy of space that doesn't contain any content
// but uses same content model. It actually works (as in without any content.
// Note: It's space created on my personal account that probably will be removed later,
// but you are free to test it out.
{
resolve: `gatsby-source-contentful`,
options: {
spaceId: `rocybtov1ozk`,
accessToken: `6f35edf0db39085e9b9c19bd92943e4519c77e72c852d961968665f1324bfc94`,
spaceId: `r8mgh95s9k6o`,
accessToken: `4587874e01060502262c3e85c4de8f6a4007d6a0eb34eda1d63626bef79aa7f1`,
},
},
`gatsby-transformer-remark`,
Expand Down
15 changes: 13 additions & 2 deletions examples/using-contentful/gatsby-node.js
Expand Up @@ -2,6 +2,17 @@ const _ = require(`lodash`)
const path = require(`path`)
const slash = require(`slash`)

exports.sourceNodes = ({ actions }) => {
// This is needed if there aren't any MarkdownRemark nodes.
// Once gatsby-transformer-remark has type definitions,
// we can remove it
actions.createTypes(`
type MarkdownRemark implements Node {
pieh marked this conversation as resolved.
Show resolved Hide resolved
html: String
}
`)
}

// Implement the Gatsby API “createPages”. This is
// called after the Gatsby bootstrap is finished so you have
// access to any information necessary to programmatically
Expand Down Expand Up @@ -51,7 +62,7 @@ exports.createPages = ({ graphql, actions }) => {
})
})
})
.then(() => {
.then(() =>
graphql(
`
{
Expand Down Expand Up @@ -90,5 +101,5 @@ exports.createPages = ({ graphql, actions }) => {
})
})
})
})
)
}
5 changes: 1 addition & 4 deletions examples/using-contentful/package.json
Expand Up @@ -25,12 +25,9 @@
],
"license": "MIT",
"main": "n/a",
"resolutions": {
"contentful": "6.1.0"
},
"scripts": {
"develop": "gatsby develop",
"build": "gatsby build",
"start": "gatsby serve"
}
}
}
10 changes: 8 additions & 2 deletions examples/using-contentful/src/templates/product.js
Expand Up @@ -83,8 +83,14 @@ export const pageQuery = graphql`
}
}
brand {
companyName {
companyName
# seems like limitation (or bug) of Contentful API
# we don't have access in introspection to figure
# out what types can be referenced
# so union is created with all content types
... on ContentfulBrand {
companyName {
companyName
}
}
}
categories {
Expand Down
4 changes: 2 additions & 2 deletions packages/gatsby-source-contentful/package.json
Expand Up @@ -12,7 +12,7 @@
"base64-img": "^1.0.3",
"bluebird": "^3.5.0",
"chalk": "^2.3.2",
"contentful": "^6.1.0",
"contentful": "^7.6.0",
"deep-map": "^1.5.0",
"fs-extra": "^4.0.2",
"gatsby-plugin-sharp": "^2.0.37",
Expand All @@ -37,7 +37,7 @@
],
"license": "MIT",
"peerDependencies": {
"gatsby": "^2.0.33"
"gatsby": "^2.5.0"
},
"repository": "https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby-source-contentful",
"scripts": {
Expand Down