Skip to content

Commit

Permalink
better test
Browse files Browse the repository at this point in the history
  • Loading branch information
AlecAivazis committed Mar 6, 2024
1 parent 1000510 commit 97d4f0e
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions packages/houdini/src/codegen/validators/componentFields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,25 @@ export default async function componentFields(config: Config, docs: Document[]):
const propValue =
propArg!.value?.kind === 'StringValue' ? propArg.value.value : undefined

// look up if we've already seen this component field before
const existingField = fieldValue && config.componentFields[parent]?.[fieldValue]

// look up the type of the parent
const parentType = config.schema.getType(parent)
if (
parentType &&
fieldValue &&
graphql.isObjectType(parentType) &&
parentType.getFields()[fieldValue]
((graphql.isObjectType(parentType) && parentType.getFields()[fieldValue]) ||
(existingField && existingField.filepath !== filepath))
) {
errors.push({
message: `Duplicate component field definition for ${parent}.${fieldValue}`,
filepath,
description: existingField
? 'The conflicting component field was defined in ' +
existingField.filepath
: '',
})
return
}

// if the type is abstract there's a problem
Expand Down

0 comments on commit 97d4f0e

Please sign in to comment.