9
9
} from "./helpers"
10
10
11
11
const unionType = typeBuilderApi => {
12
- const { typeDefs , schema, type, pluginOptions } = typeBuilderApi
12
+ const { schema, type, pluginOptions } = typeBuilderApi
13
13
14
14
const types = type . possibleTypes
15
15
. filter (
@@ -22,7 +22,7 @@ const unionType = typeBuilderApi => {
22
22
. map ( possibleType => buildTypeName ( possibleType . name ) )
23
23
24
24
if ( ! types || ! types . length ) {
25
- return
25
+ return false
26
26
}
27
27
28
28
let unionType = {
@@ -47,13 +47,12 @@ const unionType = typeBuilderApi => {
47
47
// @todo add this as a plugin option
48
48
unionType = filterTypeDefinition ( unionType , typeBuilderApi , `UNION` )
49
49
50
- typeDefs . push ( schema . buildUnionType ( unionType ) )
50
+ return schema . buildUnionType ( unionType )
51
51
}
52
52
53
53
const interfaceType = typeBuilderApi => {
54
54
const {
55
55
type,
56
- typeDefs,
57
56
schema,
58
57
gatsbyNodeTypes,
59
58
fieldAliases,
@@ -111,7 +110,7 @@ const interfaceType = typeBuilderApi => {
111
110
// @todo add this as a plugin option
112
111
typeDef = filterTypeDefinition ( typeDef , typeBuilderApi , `INTERFACE` )
113
112
114
- typeDefs . push ( schema . buildInterfaceType ( typeDef ) )
113
+ return schema . buildInterfaceType ( typeDef )
115
114
}
116
115
117
116
const objectType = typeBuilderApi => {
@@ -120,7 +119,6 @@ const objectType = typeBuilderApi => {
120
119
gatsbyNodeTypes,
121
120
fieldAliases,
122
121
fieldBlacklist,
123
- typeDefs,
124
122
schema,
125
123
isAGatsbyNode,
126
124
} = typeBuilderApi
@@ -138,7 +136,7 @@ const objectType = typeBuilderApi => {
138
136
// TypeError: Cannot convert undefined or null to object at Function.keys (<anonymous>)
139
137
// Also cause wordpress blog site build failure in createSchemaCustomization step
140
138
if ( ! transformedFields || ! Object . keys ( transformedFields ) . length ) {
141
- return
139
+ return false
142
140
}
143
141
144
142
let objectType = {
@@ -180,21 +178,18 @@ const objectType = typeBuilderApi => {
180
178
// @todo add this as a plugin option
181
179
objectType = filterTypeDefinition ( objectType , typeBuilderApi , `OBJECT` )
182
180
183
- typeDefs . push ( schema . buildObjectType ( objectType ) )
181
+ return schema . buildObjectType ( objectType )
184
182
}
185
183
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
+ } )
199
194
200
195
export default { unionType, interfaceType, objectType, enumType }
0 commit comments