1- import { Kind } from 'graphql' ;
21import {
32 augmentNodeQueryAPI ,
43 augmentNodeQueryArgumentTypes ,
@@ -37,7 +36,9 @@ import {
3736 isNodeType ,
3837 isRelationshipType ,
3938 isQueryTypeDefinition ,
40- isUnionTypeDefinition
39+ isUnionTypeDefinition ,
40+ isObjectTypeExtensionDefinition ,
41+ isInterfaceTypeExtensionDefinition
4142} from '../../types/types' ;
4243import { getPrimaryKey } from '../../../utils' ;
4344
@@ -69,9 +70,12 @@ export const augmentNodeType = ({
6970 if ( typeExtensions . length ) {
7071 typeExtensionDefinitionMap [ typeName ] = typeExtensions . map ( extension => {
7172 let isIgnoredType = false ;
72- const isObjectExtension = extension . kind === Kind . OBJECT_TYPE_EXTENSION ;
73- const isInterfaceExtension =
74- extension . kind === Kind . INTERFACE_TYPE_EXTENSION ;
73+ const isObjectExtension = isObjectTypeExtensionDefinition ( {
74+ definition : extension
75+ } ) ;
76+ const isInterfaceExtension = isInterfaceTypeExtensionDefinition ( {
77+ definition : extension
78+ } ) ;
7579 if ( isObjectExtension || isInterfaceExtension ) {
7680 [
7781 extensionNodeInputTypeMap ,
@@ -82,6 +86,7 @@ export const augmentNodeType = ({
8286 typeName,
8387 definition : extension ,
8488 typeDefinitionMap,
89+ typeExtensionDefinitionMap,
8590 generatedTypeMap,
8691 operationTypeMap,
8792 nodeInputTypeMap : extensionNodeInputTypeMap ,
@@ -110,6 +115,7 @@ export const augmentNodeType = ({
110115 isUnionType,
111116 isQueryType,
112117 typeDefinitionMap,
118+ typeExtensionDefinitionMap,
113119 generatedTypeMap,
114120 operationTypeMap,
115121 nodeInputTypeMap,
@@ -178,6 +184,7 @@ export const augmentNodeTypeFields = ({
178184 isUnionType,
179185 isQueryType,
180186 typeDefinitionMap,
187+ typeExtensionDefinitionMap,
181188 generatedTypeMap,
182189 operationTypeMap,
183190 nodeInputTypeMap = { } ,
@@ -206,10 +213,6 @@ export const augmentNodeTypeFields = ({
206213 } ;
207214 }
208215 }
209- if ( fields === undefined ) {
210- console . log ( '\ndefinition: ' , definition ) ;
211- console . log ( 'fields: ' , fields ) ;
212- }
213216 propertyOutputFields = fields . reduce ( ( outputFields , field ) => {
214217 let fieldType = field . type ;
215218 let fieldArguments = field . arguments ;
@@ -264,13 +267,14 @@ export const augmentNodeTypeFields = ({
264267 outputType,
265268 nodeInputTypeMap,
266269 typeDefinitionMap,
270+ typeExtensionDefinitionMap,
267271 generatedTypeMap,
268272 operationTypeMap,
269- config,
270273 relationshipDirective,
271274 outputTypeWrappers,
272275 isObjectExtension,
273- isInterfaceExtension
276+ isInterfaceExtension,
277+ config
274278 } ) ;
275279 } else if ( isRelationshipType ( { definition : outputDefinition } ) ) {
276280 [
@@ -292,8 +296,11 @@ export const augmentNodeTypeFields = ({
292296 outputDefinition,
293297 nodeInputTypeMap,
294298 typeDefinitionMap,
299+ typeExtensionDefinitionMap,
295300 generatedTypeMap,
296301 operationTypeMap,
302+ isObjectExtension,
303+ isInterfaceExtension,
297304 config
298305 } ) ;
299306 }
@@ -305,21 +312,22 @@ export const augmentNodeTypeFields = ({
305312 } ) ;
306313 return outputFields ;
307314 } , [ ] ) ;
308-
309- if ( ! isQueryType && extensionNodeInputTypeMap ) {
310- if ( extensionNodeInputTypeMap [ FilteringArgument . FILTER ] ) {
311- const extendedFilteringFields =
312- extensionNodeInputTypeMap [ FilteringArgument . FILTER ] . fields ;
313- nodeInputTypeMap [ FilteringArgument . FILTER ] . fields . push (
314- ...extendedFilteringFields
315- ) ;
316- }
317- if ( extensionNodeInputTypeMap [ OrderingArgument . ORDER_BY ] ) {
318- const extendedOrderingValues =
319- extensionNodeInputTypeMap [ OrderingArgument . ORDER_BY ] . values ;
320- nodeInputTypeMap [ OrderingArgument . ORDER_BY ] . values . push (
321- ...extendedOrderingValues
322- ) ;
315+ if ( ! isObjectExtension && ! isInterfaceExtension ) {
316+ if ( ! isQueryType && extensionNodeInputTypeMap ) {
317+ if ( extensionNodeInputTypeMap [ FilteringArgument . FILTER ] ) {
318+ const extendedFilteringFields =
319+ extensionNodeInputTypeMap [ FilteringArgument . FILTER ] . fields ;
320+ nodeInputTypeMap [ FilteringArgument . FILTER ] . fields . push (
321+ ...extendedFilteringFields
322+ ) ;
323+ }
324+ if ( extensionNodeInputTypeMap [ OrderingArgument . ORDER_BY ] ) {
325+ const extendedOrderingValues =
326+ extensionNodeInputTypeMap [ OrderingArgument . ORDER_BY ] . values ;
327+ nodeInputTypeMap [ OrderingArgument . ORDER_BY ] . values . push (
328+ ...extendedOrderingValues
329+ ) ;
330+ }
323331 }
324332 }
325333 } else {
@@ -347,13 +355,12 @@ const augmentNodeTypeField = ({
347355 outputType,
348356 nodeInputTypeMap,
349357 typeDefinitionMap,
358+ typeExtensionDefinitionMap,
350359 generatedTypeMap,
351360 operationTypeMap,
352361 config,
353362 relationshipDirective,
354- outputTypeWrappers,
355- isObjectExtension,
356- isInterfaceExtension
363+ outputTypeWrappers
357364} ) => {
358365 const isUnionType = isUnionTypeDefinition ( { definition : outputDefinition } ) ;
359366 fieldArguments = augmentNodeTypeFieldArguments ( {
@@ -365,19 +372,11 @@ const augmentNodeTypeField = ({
365372 typeDefinitionMap,
366373 config
367374 } ) ;
368- if ( ! isUnionType && ! isObjectExtension && ! isInterfaceExtension ) {
375+ if ( ! isUnionType ) {
369376 if (
370377 relationshipDirective &&
371378 ! isQueryTypeDefinition ( { definition, operationTypeMap } )
372379 ) {
373- nodeInputTypeMap = augmentNodeQueryArgumentTypes ( {
374- typeName,
375- fieldName,
376- outputType,
377- outputTypeWrappers,
378- nodeInputTypeMap,
379- config
380- } ) ;
381380 const relationshipName = getRelationName ( relationshipDirective ) ;
382381 const relationshipDirection = getRelationDirection ( relationshipDirective ) ;
383382 // Assume direction OUT
@@ -388,6 +387,14 @@ const augmentNodeTypeField = ({
388387 fromType = outputType ;
389388 toType = temp ;
390389 }
390+ nodeInputTypeMap = augmentNodeQueryArgumentTypes ( {
391+ typeName,
392+ fieldName,
393+ outputType,
394+ outputTypeWrappers,
395+ nodeInputTypeMap,
396+ config
397+ } ) ;
391398 [
392399 typeDefinitionMap ,
393400 generatedTypeMap ,
@@ -400,6 +407,7 @@ const augmentNodeTypeField = ({
400407 toType,
401408 relationshipName,
402409 typeDefinitionMap,
410+ typeExtensionDefinitionMap,
403411 generatedTypeMap,
404412 operationTypeMap,
405413 config
0 commit comments