Skip to content

Commit

Permalink
Log type conflics when inferring graphql types (gatsbyjs#3905)
Browse files Browse the repository at this point in the history
* add nodeDescription field to node internal object

Signed-off-by: Michal Piechowiak <[email protected]>

* store extracted example value to not run it 4 times for same nodes (for fields, for input fields, for sort field enums and for group enums)

Signed-off-by: Michal Piechowiak <[email protected]>

* introduce TypeConflictReporter utility class that will store and print type conflicts when creating graphql schema

Signed-off-by: Michal Piechowiak <[email protected]>

* enhance findRootNode function to accept predicate function and rename it to findRootNodeAncestor

Signed-off-by: Michal Piechowiak <[email protected]>

* rewrite extractFieldExamples to be able to keep track of selector path and detect type conflicts early (to not merge values if there is conflict)

Signed-off-by: Michal Piechowiak <[email protected]>

* use type conflict reporter when extracting example value

Signed-off-by: Michal Piechowiak <[email protected]>

* add nested arrays in array of objects to tests

Signed-off-by: Michal Piechowiak <[email protected]>

* rename nodeDescription to description

Signed-off-by: Michal Piechowiak <[email protected]>

* add tests for conflict reporting

Signed-off-by: Michal Piechowiak <[email protected]>

* space out conflict info to be more readable

Signed-off-by: Michal Piechowiak <[email protected]>

* add description for possible conflicts in page context

Signed-off-by: Michal Piechowiak <[email protected]>

* fix schema type conflict in gatsbyjs.org

Signed-off-by: Michal Piechowiak <[email protected]>

* Silence SitePlugin type conflicts

Signed-off-by: Michal Piechowiak <[email protected]>

* just in case clear type examples store in data-tree-utils tests - currently examples are not stored because type is not set - this is just future proofing

Signed-off-by: Michal Piechowiak <[email protected]>

* rename getExampleValue to getExampleValues

Signed-off-by: Michal Piechowiak <[email protected]>
  • Loading branch information
pieh authored and KyleAMathews committed Apr 14, 2018
1 parent 1cc2299 commit d90b12b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/create-file-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,15 @@ exports.createFileNode = async (pathToFile, pluginOptions = {}) => {
internal = {
contentDigest,
type: `Directory`,
description: `Directory "${path.relative(process.cwd(), slashed)}"`,
}
} else {
const contentDigest = await md5File(slashedFile.absolutePath)
internal = {
contentDigest,
mediaType: mime.lookup(slashedFile.ext),
type: `File`,
description: `File "${path.relative(process.cwd(), slashed)}"`,
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/create-remote-file-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ async function processRemoteNode({ url, store, cache, createNode, auth = {} }) {

// Create the file node.
const fileNode = await createFileNode(filename, {})

fileNode.internal.description = `File "${url}"`
// Override the default plugin as gatsby-source-filesystem needs to
// be the owner of File nodes or there'll be conflicts if any other
// File nodes are created through normal usages of
Expand Down

0 comments on commit d90b12b

Please sign in to comment.