99} from "./helpers"
1010
1111const unionType = typeBuilderApi => {
12- const { typeDefs , schema, type, pluginOptions } = typeBuilderApi
12+ const { schema, type, pluginOptions } = typeBuilderApi
1313
1414 const types = type . possibleTypes
1515 . filter (
@@ -22,7 +22,7 @@ const unionType = typeBuilderApi => {
2222 . map ( possibleType => buildTypeName ( possibleType . name ) )
2323
2424 if ( ! types || ! types . length ) {
25- return
25+ return false
2626 }
2727
2828 let unionType = {
@@ -47,13 +47,12 @@ const unionType = typeBuilderApi => {
4747 // @todo add this as a plugin option
4848 unionType = filterTypeDefinition ( unionType , typeBuilderApi , `UNION` )
4949
50- typeDefs . push ( schema . buildUnionType ( unionType ) )
50+ return schema . buildUnionType ( unionType )
5151}
5252
5353const interfaceType = typeBuilderApi => {
5454 const {
5555 type,
56- typeDefs,
5756 schema,
5857 gatsbyNodeTypes,
5958 fieldAliases,
@@ -111,7 +110,7 @@ const interfaceType = typeBuilderApi => {
111110 // @todo add this as a plugin option
112111 typeDef = filterTypeDefinition ( typeDef , typeBuilderApi , `INTERFACE` )
113112
114- typeDefs . push ( schema . buildInterfaceType ( typeDef ) )
113+ return schema . buildInterfaceType ( typeDef )
115114}
116115
117116const objectType = typeBuilderApi => {
@@ -120,7 +119,6 @@ const objectType = typeBuilderApi => {
120119 gatsbyNodeTypes,
121120 fieldAliases,
122121 fieldBlacklist,
123- typeDefs,
124122 schema,
125123 isAGatsbyNode,
126124 } = typeBuilderApi
@@ -138,7 +136,7 @@ const objectType = typeBuilderApi => {
138136 // TypeError: Cannot convert undefined or null to object at Function.keys (<anonymous>)
139137 // Also cause wordpress blog site build failure in createSchemaCustomization step
140138 if ( ! transformedFields || ! Object . keys ( transformedFields ) . length ) {
141- return
139+ return false
142140 }
143141
144142 let objectType = {
@@ -180,21 +178,18 @@ const objectType = typeBuilderApi => {
180178 // @todo add this as a plugin option
181179 objectType = filterTypeDefinition ( objectType , typeBuilderApi , `OBJECT` )
182180
183- typeDefs . push ( schema . buildObjectType ( objectType ) )
181+ return schema . buildObjectType ( objectType )
184182}
185183
186- const enumType = ( { typeDefs, schema, type } ) => {
187- typeDefs . push (
188- schema . buildEnumType ( {
189- name : buildTypeName ( type . name ) ,
190- values : type . enumValues . reduce ( ( accumulator , { name } ) => {
191- accumulator [ name ] = { name }
192-
193- return accumulator
194- } , { } ) ,
195- description : type . description ,
196- } )
197- )
198- }
184+ const enumType = ( { schema, type } ) =>
185+ schema . buildEnumType ( {
186+ name : buildTypeName ( type . name ) ,
187+ values : type . enumValues . reduce ( ( accumulator , { name } ) => {
188+ accumulator [ name ] = { name }
189+
190+ return accumulator
191+ } , { } ) ,
192+ description : type . description ,
193+ } )
199194
200195export default { unionType, interfaceType, objectType, enumType }
0 commit comments