Js-graphql-intellij-plugin: [v2] Main issue for tracking progress on the v2 branch

Created on 16 Jun 2018  ยท  86Comments  ยท  Source: jimkyndemeyer/js-graphql-intellij-plugin

Limitations in 1.x and proposed solutions for 2.x

Only a single schema per-project

  • 1.x Completion, references, find usages, error highlighting all based on the assumption that a single schema per-project is the norm
  • 1.x Issues - #43, #56, #84, #125, #129, #140, #144, #145
  • 2.x All language features that rely on schema type info should scoped based on their location in the project

Node.js + JavaScript plugin dependency

  • 1.x Due to these dependencies the plugin is unavailable for IDEs such as Android Studio
  • 2.x Will no longer use an external language service, and JavaScript functionality will be marked "optional" in plugin.xml

Changes to spec, grammar, and language difficult to support in the plugin

  • 1.x Difficulty in isolating changes from the plugin as the language service changes (e.g. grammar changes affect both the plugin and the LS)
  • 1.x Complexity in version management on the NPM packages that the language service depends on
  • 1.x Issues - #92, #118, #133, #137, #141, #150
  • 2.x Use JetBrains grammar-kit to support the GraphQL language natively inside the IntelliJ platform

    • No longer need a separate language service with its own eco-system to reduce complexity

    • Will use graphql-java as a native dependency for validation and schema type APIs



      • Possible now that graphql-java 8.0 added language support for SDL


      • Tasks





        • Validation



        • Completion based on schema type info






Developer experience with 2.x

The biggest change with 2.x is making the GraphQL Schema Definition Language (often abbreviated SDL) a first-class citizen in the plugin and not just a read-only view of the schema.

SDL has become part of the spec in https://github.com/facebook/graphql/pull/90 and is already widely adopted by the community for schema authoring.

A widely used example is the Apollo project where the schema is expressed using SDL inside a gql tagged template literal (https://www.apollographql.com/docs/apollo-server/v2/essentials/server.html)

With this in mind, 2.x of the plugin will provide first-class tooling support for writing SDL, including:

  • Completion on types when defining fields, arguments, implemented interfaces etc.
  • Error highlighting of schema errors such as unknown types, wrong use of types, missing fields when implementing interfaces
  • Find usages in SDL and refactoring such as rename which will update the relevant queries, mutations etc.

Any changes to the SDL type definitions will be immediately reflected in the relevant GraphQL queries and other operations within the given scope. This removes the manual step of having to either trigger an introspection query, or update a single combined .graphql schema file as required in 1.x of the plugin.

Overall, developers should be able to much more productive writing schema using SDL.

Documentation (work in progress)

https://gist.github.com/jimkyndemeyer/1903b65ff892f0811e76f16d8b530848

v2-architecture

Most helpful comment

๐ŸŽ‰๐Ÿค– ๐Ÿš€ โšก๏ธ

2.0.0 is now on master! Thank you all so much for helping with the release.

The release has been pushed to the JetBrains repository and should be available within a few days.

Until then you should get a "2.0.0-end-of-beta" via the custom alpha/beta repository. That release is effectively the 2.0.0 but with at notification to let you know when the official release has been approved by JetBrains. You should then remove the custom repository URL as instructed in the notification.

Once again, thank you for all the feedback, the bug reports and the discussions. I hope 2.0 will help you stay productive as you work with GraphQL.

Best regards,
Jim.

All 86 comments

Bug report.

I'm using Apollo GraphQL schema stitching. I have several .graphqls files. Each of them have type Query {... and type Mutation {...

Here is what 2.0.0-alpha-2 shows:
image

The tooltip shows that I declared the same type multiple times. Which I did only for Mutation and Query.

Not sure how to solve this.

@koresar See my comments here for how to get this working: https://github.com/jimkyndemeyer/js-graphql-intellij-plugin/issues/145#issuecomment-398475569

Omg, this is incredible!

Thank you for the amazing plugin. I love the new colours and features. So good!

Hello @jimkyndemeyer

I have a web app project. It uses a GraphQL endpoint (on my local machine). Previously, the plugin required the graphql.config.json file which pointed to the schema.

How would I setup a URI for my queries using the v2?

@koresar I assume you want to introspect a GraphQL endpoint at a URL and print the schema as GraphQL SDL. The next alpha will support .graphqlconfig where you'll get a green arrow next to endpoint urls. Clicking the arrow executes an introspection query, and prints the result as GraphQL SDL to a file.

Until then, you can use https://github.com/graphql-cli/graphql-cli

Just installed the alpha version, trying to create a simple .graphql file it gives an error:
image

User is defined right below

@JCMais Have you defined any scopes in "Settings" > "Appearance & Behavior" > "Scopes"? The current alpha uses those to discover schema types. The upcoming alpha has a settings page where this is opt-in, along with support for .graphqlconfig files.

@jimkyndemeyer it works, thank you!

Also, I'm using relay-modern, completion and go-to reference seems to work inside tagged graphql code, but there is no color highlight, is that correct?

@JCMais If you get completion the GraphQL parser has been injected, so you should see syntax highlighting.

Please create a separate issue with a minimal repo project attached and I'll take a look. Include IDE version.

Released https://github.com/jimkyndemeyer/js-graphql-intellij-plugin/releases/tag/2.0.0-alpha-3

Note the upgrade notes if you're already using the alpha.

Hey @jimkyndemeyer. Question.

I am running separate projects: backend API, frontend SPA. Backend is on http://localhost:3000/graphql

What should be the settings in SPA project to read the schema from backend introspection (just like it was in v1)? I cannot understand where to put my http://localhost:3000/graphql

Endponts are configured using https://github.com/prismagraphql/graphql-config#specifying-endpoint-info

Once you've added your schema path and endpoint url, you should get a green arrow in the editor gutter next to the endpoint url. Click the green arrow to run an introspection query that is saved to the file configured as the schemaPath.

I'm planning on writing up docs for this as the new workflow is somewhat different from v1.

  • Sorry, I do not have "dev" environment as in the example you linked.

No green arrow. What am I doing wrong?

image

@koresar The introspection feature was released yesterday in alpha-3. Can you check your plugin version and make sure it's updated.

I did update today morning. ๐Ÿ‘

Found the solution though. Here is the only way I could made it work:

{
  "schemaPath": "schema.graphql",
  "extensions": {
    "endpoints": {
      "dev": {
        "url": "http://localhost:3000/graphql"
      }
    }
  }
}

Thanks again! Marvellous plugin :)

Btw. Found a bug.

  • Make a typo in the .graphqlconfig. Like, remove just one double-quote.
  • Click the green arrow.
    Expected: no green arrow should be visible if JSON is malformed.
    Actual: WebStorm reports exception in the plugin.

image
The green arrow should not be available to click.

image

I've got this error on my relay modern queries

I'm using graphql-config to handle multiple graphql projects and schemas:

{
  "projects": {
    "web": {
      "schemaPath": "./entria/web/data/schema.graphql",
      "includes": ["./entria/web/data/*.graphql"],
      "extensions": {
        "endpoints": {
          "dev": {
            "url": "http://localhost:5001/graphql"
          }
        }
      }
    },
    "app": {
      "schemaPath": "./entria/app/data/schema.graphql",
      "includes": ["./entria/app/data/*.graphql"],
      "extensions": {
        "endpoints": {
          "dev": {
            "url": "http://localhost:5001/graphql"
          }
        }
      }
    },
}

it does not recognize relay modern directives as well

@connection
@arguments
@argumentDefinition
@relay(mask: false)

and so on

@sibelius There are no built-in directives other than those in the spec. You have to declare framework-specific directives using SDL. It might make sense to ship the plugin with the most popular framework directives at some point, but even for those cases that will have to be opt-in.

Regarding the error, I think it relates to not having a schema { query: CustomQueryType } in your SDL if your root type is named something other than Query.

my query name is QueryType

one example of it, it is here https://github.com/entria/graphql-dataloader-boilerplate/blob/master/data/schema.graphql#L55

there is no schema { query: Query }

@sibelius Whats the file path in the .graphql file where you're seeing the error? It has to be included by the includes glob to discover the schema.

the path is like this

"includes": ["./entria/app/data/*.graphql"],

not sure if includes should includes all project files or only .graphql schemas

@sibelius You also need to include all files where you declare GraphQL operations, including files like component jsx/tsx files which contain tagged template literals with GraphQL inside. If a file containing GraphQL is not included, the plugin has no way of discovering which schema it belongs to.

The file path I was referring to was the actual file where you're seeing the schema error, not the glob pattern. I think what you're seeing here is that a component file is not included, hence it discovers no schema and complains about no Query type. Note that if the file is not included, you should see a yellow header in the editor which alerts you to that fact.

I took a look at Relay Modern directives: https://facebook.github.io/relay/docs/en/graphql-in-relay.html#directives

Given that @arguments and @argumentDefinition appear to accept any number of named arguments themselves, I don't see how they can be declared using SDL within the current spec. @relay might also not be covered inside the spec, as it appears to take different arguments based on whether it's used on a fragment definition or a fragment spread.

I'll give it some thought on how best to handle this in the plugin. It's a shame that Relay Modern doesn't fall within spec compliance, but I can see why they needed to get creative and "polyfill" GraphQL as they called it.

Bug report added in #166

Regarding third party directives I have a probable solution for plugin users.

Few facts:

  • I do not have Relay.
  • But I have a bunch of custom directives in the schema I'm building atm.

I found a way to avoid these errors in syntax.
image

I have created a file called _not-imported-dev.graphql within my scoped folder. WebStorm scopes do a great job for me. Thanks @jimkyndemeyer for the feature!
image

And now the syntax errors are gone.
image

I hope this might help someone.

@koresar Spot on. That's the intended way of working with schema directives in v2. An additional note is that in a single-schema project the directives are picked up automatically without any configuration. For scoped/multi-schema projects developers have to ensure that the file with the schema directives is explicitly included in the relevant scopes.

@sibelius I've started working on Relay Modern support, including shipping the plugin with the built-in Relay directives.

Can you recommend a github repo that uses all the directives so I have a use case to work up against?

Hi, I'm trying to configure the latest plugin version (2.0.0-alpha3) to use with multiple schema. I already have all necessary scopes configured, then I open a *.graphql file and click on configure:

image
And the following popup is displayed:
image
At this point all are ok, a .graphqlconfig file is created in my scope root folder.
Then I trying to configure that file to use a local schema file instead of url.

{
  "schemaPath": "./schema.graphql"
}

The when go back to the query file the autocomplete does not work
image
My current scope is as follow:
image

The schema.graphql file contains the server schema returned using a introspection query with other tool, the query.graphql files is used to write queries, this queries are loaded in other place, for that reason I only need autocomplete.

Since v1.x I had a configuration like this:

{
  "schema": {
    "file": "./schema.graphql"
  }
}

After update to v2 in order to use multiple schema files using scopes, I have no idea how the configuration should be to load each schema from a file.

@rafrsr I'm still working on docs, but I've added the work-in-progress at https://gist.github.com/jimkyndemeyer/1903b65ff892f0811e76f16d8b530848

Take a look and see if that helps you out. Otherwise drop a comment and we'll troubleshoot what's going on.

Hello. Bug report.

Running the latest WebStorm 2018.2 (stable). Here is what the current plugin throws for me:

In file: file:///Users/vasyl/code/src/schema.graphql

java.lang.NullPointerException
    at com.intellij.lang.jsgraphql.ide.GraphQLValidationAnnotator.getOffsetFromSourceLocation(GraphQLValidationAnnotator.java:366)
    at com.intellij.lang.jsgraphql.ide.GraphQLValidationAnnotator.annotate(GraphQLValidationAnnotator.java:208)
    at com.intellij.codeInsight.daemon.impl.DefaultHighlightVisitor.a(DefaultHighlightVisitor.java:139)
    at com.intellij.codeInsight.daemon.impl.DefaultHighlightVisitor.visit(DefaultHighlightVisitor.java:102)
    at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.a(GeneralHighlightingPass.java:366)
    at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.a(GeneralHighlightingPass.java:298)
    at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.a(GeneralHighlightingPass.java:325)
    at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.a(GeneralHighlightingPass.java:328)
    at com.intellij.codeInsight.daemon.impl.DefaultHighlightVisitor.analyze(DefaultHighlightVisitor.java:86)
    at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.a(GeneralHighlightingPass.java:328)
    at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.a(GeneralHighlightingPass.java:295)
    at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.collectInformationWithProgress(GeneralHighlightingPass.java:238)
    at com.intellij.codeInsight.daemon.impl.ProgressableTextEditorHighlightingPass.doCollectInformation(ProgressableTextEditorHighlightingPass.java:83)
    at com.intellij.codeHighlighting.TextEditorHighlightingPass.collectInformation(TextEditorHighlightingPass.java:69)
    at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.a(PassExecutorService.java:423)
    at com.intellij.openapi.application.impl.ApplicationImpl.tryRunReadAction(ApplicationImpl.java:1151)
    at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.b(PassExecutorService.java:416)
    at com.intellij.openapi.progress.impl.CoreProgressManager.a(CoreProgressManager.java:580)
    at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:525)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:85)
    at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.c(PassExecutorService.java:415)
    at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.d(PassExecutorService.java:391)
    at com.intellij.openapi.application.impl.ReadMostlyRWLock.executeByImpatientReader(ReadMostlyRWLock.java:147)
    at com.intellij.openapi.application.impl.ApplicationImpl.executeByImpatientReader(ApplicationImpl.java:218)
    at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.run(PassExecutorService.java:389)
    at com.intellij.concurrency.JobLauncherImpl$VoidForkJoinTask$1.exec(JobLauncherImpl.java:161)
    at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
    at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
    at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
    at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)

Hello @jimkyndemeyer

Any news regarding the bug above and potential stable release?

@koresar I can't say anything specific about the timeline. I'm the only one working on this, and my free time to do it varies a lot. Regarding the bug, please create an issue with steps for how to reproduce.

Hey guys, I been reading the thread and I am not sure if this has been brought up - I am currently running into 19:29 GraphQL Introspection Error: Internal error: should never happen: cannot build value of ProjectCardArchivedState from StringValue{value='ARCHIVED'}

I am currently on v2.0.0-alpha-3 and attempting to run the introspection query by clicking the โ–ถ๏ธ next to the endpoint url in .graphqlconfig

I am querying Github API @ https://api.github.com/graphql

This is what my config file looks like:

{
  "schemaPath": "./schema.graphql",
  "extensions": {
    "endpoints": {
      "Default GraphQL Endpoint": {
        "url": "https://api.github.com/graphql",
        "headers": {
          "Authorization": "Bearer ${env:GH_TOKEN}"
        }
      }
    }
  }
}

I am new to GraphQL and just found out about this plugin. Anyone has any ideas what is causing this/how to fix it?

@cleverjam As far as I can tell, this error is thrown by graphql-java in https://github.com/graphql-java/graphql-java/blob/394ca2a7f48d7c170e36a16dd70185fd70f6d4d5/src/main/java/graphql/schema/idl/SchemaGeneratorHelper.java#L95.

It's unclear to my why the error occurs, as https://developer.github.com/v4/enum/projectcardarchivedstate/ lists "ARCHIVED" as a valid ProjectCardArchivedState enum value.

I'll try and setup a small reproduction and see if an issue should be logged with the graphql-java project.

@jimkyndemeyer Thank you for your prompt reply! I'll keep an eye on graphql-java to see if anything related comes up/fixes it.

@jimkyndemeyer I am getting an error ""GraphQLError: Syntax Error: Unexpected Name "http""," when running the introspection (clicking the green arrow in .graphqlconfig).

My .graphql config

{
    "schemaPath": "schema.graphql",
    "includes": [
        "**/*.graphql",
        "**/*.js",
        "**/*.jsx",
        "**/*.ts",
        "**/*.tsx"
    ],
    "extensions": {
        "endpoints": {
            "dev": {
                "url": "http://localhost:8101/gql"
            }
        }
    }
}

@nanandn It looks like this error is coming from your GraphQL endpoint. The downside with introspection is that the GraphQL spec has multiple versions, and it's not guaranteed that the supported GraphQL spec version that ships with the plugin is the same as your endpoint. You have two options: A: Configure an introspection query in the GraphQL IDE settings that matches your endpoint, or B: get access to the schema expressed using GraphQL schema definition language (SDL). Depending on your setup, you can write a script that does the introspection and writes the relevant .graphql schema files to your project. In short, the built-in introspection in the plugin is for convenience, but not guaranteed to work with any setup.

Created https://github.com/facebook/graphql/issues/543 to start a discussion about mismatched tooling/endpoint versions during introspection.

@jimkyndemeyer I am not sure what you mean by "Configure an introspection query in the GraphQL IDE settings that matches your endpoint". Isn't that what the "endpoints" in the .graphqlconfig "extensions" is? The apollo graphql playground and graphiql seems to work fine. Is my graphqlconfig wrong?

A different question... If i have the queries/mutations in a .graphql file in the IDE I see an option to run that query.
screen shot 2018-12-22 at 9 32 30 am

But I have a query in the JS file like gql``, I don't see that option. Autocomplete, syntax highlighting works.

Thanks
Anand

Hello @jimkyndemeyer,

I've just tried v2 since the v1 does not recognizes fragments declared in other .graphql files.
First, thanks for all the work, it must be difficult to keep up with the rapidly-evolving technology, practices and conventions :)

For me v2 is unusable for now, mainly because the generated schema (from an endpoint) does not contains definitions for custom scalar types, like MongoID and Date here:

image

I think this is also the reason why my .graphql files also fail to load:

image

Last but not least, gql tags are broken:

image

Not really a big problem for me since we're migrating to plain .graphql files, but not all the "legacy" code using gql will be changed right now.

EDIT: I've finally been able to make it work by generating the schema with graphql-cli get-schema (get-graphql-schema CLI tool also works). The generated schema is correct, and the plugin can use it.
Now the plugin works!

I get terrible performances on live editing though. See that real-time GIF:

peek 23-12-2018 23-58

In purple, the symbols that the IDE has recognized. Below, they're all white, meaning they've not been statically analyzed yet. They get colored _very_ slowly one after the other, and WebStorm takes up to 200-250% CPU usage. When I try to autocomplete, it's also very slow.

I've made an IDE CPU profiling dump (I don't even know with what tool we can read it...) if that can help : WS-183.4588.66_morgan_23.12.2018_22.36.54.zip


I was wondering if we could also get back, at some point, the old behavior of the plugin, when it was automatically running an instrospection query and then put the schema in a scratch file (or something like that), not in the project's filesystem. Not a big fan of auto-generated files. Now I find it a bit invasive, but I can understand the pros (no need to query the server each time, and support for a community convention).


~I'll just reinstall v1 the time being and try to forget about those "unknown fragment" messages.~ As stated in my edit, that's no longer necessary but that performance problem is annoying.

As I said, thanks for the work, and I'd be happy to help! This plugin is actually the best third-party thing I've used in WebStorm and is very, very useful to my daily work.

Hey people.

I'd like WebStorm to have full GraphQL support out of the box.

So I created a feature request there and pointed to this awesome plugin.

I urge you to vote (thumb up) on the WebStorm issue tracker.
https://youtrack.jetbrains.com/issue/WEB-33564

Thanks all

Hi All.

I wanna give a big thanks to all the testers so far.

I've just released alpha 4 which adresses a number of issues. The highlights are as follows:

  • Performance improvements (tested with 10K lines in a single schema file)
  • Relay Modern support (opt in, but plugin will ask for Relay projects)
  • MarkDown documentation support
  • Structure view
  • Scratch files
  • Recognize .graphqls extension as GraphQL file
  • Template placeholder support, e.g. to insert fragments in tagged template literals
  • Various minor bug fixes
  • Increased test coverage

See https://github.com/jimkyndemeyer/js-graphql-intellij-plugin/releases/tag/2.0.0-alpha-4 for further info.

Keep the feedback coming. I'm aware that since schema discovery is more complex is v2 I'll need to address this with more feedback from the UI. I'll also look into having the plugin help developers migrate from the old graphql.config.json files to the new graphql-config format.

Best regards,
Jim.

@jimkyndemeyer From just a quick glance, I can see a huge perf improvement! Thank you!

Here are my impressions of 2.0.0 alpha4 installed in IDEA 2018.3.4 (Preview).
My .graphqlconfig is as follows:

{
  "schemaPath": "schema.graphql",
  "extensions": {
    "endpoints": {
      "ghe": {
        "url": "https://github.jpl.nasa.gov/api/graphql",
        "headers": {
          "Authorization": "Bearer ${env:GITHUB_API_KEY}"
        }
      }
    }
  }
}

When I click on the green arrow, a dialog pops up
titled Enter Missing GraphQL "GITHUB_API_KEY" Environment Variable.
However, the name of the variable is shown without underscores, i.e.: GITHUBAPIKEY
At least, it's nice that it remembers the value of this variable for the IntelliJ session.

After I click OK and I get this in the IntelliJ Event Log:

1/21/19
4:55 PM GraphQL Introspection Error: Internal error: should never happen: cannot build value of ProjectCardArchivedState from StringValue{value='ARCHIVED'}

At least, If I invoke
In the schema, we see this:

        {
          "kind": "ENUM",
          "name": "ProjectCardArchivedState",
          "description": "The possible archived states of a project card.",
          "fields": null,
          "inputFields": null,
          "interfaces": null,
          "enumValues": [
            {
              "name": "ARCHIVED",
              "description": "A project card that is archived",
              "isDeprecated": false,
              "deprecationReason": null
            },
            {
              "name": "NOT_ARCHIVED",
              "description": "A project card that is not archived",
              "isDeprecated": false,
              "deprecationReason": null
            }
          ],
          "possibleTypes": null
        },

I can execute *.graphql queries; however, the graphql code shows red; I get the same error as shown here: https://github.com/jimkyndemeyer/js-graphql-intellij-plugin/issues/164#issuecomment-402485704

I tried to use the graphql get-schema command but this fails because the .graphqlconfig file doesn't have a project. At any rate, I saved the Github V4 API schema using curl in schema.graphql.
It it unclear whether the plugin recognizes this schema at all.

Perhaps the Settings > Language & Frameworks > GraphQL dialog could show which schema(s) are effectively recognized for the current project. Without this kind of feedback, it's frustrating to have the error marks all over *.graphql files without any clue about why the plugin can't find the schema.

About invoking queries:

The variables editor is useful; however, it would be very helpful to have a mechanism for optionally persisting variables & values. I'd like to run the same query with different sets of variable/values.

I noticed that if I have a '*.graphql' editor open and I switch to the "Query Result" pane,
then the "Structure" pane shows me the outline of the query result. Double-clicking in a nested result opens a new "/Graphql.result.json" editor window.

@NicolasRouquette Thanks for the feedback.

I agree that it isn't clear right now how the schema discovery is working and the status of it. I plan to add two tabs to the GraphQL tool window to help with this:

  • Bring back the "Console" tab, to show various info/error messages about what the plugin is doing
  • A new "Schemas" tab that shows the discovered schemas, their status, and whether the currently open tab is considered a part of it.

As for the variables editor, I've made a note of your suggestion, as it would be a nice improvement.

Thanks,
Jim.

I've got this error on alpha-5

java.lang.ClassCastException: graphql.schema.GraphQLTypeReference cannot be cast to graphql.schema.GraphQLInterfaceType
    at graphql.schema.idl.SchemaGenerator.lambda$buildObjectTypeInterfaces$9(SchemaGenerator.java:499)
    at java.util.ArrayList.forEach(ArrayList.java:1251)
    at graphql.schema.idl.SchemaGenerator.buildObjectTypeInterfaces(SchemaGenerator.java:498)
    at graphql.schema.idl.SchemaGenerator.buildObjectType(SchemaGenerator.java:489)
    at graphql.schema.idl.SchemaGenerator.buildOutputType(SchemaGenerator.java:411)
    at graphql.schema.idl.SchemaGenerator.buildField(SchemaGenerator.java:695)
    at graphql.schema.idl.SchemaGenerator.lambda$buildInterfaceType$12(SchemaGenerator.java:531)
    at java.util.ArrayList.forEach(ArrayList.java:1251)
    at graphql.schema.idl.SchemaGenerator.buildInterfaceType(SchemaGenerator.java:530)
    at graphql.schema.idl.SchemaGenerator.buildOutputType(SchemaGenerator.java:413)
    at graphql.schema.idl.SchemaGenerator.buildField(SchemaGenerator.java:695)
    at graphql.schema.idl.SchemaGenerator.lambda$buildObjectType$6(SchemaGenerator.java:478)
    at java.util.ArrayList.forEach(ArrayList.java:1251)
    at graphql.schema.idl.SchemaGenerator.buildObjectType(SchemaGenerator.java:477)
    at graphql.schema.idl.SchemaGenerator.buildOutputType(SchemaGenerator.java:411)
    at graphql.schema.idl.SchemaGenerator.lambda$buildUnionType$15(SchemaGenerator.java:557)
    at java.util.ArrayList.forEach(ArrayList.java:1251)
    at graphql.schema.idl.SchemaGenerator.buildUnionType(SchemaGenerator.java:556)
    at graphql.schema.idl.SchemaGenerator.buildOutputType(SchemaGenerator.java:415)
    at graphql.schema.idl.SchemaGenerator.lambda$buildAdditionalTypes$3(SchemaGenerator.java:365)
    at java.util.LinkedHashMap$LinkedValues.forEach(LinkedHashMap.java:608)
    at graphql.schema.idl.SchemaGenerator.buildAdditionalTypes(SchemaGenerator.java:357)
    at graphql.schema.idl.SchemaGenerator.makeExecutableSchemaImpl(SchemaGenerator.java:332)
    at graphql.schema.idl.SchemaGenerator.makeExecutableSchema(SchemaGenerator.java:274)
    at graphql.schema.idl.SchemaGenerator.makeExecutableSchema(SchemaGenerator.java:246)
    at graphql.schema.idl.UnExecutableSchemaGenerator.makeUnExecutableSchema(UnExecutableSchemaGenerator.java:28)
    at com.intellij.lang.jsgraphql.schema.GraphQLTypeDefinitionRegistryServiceImpl.lambda$getSchemaWithErrors$1(GraphQLTypeDefinitionRegistryServiceImpl.java:71)
    at java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1660)

@sibelius Thanks for testing. Can you please create a separate issue with the [v2] prefix and include the SDL or Schema JSON that causes this exception. It's occurring inside the graphql-java code, so I might need to log an issue or do a PR for that project.

Also, can you please let me know how the Relay Modern tooling fares in v2 if you have any projects with that stack. You should get a notification when the plugin detects Relay to enable the necessary directives.

the plugin is working fine

the creating of graphql config really helped

the plugin detected relay modern, and relay modern features is working pretty well

thanks for the hard work

the crash stopped working after having the configs set up

@sibelius Sounds good. As for the class cast exception it appears to be https://github.com/graphql-java/graphql-java/issues/1147

I'll bump the graphql-java version for the next alpha release.

we have some code like this:

// language=GraphQL
  const query = `
    mutation M($id: ID!) {
      MyMutation(input: {
        id: $id
      }) {
         name
      }
    }
  `;

in v1 it highlight this kind of code, because we were using // language=GraphQL hint

should this work on v2?

nevermind is working

it'd be cool to see which schema the query is working, as we can have multiple schema support

@sibelius I'll add the new directives to the next Alpha. For now you can simply declare them yourself as part of your schema, given that they don't have the special non-GraphQL spec behaviour that the other directives have.

The schema tool window will bold the label of schema tree nodes that include the current editor tab.

The schema tool window will bold the label of schema tree nodes that include the current editor tab.

this comments helps when the plugin identify a schema, the problem happens when the plugin does not identify a schema.graphql, maybe a hint where the plugin tried to find the config

another feedback is that Schemas and Project Structure only shows the current message, maybe show a list of schema.graphql recognized and the paths of any of them.

Or just the schema.graphql recognized for current open file, not sure how hard it to do it

image

@sibelius Hmm, that state should only be shown until either the default single schema is active, or one or more .graphqlconfig files have been processed. Does the "Refresh" icon button on the left change the tree? If not, it would be really helpful with a small reproduction repo.

Published alpha-6:

  • Migration of graphql.config.json files to .graphqlconfig
  • Support for schemas based on JSON introspection files
  • Improved the schemas tree view presentation of config files with multiple keyed projects
  • Automatic introspection notification
  • Updated Relay Modern directives
  • Upgraded to graphql-java 11.0
  • Various minor fixes

The config migration worked beautifully on my rather complicated project.
Thank you!

On Mon., 25 Feb. 2019, 02:08 Jim Kynde Meyer, notifications@github.com
wrote:

Published alpha-6:

  • Migration of graphql.config.json files to .graphqlconfig
  • Support for schemas based on JSON introspection files
  • Improved the schemas tree view presentation of config files with
    multiple keyed projects
  • Automatic introspection notification
  • Updated Relay Modern directives
  • Upgraded to graphql-java 11.0
  • Various minor fixes

โ€”
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/jimkyndemeyer/js-graphql-intellij-plugin/issues/164#issuecomment-466785057,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABjCLzzBvpTQ62NWzllCQVgzykTPJXYTks5vQqrjgaJpZM4UqdCh
.

WebStorm 2019.1 EAP throws "Exception in plugin JS GraphQL (2.0.0-alpa-6)..."

Double release of editor

com.intellij.openapi.util.TraceableDisposable$DisposalException: Double release of editor:
    at com.intellij.openapi.util.TraceableDisposable.throwDisposalError(TraceableDisposable.java:101)
...

@koresar Thanks, fixed in alpha-7.

@jimkyndemeyer could you please publish alpha-7?

Published alpha-7:

  • Added re-run introspection action to improve remote schema workflow
  • Added scalars to introspection SDL output
  • Added __typename completion
  • Various minor fixes (double dispose of editor etc.)

See https://github.com/jimkyndemeyer/graphql-config-examples for example project structures.

I have query parameter named "input". Should it be the same black colour as the rest of the arguments instead of the bold blue?

image

@koresar Thanks for the heads up. Fixed in alpha-8 due tomorrow evening.

Published alpha-8:

  • Improved introspection including support for custom scalars
  • Added intention to add missing schema types in SDL
  • Fixed error marker positions in gql tags
  • Moved configuration scan to background tasks
  • Added support for projects in scratch files
  • Added completion of variable names
  • Added completion of enums in lists
  • Fixed arguments shown as keywords in syntax highlighter

This is expected to be the last alpha release since it's considered feature complete for the initial 2.0 release.

The first beta release will be cut after the initial round of testing. We're getting close now.

Thanks for all your feedback and testing. It's been instrumental in getting the v2 in shape ๐Ÿ‘

Is there a way to remove this thing?

image

Quite annoying. I'm fine to use the entire project.

Also, I have no idea how to edit .graphqlconfig globs.

@koresar This message is shown based on the following logic:

  • A .graphqlconfig file exists in the directory of the file, or one of the parent directories
  • But, given either "includes" and/or "excludes" globs in that config, the edited file is not part of that configuration. This should be unintentional, as schema discovery will then not be controlled by the nearest .graphqlconfig and fall back to project-wide.

It's fine to have a .graphqlconfig that doesn't control schema discovery, but only contains endpoints. In that case make sure you delete the "includes" and "excludes" from your config.

If what you're seeing appears to be a bug, please create a separate [v2] issue and include your .graphqlconfig along with the path of the edited file that shows the warning.

Best regards,
Jim.

Hello @jimkyndemeyer,

So far Alpha 8 seems to work well. Just got a small error while typing a property name in a fragment though:


Show stack trace for java.lang.NullPointerException

java.lang.NullPointerException
    at com.intellij.lang.jsgraphql.ide.completion.GraphQLCompletionContributor$16.addCompletions(GraphQLCompletionContributor.java:683)
    at com.intellij.codeInsight.completion.CompletionProvider.addCompletionVariants(CompletionProvider.java:36)
    at com.intellij.codeInsight.completion.CompletionContributor.fillCompletionVariants(CompletionContributor.java:141)
    at com.intellij.codeInsight.completion.CompletionService.getVariantsFromContributors(CompletionService.java:87)
    at com.intellij.codeInsight.completion.CompletionResultSet.runRemainingContributors(CompletionResultSet.java:149)
    at com.intellij.codeInsight.completion.CompletionResultSet.runRemainingContributors(CompletionResultSet.java:142)
    at com.intellij.codeInsight.template.impl.LiveTemplateCompletionContributor$2.addCompletions(LiveTemplateCompletionContributor.java:96)
    at com.intellij.codeInsight.completion.CompletionProvider.addCompletionVariants(CompletionProvider.java:36)
    at com.intellij.codeInsight.completion.CompletionContributor.fillCompletionVariants(CompletionContributor.java:141)
    at com.intellij.codeInsight.completion.CompletionService.getVariantsFromContributors(CompletionService.java:87)
    at com.intellij.codeInsight.completion.impl.CompletionServiceImpl.performCompletion(CompletionServiceImpl.java:63)
    at com.intellij.codeInsight.completion.CompletionProgressIndicator.calculateItems(CompletionProgressIndicator.java:827)
    at com.intellij.codeInsight.completion.CompletionProgressIndicator.runContributors(CompletionProgressIndicator.java:812)
    at com.intellij.codeInsight.completion.CodeCompletionHandlerBase.lambda$null$2(CodeCompletionHandlerBase.java:272)
    at com.intellij.openapi.application.impl.ApplicationImpl.tryRunReadAction(ApplicationImpl.java:1168)
    at com.intellij.codeInsight.completion.AsyncCompletion.tryReadOrCancel(CompletionThreading.java:169)
    at com.intellij.codeInsight.completion.CodeCompletionHandlerBase.lambda$doComplete$3(CodeCompletionHandlerBase.java:269)
    at com.intellij.codeInsight.completion.AsyncCompletion.lambda$null$0(CompletionThreading.java:95)
    at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$2(CoreProgressManager.java:164)
    at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:582)
    at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:532)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:87)
    at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:151)
    at com.intellij.codeInsight.completion.AsyncCompletion.lambda$startThread$1(CompletionThreading.java:91)
    at com.intellij.openapi.application.impl.ApplicationImpl$1.run(ApplicationImpl.java:314)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)




Nothing critical, and that happened only once.

Again, thanks for your precious work =)

Hello again!

The plugin proposes me to migrate to the new config format, even in projects where I don't use GraphQL:

image

Shouldn't the plugin check for the existence of the old file first?

@toverux I reviewed the migration code, and it finds the legacy configs using the file index and the file name graphql.config.json:

https://github.com/jimkyndemeyer/js-graphql-intellij-plugin/blob/2e760f5b0c3b70825e9f47ddd8291d51b64cc59e/src/main/com/intellij/lang/jsgraphql/ide/project/graphqlconfig/GraphQLConfigMigrationHelper.java#L64-L78

I've also not been able to reproduce the notification in a new blank project.

If you click the graphql.config.json link it should open the file it identified as the legacy config.

FYI: Intellij says there's an update: Version 2.0.0-beta-1 update.

Indeed, look at: https://raw.githubusercontent.com/jimkyndemeyer/js-graphql-intellij-plugin/v2/alpha-releases/updatePlugins.xml
It currently has:

<plugins>
    <plugin id="com.intellij.lang.jsgraphql" url="https://github.com/jimkyndemeyer/js-graphql-intellij-plugin/blob/v2/alpha-releases/JS%20GraphQL-2.0.0-beta-1.zip?raw=true" version="2.0.0-beta-1"/>
</plugins>

But there is no such release as: https://github.com/jimkyndemeyer/js-graphql-intellij-plugin/blob/v2/alpha-releases/JS%20GraphQL-2.0.0-beta-1.zip

@NicolasRouquette Thanks for the heads up. I jumped the gun there. I've fixed the version for now, and expect a beta-1 release later today.

Published beta-1:

  • Fixed schema and endpoint resolution for "Edit GraphQL fragment" in own editor tab.
  • Fixed fragment definition resolution in scratch files.
  • Various minor fixes: Completion, syntax highlighting, JSON introspection schema scopes.
  • Removed unused v1 code.

How does one install this version? I only see v1.7.3 available through Webstorm's plugin installer.

Thank you!

Published beta-2:

  • Switched to SVG-based icons and added plugin icon.
  • Updated document provider to use new style.
  • Moved schema discovery in Schemas panel off the UI thread.
  • Introduced dedicated GraphQL index to improve performance.
  • Fixed various minor issues: Type scopes in arrays, custom scalars omitted by graphql-java, memory leak in query editor.

A thank you to the JetBrains team who contributed multiple pull requests.

@jimkyndemeyer Is this a bug?

A different question... If i have the queries/mutations in a .graphql file in the IDE I see an option to run that query.
screen shot 2018-12-22 at 9 32 30 am

But I have a query in the JS file like gql``, I don't see that option. Autocomplete, syntax highlighting works.

Thanks
Anand

It is a bug. I reported it earlier. Just found a way to reproduce.

  • Create a new node.js project. (It's a server side project.)
  • Create a new file, say schema.graphql with some queries/mutations/types.

Problem: The panel from the above screenshot is present.
Expected: No panels, or at least I can hide/close it.

@koresar Thanks for responding.
I am a little confused by your response. you are saying "Problem: The panel from the above screenshot is present." Do you mean the panel should not be preset?

Anand

@anarasimhan oops. Misread your issue. My issue it totally different. Apologies.

@anarasimhan Not a bug. You can't execute the JS files directly against a GraphQL endpoint, but you can use the "Edit GraphQL fragment" intention to create a separate editor tab that allows you to do it:

image

@jimkyndemeyer Thanks. Makes sense. There can be more than one query in the js file.
Maybe a "play" icon/button on the gutter on the line where the query is would be easy to use than intention.

๐ŸŽ‰๐Ÿค– ๐Ÿš€ โšก๏ธ

2.0.0 is now on master! Thank you all so much for helping with the release.

The release has been pushed to the JetBrains repository and should be available within a few days.

Until then you should get a "2.0.0-end-of-beta" via the custom alpha/beta repository. That release is effectively the 2.0.0 but with at notification to let you know when the official release has been approved by JetBrains. You should then remove the custom repository URL as instructed in the notification.

Once again, thank you for all the feedback, the bug reports and the discussions. I hope 2.0 will help you stay productive as you work with GraphQL.

Best regards,
Jim.

After updating I got syntax error in the code which used to highlight correctly. It's a valid GraphQL query. It shouldn't be red.

When I hover mouse over the red text the tooltip says:

Unknown fragment spread "AddressParts"

image

fragment AddressParts on Address { street suburb state postcode country }
fragment ContactParts on IContact {
    address { ...AddressParts }
    id firstName lastName companyName
}
fragment RecipientParts on Recipient {
    ...ContactParts
    bankIdentifier accountIdentifier country
}
fragment SenderParts on Sender { ...ContactParts dob }

{
  ... then goes the query
}

@koresar Please create a separate issue for this with steps to reproduce. I see that you're using an injection comment which could be the reason why the newly introduced index doesn't discover the fragments. Also add the reason why the language=GraphQL comment is needed for your use case.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dhay picture dhay  ยท  5Comments

advance512 picture advance512  ยท  5Comments

MichaelDeBoey picture MichaelDeBoey  ยท  4Comments

smmoosavi picture smmoosavi  ยท  3Comments

vjpr picture vjpr  ยท  4Comments