in src/main/kotlin/com/netflix/dgs/plugin/hints/DgsEntityFetcherInspector.kt [36:72]
override fun visitElement(element: PsiElement) {
val dgsService = element.project.getService(DgsService::class.java)
if(!dgsService.isDgsProject(element.project)) {
return
}
var directives: List<GraphQLDirective> = emptyList()
if (element is GraphQLObjectTypeDefinition) {
directives = element.directives
}
if (element is GraphQLObjectTypeExtensionDefinition){
directives = element.directives
}
val keyDirective = directives.find { (it.nameIdentifier as GraphQLIdentifierImpl?)?.name == "key" }
if (keyDirective != null) {
val isNotResolvable = keyDirective.arguments?.argumentList?.any { it.name == "resolvable" && it.value?.text.equals("false") } ?: false
// if the key directive has a resolvable argument, we don't need to check for the entity fetcher
if(isNotResolvable) {
return
}
// look up the corresponding entity fetcher in the type registry
val entityFetcher = dgsService.dgsComponentIndex.entityFetchers.find { it.schemaPsi == element }
if (entityFetcher == null) {
val message = MyBundle.getMessage(
"dgs.inspection.missing.entityfetcher.annotation"
)
holder.registerProblem(
(directives[0] as GraphQLDirectiveImpl),
message,
ProblemHighlightType.WARNING
)
}
}
}