Repository: apollographql/apollo-kotlin
Pull request #5907 (2024-05-20 13:58:38)

[IJ Plugin] Remove GraphQL IJ plugin issue workaround
The workaround for https://github.com/JetBrains/js-graphql-intellij-plugin/issues/665 is no longer needed since it has been fixed

netlify[bot]: ### <span aria-hidden="true">👷</span> Deploy Preview for *apollo-android-docs* processing.


|  Name | Link |
|:-:|------------------------|
|<span aria-hidden="true">🔨</span> Latest commit | 9bcf57d22543b3da6a02a8b5ab5dc56e9c4345ae |
|<span aria-hidden="true">🔍</span> Latest deploy log | https://app.netlify.com/sites/apollo-android-docs/deploys/664b57108ba96400099373a0 |

Patch:
diff --git a/gradle/libraries.toml b/gradle/libraries.toml
index be2f32c019..717a8c9503 100644
--- a/gradle/libraries.toml
+++ b/gradle/libraries.toml
@@ -25,13 +25,13 @@ javaPoet = "1.13.0"
 jetbrains-annotations = "24.0.1"
 junit = "4.13.2"
 kotlin-plugin-min = "1.9.0"
-kotlin-plugin = "2.0.0-RC3"
-kotlin-plugin-max = "2.0.0-RC3"
-kotlin-stdlib = "2.0.0-RC3"
+kotlin-plugin = "2.0.0"
+kotlin-plugin-max = "2.0.0"
+kotlin-stdlib = "2.0.0"
 kotlinx-coroutines = "1.8.0"
 kotlinx-datetime = "0.5.0"
 kotlinx-serialization-runtime = "1.6.2"
-ksp = "2.0.0-RC3-1.0.20"
+ksp = "2.0.0-1.0.21"
 ktor = "2.3.7"
 moshix = "0.14.1"
 node-fetch = "2.6.7"
diff --git a/intellij-plugin/src/main/kotlin/com/apollographql/ijplugin/graphql/BuiltInRedefinitionErrorFilter.kt b/intellij-plugin/src/main/kotlin/com/apollographql/ijplugin/graphql/BuiltInRedefinitionErrorFilter.kt
deleted file mode 100644
index b424ac1ca3..0000000000
--- a/intellij-plugin/src/main/kotlin/com/apollographql/ijplugin/graphql/BuiltInRedefinitionErrorFilter.kt
+++ /dev/null
@@ -1,50 +0,0 @@
-package com.apollographql.ijplugin.graphql
-
-import com.intellij.lang.jsgraphql.ide.validation.GraphQLErrorFilter
-import com.intellij.lang.jsgraphql.types.GraphQLError
-import com.intellij.lang.jsgraphql.types.language.DirectiveDefinition
-import com.intellij.lang.jsgraphql.types.language.EnumTypeDefinition
-import com.intellij.lang.jsgraphql.types.language.ObjectTypeDefinition
-import com.intellij.lang.jsgraphql.types.language.ScalarTypeDefinition
-import com.intellij.lang.jsgraphql.types.schema.idl.errors.DirectiveRedefinitionError
-import com.intellij.lang.jsgraphql.types.schema.idl.errors.TypeRedefinitionError
-import com.intellij.openapi.project.Project
-import com.intellij.psi.PsiElement
-
-/**
- * Suppress redefinition errors for built-in GraphQL types/directives.
- *
- * TODO: remove this once https://github.com/JetBrains/js-graphql-intellij-plugin/issues/665 is fixed
- */
-class BuiltInRedefinitionErrorFilter : GraphQLErrorFilter {
-  private val builtInScalarTypes = listOf("Int", "Float", "String", "Boolean", "ID")
-  private val builtInDirectives = listOf("skip", "include", "deprecated", "defer", "specifiedBy")
-
-  override fun isGraphQLErrorSuppressed(project: Project, error: GraphQLError, element: PsiElement?): Boolean {
-    return when (error) {
-      is TypeRedefinitionError -> {
-        when (val node = error.node) {
-          is ScalarTypeDefinition -> {
-            node.name in builtInScalarTypes
-          }
-
-          is ObjectTypeDefinition -> {
-            node.name.startsWith("__")
-          }
-
-          is EnumTypeDefinition -> {
-            node.name.startsWith("__")
-          }
-
-          else -> false
-        }
-      }
-
-      is DirectiveRedefinitionError -> {
-        (error.node as DirectiveDefinition).name in builtInDirectives
-      }
-
-      else -> false
-    }
-  }
-}
diff --git a/intellij-plugin/src/main/resources/META-INF/plugin.xml b/intellij-plugin/src/main/resources/META-INF/plugin.xml
index 81becd4034..bbe81ce64e 100644
--- a/intellij-plugin/src/main/resources/META-INF/plugin.xml
+++ b/intellij-plugin/src/main/resources/META-INF/plugin.xml
@@ -243,10 +243,6 @@
   <extensions defaultExtensionNs="com.intellij.lang.jsgraphql">
     <!-- Contribute configuration to the GraphQL plugin -->
     <configContributor implementation="com.apollographql.ijplugin.graphql.ApolloGraphQLConfigContributor" />
-
-    <!-- Suppress redefinition errors for built-in GraphQL types/directives. -->
-    <!-- TODO: remove this once https://github.com/JetBrains/js-graphql-intellij-plugin/issues/665 is fixed -->
-    <errorFilter implementation="com.apollographql.ijplugin.graphql.BuiltInRedefinitionErrorFilter" />
   </extensions>
 
   <applicationListeners>
diff --git a/libraries/apollo-ast/src/commonMain/kotlin/com/apollographql/apollo3/ast/gqldocument.kt b/libraries/apollo-ast/src/commonMain/kotlin/com/apollographql/apollo3/ast/gqldocument.kt
index faf0e572f8..b22130999b 100644
--- a/libraries/apollo-ast/src/commonMain/kotlin/com/apollographql/apollo3/ast/gqldocument.kt
+++ b/libraries/apollo-ast/src/commonMain/kotlin/com/apollographql/apollo3/ast/gqldocument.kt
@@ -196,12 +196,7 @@ fun GQLDocument.toSDL(indent: String = "  "): String {
 
       definition is GQLTypeDefinition && definition.name in GQLTypeDefinition.builtInTypes ||
           definition is GQLDirectiveDefinition && definition.name in GQLDirectiveDefinition.builtInDirectives -> {
-        // Tools like the GraphQL intelliJ plugin expect a "server" schema, without builtin types
-        // Suppress the errors for now
-        buffer.writeUtf8("# See https://github.com/JetBrains/js-graphql-intellij-plugin/issues/665\n")
-        buffer.writeUtf8("# noinspection GraphQLTypeRedefinition\n")
         writer.write(definition)
-
       }
 
       else -> {


Test patch:
diff --git a/libraries/apollo-ast/test-fixtures/sdl/introspection.expected b/libraries/apollo-ast/test-fixtures/sdl/introspection.expected
index 1f18fcb7c1..5bcccc75c5 100644
--- a/libraries/apollo-ast/test-fixtures/sdl/introspection.expected
+++ b/libraries/apollo-ast/test-fixtures/sdl/introspection.expected
@@ -2,29 +2,21 @@ type Query {
     foo: Int
 }
 
-# See https://github.com/JetBrains/js-graphql-intellij-plugin/issues/665
-# noinspection GraphQLTypeRedefinition
 """
 Directs the executor to include this field or fragment only when the `if` argument is true
 """
 directive @include ("Included when true." if: Boolean!) on FIELD|FRAGMENT_SPREAD|INLINE_FRAGMENT
 
-# See https://github.com/JetBrains/js-graphql-intellij-plugin/issues/665
-# noinspection GraphQLTypeRedefinition
 """
 Directs the executor to skip this field or fragment when the `if` argument is true.
 """
 directive @skip ("Skipped when true." if: Boolean!) on FIELD|FRAGMENT_SPREAD|INLINE_FRAGMENT
 
-# See https://github.com/JetBrains/js-graphql-intellij-plugin/issues/665
-# noinspection GraphQLTypeRedefinition
 """
 Marks the field, argument, input field or enum value as deprecated
 """
 directive @deprecated ("The reason for the deprecation" reason: String = "No longer supported") on FIELD_DEFINITION|ARGUMENT_DEFINITION|ENUM_VALUE|INPUT_FIELD_DEFINITION
 
-# See https://github.com/JetBrains/js-graphql-intellij-plugin/issues/665
-# noinspection GraphQLTypeRedefinition
 """
 Exposes a URL that specifies the behaviour of this scalar.
 """
diff --git a/libraries/apollo-ast/test-fixtures/sdl/type_redefinitions.expected b/libraries/apollo-ast/test-fixtures/sdl/type_redefinitions.expected
index 955a1c5b96..aaa7e6dcc5 100644
--- a/libraries/apollo-ast/test-fixtures/sdl/type_redefinitions.expected
+++ b/libraries/apollo-ast/test-fixtures/sdl/type_redefinitions.expected
@@ -2,8 +2,6 @@ type Query {
     foo: Int
 }
 
-# See https://github.com/JetBrains/js-graphql-intellij-plugin/issues/665
-# noinspection GraphQLTypeRedefinition
 type __Schema {
     description: String
 
@@ -18,8 +16,6 @@ type __Schema {
     directives: [__Directive!]!
 }
 
-# See https://github.com/JetBrains/js-graphql-intellij-plugin/issues/665
-# noinspection GraphQLTypeRedefinition
 type __Type {
     kind: __TypeKind!
 
@@ -42,8 +38,6 @@ type __Type {
     specifiedByURL: String
 }
 
-# See https://github.com/JetBrains/js-graphql-intellij-plugin/issues/665
-# noinspection GraphQLTypeRedefinition
 enum __TypeKind {
     SCALAR
 
@@ -62,8 +56,6 @@ enum __TypeKind {
     NON_NULL
 }
 
-# See https://github.com/JetBrains/js-graphql-intellij-plugin/issues/665
-# noinspection GraphQLTypeRedefinition
 type __Field {
     name: String!
 
@@ -78,8 +70,6 @@ type __Field {
     deprecationReason: String
 }
 
-# See https://github.com/JetBrains/js-graphql-intellij-plugin/issues/665
-# noinspection GraphQLTypeRedefinition
 type __InputValue {
     name: String!
 
@@ -94,8 +84,6 @@ type __InputValue {
     deprecationReason: String
 }
 
-# See https://github.com/JetBrains/js-graphql-intellij-plugin/issues/665
-# noinspection GraphQLTypeRedefinition
 type __EnumValue {
     name: String!
 
@@ -106,8 +94,6 @@ type __EnumValue {
     deprecationReason: String
 }
 
-# See https://github.com/JetBrains/js-graphql-intellij-plugin/issues/665
-# noinspection GraphQLTypeRedefinition
 type __Directive {
     name: String!
 
@@ -120,8 +106,6 @@ type __Directive {
     isRepeatable: Boolean!
 }
 
-# See https://github.com/JetBrains/js-graphql-intellij-plugin/issues/665
-# noinspection GraphQLTypeRedefinition
 enum __DirectiveLocation {
     QUERY
 
@@ -162,20 +146,12 @@ enum __DirectiveLocation {
     INPUT_FIELD_DEFINITION
 }
 
-# See https://github.com/JetBrains/js-graphql-intellij-plugin/issues/665
-# noinspection GraphQLTypeRedefinition
 directive @skip (if: Boolean!) on FIELD|FRAGMENT_SPREAD|INLINE_FRAGMENT
 
-# See https://github.com/JetBrains/js-graphql-intellij-plugin/issues/665
-# noinspection GraphQLTypeRedefinition
 directive @include (if: Boolean!) on FIELD|FRAGMENT_SPREAD|INLINE_FRAGMENT
 
-# See https://github.com/JetBrains/js-graphql-intellij-plugin/issues/665
-# noinspection GraphQLTypeRedefinition
 directive @deprecated (reason: String = "No longer supported") on FIELD_DEFINITION|ARGUMENT_DEFINITION|INPUT_FIELD_DEFINITION|ENUM_VALUE
 
 directive @defer (label: String, if: Boolean! = true) on FRAGMENT_SPREAD|INLINE_FRAGMENT
 
-# See https://github.com/JetBrains/js-graphql-intellij-plugin/issues/665
-# noinspection GraphQLTypeRedefinition
 directive @specifiedBy (url: String!) on SCALAR
diff --git a/libraries/apollo-compiler/src/test/validation/operation/fragment_variables/schema.graphqls b/libraries/apollo-compiler/src/test/validation/operation/fragment_variables/schema.graphqls
index 5640fcad2c..2795efe5be 100644
--- a/libraries/apollo-compiler/src/test/validation/operation/fragment_variables/schema.graphqls
+++ b/libraries/apollo-compiler/src/test/validation/operation/fragment_variables/schema.graphqls
@@ -5828,8 +5828,6 @@ type UserModData {
     email: String
 }
 
-# See https://github.com/JetBrains/js-graphql-intellij-plugin/issues/665
-# noinspection GraphQLTypeRedefinition
 """
 A GraphQL Schema defines the capabilities of a GraphQL server. It exposes all available types and directives on the server, as well as the entry points for query, mutation, and subscription operations.
 """
@@ -5860,8 +5858,6 @@ type __Schema {
     directives: [__Directive!]!
 }
 
-# See https://github.com/JetBrains/js-graphql-intellij-plugin/issues/665
-# noinspection GraphQLTypeRedefinition
 """
 The fundamental unit of any GraphQL Schema is the type. There are many kinds of types in GraphQL as represented by the `__TypeKind` enum.
 
@@ -5887,8 +5883,6 @@ type __Type {
     ofType: __Type
 }
 
-# See https://github.com/JetBrains/js-graphql-intellij-plugin/issues/665
-# noinspection GraphQLTypeRedefinition
 """
 An enum describing what kind of type a given `__Type` is.
 """
@@ -5934,8 +5928,6 @@ enum __TypeKind {
     NON_NULL
 }
 
-# See https://github.com/JetBrains/js-graphql-intellij-plugin/issues/665
-# noinspection GraphQLTypeRedefinition
 """
 Object and Interface types are described by a list of Fields, each of which has a name, potentially a list of arguments, and a return type.
 """
@@ -5953,8 +5945,6 @@ type __Field {
     deprecationReason: String
 }
 
-# See https://github.com/JetBrains/js-graphql-intellij-plugin/issues/665
-# noinspection GraphQLTypeRedefinition
 """
 Arguments provided to Fields or Directives and the input fields of an InputObject are represented as Input Values which describe their type and optionally a default value.
 """
@@ -5971,8 +5961,6 @@ type __InputValue {
     defaultValue: String
 }
 
-# See https://github.com/JetBrains/js-graphql-intellij-plugin/issues/665
-# noinspection GraphQLTypeRedefinition
 """
 One possible value for a given Enum. Enum values are unique values, not a placeholder for a string or numeric value. However an Enum value is returned in a JSON response as a string.
 """
@@ -5986,8 +5974,6 @@ type __EnumValue {
     deprecationReason: String
 }
 
-# See https://github.com/JetBrains/js-graphql-intellij-plugin/issues/665
-# noinspection GraphQLTypeRedefinition
 """
 A Directive provides a way to describe alternate runtime execution and type validation behavior in a GraphQL document.
 
@@ -6009,8 +5995,6 @@ type __Directive {
     onField: Boolean! @deprecated(reason: "Use `locations`.")
 }
 
-# See https://github.com/JetBrains/js-graphql-intellij-plugin/issues/665
-# noinspection GraphQLTypeRedefinition
 """
 A Directive can be adjacent to many parts of the GraphQL language, a __DirectiveLocation describes one such possible adjacencies.
 """
@@ -6106,22 +6090,16 @@ enum __DirectiveLocation {
     INPUT_FIELD_DEFINITION
 }
 
-# See https://github.com/JetBrains/js-graphql-intellij-plugin/issues/665
-# noinspection GraphQLTypeRedefinition
 """
 Directs the executor to include this field or fragment only when the `if` argument is true.
 """
 directive @include ("Included when true." if: Boolean!) on FIELD|FRAGMENT_SPREAD|INLINE_FRAGMENT
 
-# See https://github.com/JetBrains/js-graphql-intellij-plugin/issues/665
-# noinspection GraphQLTypeRedefinition
 """
 Directs the executor to skip this field or fragment when the `if` argument is true.
 """
 directive @skip ("Skipped when true." if: Boolean!) on FIELD|FRAGMENT_SPREAD|INLINE_FRAGMENT
 
-# See https://github.com/JetBrains/js-graphql-intellij-plugin/issues/665
-# noinspection GraphQLTypeRedefinition
 """
 Marks an element of a GraphQL schema as no longer supported.
 """