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

Introspection returning empty result #505

Closed CruseCtrl closed 2 years ago

CruseCtrl commented 2 years ago

Hi,

I'm trying to turn on introspection for a remote schema, but I'm just getting an empty result with no "data" node. I've created a .graphqlconfig file as described in the documentation and I can now send & receive queries using scratch files, but when I try to run the introspection I get an empty result.

My .graphqlconfig file:

{
  "schemaPath": "schema.graphql",
  "extensions": {
    "endpoints": {
      "dev": {
        "url": "https://example.com/path/db-dev/graphql",
        "headers": {
          "Authorization": "Bearer  <token>",
          "user-agent": "JS GraphQL"
        },
        "introspect": true
      }
    }
  }
}

The schemas panel: image

(I think that the error "A schema should have a query operation defined" is because the introspection hasn't yet created a schema)

The result of running "Get GraphQL Schema from Endpoint (Introspection)" on dev: image

But I can successfully run a query in a scratch file, so it's definitely connecting to the server correctly: Screenshot 2021-11-01 at 14 36 47

Extra information The server is running PostGraphile I can successfully fetch the schema in Insomnia, just by pasting in the url of my GraphQL server and giving it the correct access token, without having to do any other setup

I get the following error in the logs of the PostGraphile server:

[
  GraphQLError: Syntax Error: Unexpected Name "https"
      at syntaxError (/home/node/app/node_modules/graphql/error/syntaxError.js:15:10)
      at Parser.unexpected (/home/node/app/node_modules/graphql/language/parser.js:1463:41)
      at Parser.parseDefinition (/home/node/app/node_modules/graphql/language/parser.js:157:16)
      at Parser.many (/home/node/app/node_modules/graphql/language/parser.js:1518:26)
      at Parser.parseDocument (/home/node/app/node_modules/graphql/language/parser.js:111:25)
      at Object.parse (/home/node/app/node_modules/graphql/language/parser.js:36:17)
      at parseQuery (/home/node/app/node_modules/postgraphile/build/postgraphile/http/createPostGraphileHttpRequestHandler.js:260:46)
      at /home/node/app/node_modules/postgraphile/build/postgraphile/http/createPostGraphileHttpRequestHandler.js:677:63
      at Array.map (<anonymous>)
      at graphqlRouteHandler (/home/node/app/node_modules/postgraphile/build/postgraphile/http/createPostGraphileHttpRequestHandler.js:640:52) {
    locations: [ [Object] ],
    statusCode: 400
  }
]

Version and Environment Details Operation system: macOS Big Sur Version 11.6 IDE name and version: PyCharm 2021.2.2 (Professional Edition) Plugin version: JS GraphQL 3.0.0

Thanks!

CruseCtrl commented 2 years ago

It turns out this was due to an earlier attempt at getting this working, which I had forgotten about. Originally I had pasted the url of my GraphQL API into the "Introspection Query" box in Settings | Languages & Frameworks | GraphQL. Clearing that box made everything work properly. Maybe there should be something to validate that the introspection query matches the expected syntax?

Thanks for making this plugin!