Skip to content

Commit 7150ad9

Browse files
committed
cleanup
1 parent 726ba34 commit 7150ad9

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

packages/gatsby/src/schema/schema.js

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,13 +1040,10 @@ const addInferredChildOfExtension = ({ schemaComposer, typeComposer }) => {
10401040
let childOfExtension = childTypeComposer.getExtension(`childOf`)
10411041
const many = maxChildCount > 1
10421042

1043-
// Only warn when the parent-child relation has not been explicitly set with
1044-
if (
1045-
!childOfExtension ||
1046-
!childOfExtension.types.includes(parentTypeName) ||
1047-
childOfExtension.many !== many
1048-
) {
1043+
// Add `@childOf` extension automatically unless it is already set for this type
1044+
if (!childOfExtension?.types.includes(parentTypeName)) {
10491045
// Adding children fields to types with the `@dontInfer` extension is deprecated
1046+
// Only warn when the parent-child relation has not been explicitly set with
10501047
if (shouldInfer === false) {
10511048
const fieldName = many
10521049
? fieldNames.convenienceChildren(typeName)
@@ -1072,9 +1069,7 @@ const addInferredChildOfExtension = ({ schemaComposer, typeComposer }) => {
10721069
childOfExtension.many = many
10731070
}
10741071
}
1075-
if (!childOfExtension.types.includes(parentTypeName)) {
1076-
childOfExtension.types.push(parentTypeName)
1077-
}
1072+
childOfExtension.types.push(parentTypeName)
10781073
childTypeComposer.setExtension(`childOf`, childOfExtension)
10791074
}
10801075
})

0 commit comments

Comments
 (0)