Skip to content

Commit

Permalink
fix(gatsby): Add error message for field extension validation (#16232)
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanprobst authored and sidharthachatterjee committed Jul 30, 2019
1 parent 6d8b663 commit f64a9e0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/gatsby/src/schema/infer/__tests__/merge-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ describe(`merges explicit and inferred type definitions`, () => {
links: {
type: `[Test!]!`,
extensions: {
link: true,
link: {},
},
},
},
Expand Down
9 changes: 9 additions & 0 deletions packages/gatsby/src/schema/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,15 @@ const addExtensions = ({
.filter(name => !internalExtensionNames.includes(name))
.forEach(name => {
const args = fieldExtensions[name]

if (!args || typeof args !== `object`) {
report.error(
`Field extension arguments must be provided as an object. ` +
`Received "${args}" on \`${typeName}.${fieldName}\`.`
)
return
}

try {
const definition = schemaComposer.getDirective(name)

Expand Down

0 comments on commit f64a9e0

Please sign in to comment.