@@ -31,7 +31,6 @@ import { DocumentValidationError } from "../utils/document-validation-error";
3131
3232export function verifyRelationshipArgumentValue (
3333 objectTypeToRelationshipsPerRelationshipTypeMap : Map < string , Map < string , [ string , string , string ] [ ] > > ,
34- interfaceToImplementationsMap : Map < string , Set < string > > ,
3534 extra ?: {
3635 enums : EnumTypeDefinitionNode [ ] ;
3736 interfaces : InterfaceTypeDefinitionNode [ ] ;
@@ -51,8 +50,8 @@ export function verifyRelationshipArgumentValue(
5150 // delegate
5251 return ;
5352 }
54- if ( ! parentDef ) {
55- console . error ( "No parent definition" ) ;
53+ if ( ! parentDef || parentDef . kind === Kind . INTERFACE_TYPE_DEFINITION ) {
54+ // @relationship can only be present on fields of Object Types
5655 return ;
5756 }
5857 const typeArg = directiveNode . arguments ?. find ( ( a ) => a . name . value === "type" ) ;
@@ -72,8 +71,7 @@ export function verifyRelationshipArgumentValue(
7271 parentDef ,
7372 currentRelationship ,
7473 typeValue ,
75- objectTypeToRelationshipsPerRelationshipTypeMap ,
76- interfaceToImplementationsMap
74+ objectTypeToRelationshipsPerRelationshipTypeMap
7775 ) ;
7876 }
7977
@@ -149,44 +147,17 @@ function checkRelationshipFieldsForDuplicates(
149147}
150148
151149function verifyRelationshipFields (
152- parentDef : ObjectTypeDefinitionNode | InterfaceTypeDefinitionNode ,
150+ parentDef : ObjectTypeDefinitionNode ,
153151 currentRelationship : [ string , string , string ] ,
154152 typeValue : any ,
155- objectTypeToRelationshipsPerRelationshipTypeMap : Map < string , Map < string , [ string , string , string ] [ ] > > ,
156- interfaceToImplementationsMap : Map < string , Set < string > >
153+ objectTypeToRelationshipsPerRelationshipTypeMap : Map < string , Map < string , [ string , string , string ] [ ] > >
157154) {
158155 const relationshipFieldsForCurrentType = objectTypeToRelationshipsPerRelationshipTypeMap . get ( parentDef . name . value ) ;
159156 checkRelationshipFieldsForDuplicates ( relationshipFieldsForCurrentType , currentRelationship , typeValue ) ;
160157 objectTypeToRelationshipsPerRelationshipTypeMap . set (
161158 parentDef . name . value ,
162159 getUpdatedRelationshipFieldsForCurrentType ( relationshipFieldsForCurrentType , currentRelationship , typeValue )
163160 ) ;
164-
165- if ( parentDef . kind === Kind . INTERFACE_TYPE_DEFINITION ) {
166- const dependents = interfaceToImplementationsMap . get ( parentDef . name . value ) ;
167- dependents ?. forEach ( ( dependentTypeName ) => {
168- const relationshipFieldsForDependentType =
169- objectTypeToRelationshipsPerRelationshipTypeMap . get ( dependentTypeName ) ;
170- checkRelationshipFieldsForDuplicates ( relationshipFieldsForDependentType , currentRelationship , typeValue ) ;
171- } ) ;
172- }
173-
174- if ( parentDef . kind === Kind . OBJECT_TYPE_DEFINITION ) {
175- parentDef . interfaces ?. forEach ( ( i ) => {
176- const relationshipFieldsForImplementedInterface = objectTypeToRelationshipsPerRelationshipTypeMap . get (
177- i . name . value
178- ) ;
179- checkRelationshipFieldsForDuplicates (
180- relationshipFieldsForImplementedInterface ,
181- currentRelationship ,
182- typeValue
183- ) ;
184-
185- const implementations = interfaceToImplementationsMap . get ( i . name . value ) || new Set < string > ( ) ;
186- implementations . add ( parentDef . name . value ) ;
187- interfaceToImplementationsMap . set ( i . name . value , implementations ) ;
188- } ) ;
189- }
190161}
191162
192163export function verifyRelationshipFieldType ( {
0 commit comments