override fun isGraphQLErrorSuppressed()

in src/main/com/intellij/lang/jsgraphql/ide/validation/GraphQLGeneralErrorFilter.kt [23:58]


  override fun isGraphQLErrorSuppressed(
    project: Project,
    error: GraphQLError,
    element: PsiElement?,
  ): Boolean {
    if (error.message.contains(GraphQLInjectionUtils.GRAPHQL_EXTERNAL_FRAGMENT)) {
      return true
    }

    val isInInjectedLanguageBoundary = intersectsInjectedFragments(element)
    if (isInInjectedLanguageBoundary) {
      if ((error is ValidationError && error.validationErrorType == ValidationErrorType.WrongType) ||
          error is DirectiveIllegalArgumentTypeError) {
        return true
      }
    }

    val namedNode = error.node as? NamedNode<*>

    if (error is QueryOperationMissingError) {
      return true
    }

    if (isExpectedInLibraryDefinitions(error, namedNode)) {
      val roots = GraphQLLibraryManager.getInstance(project).getLibraryRoots().map { it.path }.toSet()
      return namedNode?.sourceLocation?.sourceName in roots
    }

    if (error is ValidationError && error.validationErrorType == ValidationErrorType.MisplacedDirective) {
      // graphql-java KnownDirectives rule only recognizes executable directive locations, so ignore
      // the error if we're inside a type definition
      return PsiTreeUtil.getParentOfType(element, GraphQLTypeSystemDefinition::class.java) != null
    }

    return false
  }