JetBrains / js-graphql-intellij-plugin

GraphQL language support for WebStorm, IntelliJ IDEA and other IDEs based on the IntelliJ Platform.
https://jimkyndemeyer.github.io/js-graphql-intellij-plugin/
MIT License
879 stars 97 forks source link

Exception: SchemaProblem{errors=['onOperation' tried to use an undeclared directive 'deprecated', 'onFragment' tried to use an undeclared directive 'deprecated', 'onField' tried to use an undeclared directive 'deprecated']} #548

Closed ihormaslov closed 2 years ago

ihormaslov commented 2 years ago

Description

Stacktrace

Please paste the full stacktrace from the IDEA error popup.

SchemaProblem{errors=['onOperation' tried to use an undeclared directive 'deprecated', 'onFragment' tried to use an undeclared directive 'deprecated', 'onField' tried to use an undeclared directive 'deprecated']}
    at com.intellij.lang.jsgraphql.ide.introspection.GraphQLIntrospectionService.printIntrospectionAsGraphQL(GraphQLIntrospectionService.java:348)
    at com.intellij.lang.jsgraphql.ide.introspection.GraphQLIntrospectionService.printIntrospectionAsGraphQL(GraphQLIntrospectionService.java:305)
    at com.intellij.lang.jsgraphql.ide.introspection.GraphQLIntrospectionFilesManager.lambda$getOrCreateIntrospectionSDL$0(GraphQLIntrospectionFilesManager.java:32)
    at com.intellij.psi.util.CachedValuesManager$1.compute(CachedValuesManager.java:158)
    at com.intellij.psi.impl.PsiCachedValueImpl.doCompute(PsiCachedValueImpl.java:39)
    at com.intellij.util.CachedValueBase.lambda$getValueWithLock$3(CachedValueBase.java:227)
    at com.intellij.util.CachedValueBase.computeData(CachedValueBase.java:42)
    at com.intellij.util.CachedValueBase.lambda$getValueWithLock$4(CachedValueBase.java:227)
    at com.intellij.openapi.util.RecursionManager$1.computePreventingRecursion(RecursionManager.java:114)
    at com.intellij.openapi.util.RecursionGuard.doPreventingRecursion(RecursionGuard.java:44)
    at com.intellij.openapi.util.RecursionManager.doPreventingRecursion(RecursionManager.java:68)
    at com.intellij.util.CachedValueBase.getValueWithLock(CachedValueBase.java:228)
    at com.intellij.psi.impl.PsiCachedValueImpl.getValue(PsiCachedValueImpl.java:28)
    at com.intellij.util.CachedValuesManagerImpl.getCachedValue(CachedValuesManagerImpl.java:72)
    at com.intellij.psi.util.CachedValuesManager.getCachedValue(CachedValuesManager.java:155)
    at com.intellij.lang.jsgraphql.ide.introspection.GraphQLIntrospectionFilesManager.getOrCreateIntrospectionSDL(GraphQLIntrospectionFilesManager.java:27)
    at com.intellij.lang.jsgraphql.ide.search.GraphQLPsiSearchHelper$4.visitElement(GraphQLPsiSearchHelper.java:271)
    at com.intellij.psi.impl.PsiElementBase.accept(PsiElementBase.java:273)
    at com.intellij.json.psi.impl.JsonLiteralImpl.accept(JsonLiteralImpl.java:26)
    at com.intellij.json.psi.impl.JsonStringLiteralImpl.accept(JsonStringLiteralImpl.java:28)
    at com.intellij.psi.impl.PsiElementBase.acceptChildren(PsiElementBase.java:69)
    at com.intellij.psi.PsiRecursiveElementVisitor.visitElement(PsiRecursiveElementVisitor.java:41)
    at com.intellij.lang.jsgraphql.ide.search.GraphQLPsiSearchHelper$4.visitElement(GraphQLPsiSearchHelper.java:282)
    at com.intellij.psi.impl.PsiElementBase.accept(PsiElementBase.java:273)
    at com.intellij.json.psi.impl.JsonPropertyImpl.accept(JsonPropertyImpl.java:27)
    at com.intellij.psi.impl.PsiElementBase.acceptChildren(PsiElementBase.java:69)
    at com.intellij.psi.PsiRecursiveElementVisitor.visitElement(PsiRecursiveElementVisitor.java:41)
    at com.intellij.lang.jsgraphql.ide.search.GraphQLPsiSearchHelper$4.visitElement(GraphQLPsiSearchHelper.java:282)
    at com.intellij.psi.impl.PsiElementBase.accept(PsiElementBase.java:273)
    at com.intellij.json.psi.impl.JsonValueImpl.accept(JsonValueImpl.java:26)
    at com.intellij.json.psi.impl.JsonContainerImpl.accept(JsonContainerImpl.java:27)
    at com.intellij.json.psi.impl.JsonObjectImpl.accept(JsonObjectImpl.java:27)
    at com.intellij.psi.impl.source.tree.SharedImplUtil.acceptChildren(SharedImplUtil.java:185)
    at com.intellij.psi.impl.source.PsiFileImpl.acceptChildren(PsiFileImpl.java:754)
    at com.intellij.psi.PsiRecursiveElementVisitor.visitElement(PsiRecursiveElementVisitor.java:41)
    at com.intellij.lang.jsgraphql.ide.search.GraphQLPsiSearchHelper$4.visitElement(GraphQLPsiSearchHelper.java:282)
    at com.intellij.psi.PsiElementVisitor.visitFile(PsiElementVisitor.java:35)
    at com.intellij.psi.PsiRecursiveElementVisitor.visitFile(PsiRecursiveElementVisitor.java:60)
    at com.intellij.extapi.psi.PsiFileBase.accept(PsiFileBase.java:60)
    at com.intellij.lang.jsgraphql.ide.search.GraphQLPsiSearchHelper.lambda$processElementsWithWordUsingIdentifierIndex$3(GraphQLPsiSearchHelper.java:286)
    at com.intellij.util.indexing.FileBasedIndexEx.processVirtualFiles(FileBasedIndexEx.java:522)
    at com.intellij.util.indexing.FileBasedIndexEx.processFilesContainingAllKeys(FileBasedIndexEx.java:362)
    at com.intellij.util.indexing.FileBasedIndexEx.getFilesWithKey(FileBasedIndexEx.java:433)
    at com.intellij.lang.jsgraphql.ide.search.GraphQLPsiSearchHelper.processElementsWithWordUsingIdentifierIndex(GraphQLPsiSearchHelper.java:249)
    at com.intellij.lang.jsgraphql.ide.search.GraphQLPsiSearchHelper.processElementsWithWord(GraphQLPsiSearchHelper.java:301)
    at com.intellij.lang.jsgraphql.ide.resolve.GraphQLReferenceService.resolveUsingIndex(GraphQLReferenceService.java:443)
    at com.intellij.lang.jsgraphql.ide.resolve.GraphQLReferenceService.resolveTypeName(GraphQLReferenceService.java:330)
    at com.intellij.lang.jsgraphql.ide.resolve.GraphQLReferenceService.innerResolveReference(GraphQLReferenceService.java:107)
    at com.intellij.lang.jsgra...

Version and Environment Details

Operation system: macOS 12.0.1 IDE version: PY-213.5744.248 Plugin version: 3.1.0

vepanimas commented 2 years ago

Hi @ihormaslov! Is it possible to introspect a schema into the .json file?

{
    "name": "Client schema",
    "schemaPath": "client.json", // <-- specify .json here instead of .graphql
    "extensions": {
        "endpoints": {

        }
    }
}

And what implementation of GraphQL do you use on the server-side? It looks like it doesn't send a deprecated directive definition in the introspection response. I have plenty of similar reports but unfortunately can't reproduce it yet.

Mxrck commented 2 years ago

@vepanimas we have the same problem, using graphene 2.1.8 as server, the plugin version 3.0.0 works well with the same server but it is incompatible with webstorm 2021.3

Fragment of the query result:

...
{
  "kind": "OBJECT",
  "name": "__Directive",
  "description": "A Directive provides a way to describe alternate runtime execution and type validation behavior in a GraphQL document.\n\nIn some cases, you need to provide options to alter GraphQL's execution behavior in ways field arguments will not suffice, such as conditionally including or skipping a field. Directives provide this by describing additional information to the executor.",
  "fields": [
    {
      "name": "name",
      "description": null,
      "args": [],
      "type": {
        "kind": "NON_NULL",
        "name": null,
        "ofType": {
          "kind": "SCALAR",
          "name": "String",
          "ofType": null
        }
      },
      "isDeprecated": false,
      "deprecationReason": null
    },
    {
      "name": "description",
      "description": null,
      "args": [],
      "type": {
        "kind": "SCALAR",
        "name": "String",
        "ofType": null
      },
      "isDeprecated": false,
      "deprecationReason": null
    },
    {
      "name": "locations",
      "description": null,
      "args": [],
      "type": {
        "kind": "NON_NULL",
        "name": null,
        "ofType": {
          "kind": "LIST",
          "name": null,
          "ofType": {
            "kind": "NON_NULL",
            "name": null,
            "ofType": {
              "kind": "ENUM",
              "name": "__DirectiveLocation",
              "ofType": null
            }
          }
        }
      },
      "isDeprecated": false,
      "deprecationReason": null
    },
    {
      "name": "args",
      "description": null,
      "args": [],
      "type": {
        "kind": "NON_NULL",
        "name": null,
        "ofType": {
          "kind": "LIST",
          "name": null,
          "ofType": {
            "kind": "NON_NULL",
            "name": null,
            "ofType": {
              "kind": "OBJECT",
              "name": "__InputValue",
              "ofType": null
            }
          }
        }
      },
      "isDeprecated": false,
      "deprecationReason": null
    },
    {
      "name": "onOperation",
      "description": null,
      "args": [],
      "type": {
        "kind": "NON_NULL",
        "name": null,
        "ofType": {
          "kind": "SCALAR",
          "name": "Boolean",
          "ofType": null
        }
      },
      "isDeprecated": true,
      "deprecationReason": "Use `locations`."
    },
    {
      "name": "onFragment",
      "description": null,
      "args": [],
      "type": {
        "kind": "NON_NULL",
        "name": null,
        "ofType": {
          "kind": "SCALAR",
          "name": "Boolean",
          "ofType": null
        }
      },
      "isDeprecated": true,
      "deprecationReason": "Use `locations`."
    },
    {
      "name": "onField",
      "description": null,
      "args": [],
      "type": {
        "kind": "NON_NULL",
        "name": null,
        "ofType": {
          "kind": "SCALAR",
          "name": "Boolean",
          "ofType": null
        }
      },
      "isDeprecated": true,
      "deprecationReason": "Use `locations`."
    }
  ],
  "inputFields": null,
  "interfaces": [],
  "enumValues": null,
  "possibleTypes": null
},
...
vepanimas commented 2 years ago

Fixed in 3.1.2. Will be available as soon as the plugin will be approved in the marketplace.