Skip to content

Commit

Permalink
Merge pull request #232 from jimkyndemeyer/v2
Browse files Browse the repository at this point in the history
Apply v2 to master
  • Loading branch information
jimkyndemeyer committed Apr 6, 2019
2 parents ae48064 + 693fadf commit a34e36b
Show file tree
Hide file tree
Showing 622 changed files with 27,964 additions and 13,382 deletions.
18 changes: 12 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,15 @@ $RECYCLE.BIN/

# Windows shortcuts
*.lnk
.idea/dictionaries/*
.idea/workspace.xml
.idea/uiDesigner.xml
.idea/vcs.xml
.idea/pure-run-config-templates.xml
resources/META-INF/dist/
.idea
resources/META-INF/dist/

.gradle
build

# documentation website
website/translated_docs
website/build/
website/yarn.lock
website/node_modules
website/i18n/*
1 change: 0 additions & 1 deletion .idea/.name

This file was deleted.

22 changes: 5 additions & 17 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions .idea/copyright/profiles_settings.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/encodings.xml

This file was deleted.

9 changes: 0 additions & 9 deletions .idea/libraries/commons_io_2_5.xml

This file was deleted.

18 changes: 4 additions & 14 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## 2.0.0 (2019-04-06)

Changes:

- Support for the June 2018 GraphQL specification including SDL (#118, #133, #137, #129, #141, #144, #150, #164)
- Support for multiple schemas using graphql-config (#84, #125, #140, #145, #164)
- Replaced Node.js based language service with native parser, lexer, and graphql-java to be compatible with all IDEs based on the IntelliJ Platform (#62, #164)

## 1.7.4 (2019-04-03)

Fixes:
Expand Down
102 changes: 20 additions & 82 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,105 +2,43 @@

# JS GraphQL IntelliJ Plugin

__Note:__ V2.0 is in active development. See the [v2 branch](https://github.com/jimkyndemeyer/js-graphql-intellij-plugin/tree/v2) and [#164]( https://github.com/jimkyndemeyer/js-graphql-intellij-plugin/issues/164)
GraphQL language support for WebStorm, IntelliJ IDEA and other IDEs based on the IntelliJ Platform.

GraphQL language support including Relay.QL tagged templates in JavaScript and TypeScript.

It provides the following features in IntelliJ IDEA, WebStorm, RubyMine, PhpStorm, and PyCharm:
## Features overview

- Full language support for the June 2018 GraphQL Specification including the Type System Definition Language (SDL)
- The plugin discovers your local schema on the fly. Remote schemas are easily fetched using introspection
- Schema discovery is configured using [graphql-config](https://github.com/prisma/graphql-config) files, including support for multi-schema projects
- Built-in support for Relay and Apollo projects: `graphql` and `gql` tagged template literals in JavaScript and TypeScript are automatically recognized as GraphQL
- Execute queries using variables against configurable endpoints, including support for custom headers and environment variables
- Schema-aware completion, error highlighting, and documentation
- Syntax highlighting, code-formatting, folding, commenter, and brace-matching
- 'Find Usages' and 'Go to Declaration' for schema types and fields
- Schema viewer and 'Go to Implementation' for schema interfaces
- 'Structure view' to navigate GraphQL and GraphQL Schema files
- Configurable GraphQL schema retrieval and reloading based on a local file or a url using 'then-request'
- Execute queries with variables against configurable endpoints

V1.x depends on [js-graphql-language-service](https://github.com/jimkyndemeyer/js-graphql-language-service) that it manages using a Node.js process handler.

## Installation
1. Install Node JS
```
# Ubuntu
sudo apt install nodejs
# Mac OS
brew install node
```

2. Install Node JS and JS GraphQL Plugin in IntelliJ
```
1. File | Settings | Plugins
2. Search for: nodejs and graphql
3. Install both plugins and Restart
```

3. Set Node JS Interpreter in IntelliJ
```
1. File | Settings | Languages & Frameworks | Node.js and NPM Node interpreter
2. Add... (search for nodejs bin path in your system)
# Ubuntu
whereis nodejs
/usr/bin/nodejs
# Mac OS
which node
# Windows
where node
```
At this point JS GraphQL will recognize your `.graphql` files. However, if you wish to customize your schema, follow the FAQ.
- 'Find Usages' and 'Go to Declaration' for schema types, fields, and fragments
- 'Structure view' to navigate GraphQL files

## Documentation

The plugin uses a `graphql.config.json` file in the project root to configure the location of your GraphQL schema.

To get started, please see the [FAQ](#faq).

## Features demo

**Schema setup, completion, error highlighting, documentation**
![](docs/js-graphql-webstorm-demo.gif)

**Find usages, schema viewer, structure view**
![](docs/js-graphql-webstorm-usages-structure-demo.gif)

## FAQ

**How do I configure the plugin in a project**

The plugin is activated as soon as you view or edit GraphQL in the editor. This includes GraphQL inside `Relay.QL` and `gql` templates in JavaScript and TypeScript. You can also use `.graphql` physical files and scratch files. These files allow you to query your endpoint directly from your IDE.

An editor notification bar should prompt you to "Create a graphql.config.json". Accept and edit this config file to point the plugin at your local `schema.json` or your endpoint for introspection. The plugin uses the schema to provide completion and error highlighting.

**How do I reload a GraphQL Schema that was loaded from a URL?**

In the the GraphQL tool window, select the "Current Errors" tab and click the "Restart JS GraphQL Language Service" button.

**I clicked "No thanks" when asked to create a graphql.config.json. Now what?**

Download [graphql.config.json](https://github.com/jimkyndemeyer/js-graphql-intellij-plugin/blob/master/resources/META-INF/graphql.config.json) from this repository and place it in your project root (next to your package.json for JS projects). Re-open the project and edit `graphql.config.json` to point the plugin at your schema.
The main documentation site is available at https://jimkyndemeyer.github.io/js-graphql-intellij-plugin/

**Fields are shown as errors with "Cannot query field..." messages**
## Which IDEs are compatible with the plugin?

Make sure you've edited your `graphql.config.json` to point it at your schema. This enables the plugin to properly recognize the available types and their fields.
The plugin is compatible with version 2018.2+ (182.711 or later) of all IDEs based on the IntelliJ Platform, including but not limited to WebStorm, IntelliJ IDEA, Android Studio, RubyMine, PhpStorm, and PyCharm.

**Which IDEs are compatible with the plugin?**
## Where can I get the plugin?

The plugin is compatible with version 143+ of IntelliJ IDEA, WebStorm, RubyMine, PhpStorm, and PyCharm.
The plugin is published to the [JetBrains Plugin Repository](https://plugins.jetbrains.com/plugin/8097?pr=).

PyCharm CE is not supported since the plugin depends on two other plugins: NodeJS and JavaScript.
To install it, open your IDE "Settings", "Plugins", "Marketplace" and search for "GraphQL".

Experimental support for Android Studio is available in the [`android-studio`](https://github.com/jimkyndemeyer/js-graphql-intellij-plugin/tree/android-studio) branch. Download it from there.
## Acknowledgements

**Where can I get the plugin?**
This plugin was heavily inspired by [GraphiQL](https://github.com/graphql/graphiql) from Facebook.

The plugin is available from the JetBrains Plugin Repository at https://plugins.jetbrains.com/plugin/8097?pr=
A number of language features such as query and schema validation are powered by [graphql-java](https://github.com/graphql-java/graphql-java).

To install it, open "Settings", "Plugins", "Browse repositories..." and search for "GraphQL".
A thanks also goes out to the [Apollo](https://github.com/apollographql) and [Prisma](https://github.com/prisma) teams for their continued efforts to improve the GraphQL Developer Experience.

**Note**: The experimental version in the `android-studio` branch is not available from the JetBrains Plugin Repository.
And finally, a thank you to the [JetBrains WebStorm team](https://twitter.com/WebStormIDE) and the Alpha/Beta testers for all their help in getting the 2.0 release across the finish line.

## License
MIT
Binary file added alpha-releases/JS GraphQL-2.0.0-alpha-1.zip
Binary file not shown.
Binary file added alpha-releases/JS GraphQL-2.0.0-alpha-2.zip
Binary file not shown.
Binary file added alpha-releases/JS GraphQL-2.0.0-alpha-3.zip
Binary file not shown.
Binary file added alpha-releases/JS GraphQL-2.0.0-alpha-4.zip
Binary file not shown.
Binary file added alpha-releases/JS GraphQL-2.0.0-alpha-5.zip
Binary file not shown.
Binary file added alpha-releases/JS GraphQL-2.0.0-alpha-6.zip
Binary file not shown.
Binary file added alpha-releases/JS GraphQL-2.0.0-alpha-7.zip
Binary file not shown.
Binary file added alpha-releases/JS GraphQL-2.0.0-alpha-8.zip
Binary file not shown.
Binary file added alpha-releases/JS GraphQL-2.0.0-beta-1.zip
Binary file not shown.
Binary file added alpha-releases/JS GraphQL-2.0.0-beta-2.zip
Binary file not shown.
Binary file added alpha-releases/JS GraphQL-2.0.0-end-of-beta.zip
Binary file not shown.
3 changes: 3 additions & 0 deletions alpha-releases/updatePlugins.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<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-end-of-beta.zip?raw=true" version="2.0.0-end-of-beta"/>
</plugins>
137 changes: 137 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
buildscript {
repositories {
maven { url 'https://jitpack.io'}
}
dependencies{
classpath "com.github.JetBrains:gradle-grammar-kit-plugin:2018.3"
}
}

plugins {
id 'org.jetbrains.intellij' version '0.4.4'
id "de.undercouch.download" version "3.4.3"
id "com.github.ManifestClasspath" version "0.1.0-RELEASE"
}

group 'com.intellij.lang.jsgraphql'
version '2.0.0'

apply plugin: 'java'

sourceCompatibility = 1.8

repositories {
mavenCentral()
}

dependencies {
compile ("com.graphql-java:graphql-java:11.0") {
exclude group: "org.reactivestreams", module: "reactive-streams"
exclude group: "com.graphql-java", module: "java-dataloader"
exclude group: "org.slf4j", module: "slf4j-api"
}
compile "commons-io:commons-io:2.6"
compile "com.atlassian.commonmark:commonmark:0.12.1"
compile group: 'org.yaml', name: 'snakeyaml', version: '1.21'

testCompile group: 'junit', name: 'junit', version: '4.12'
}

intellij {
version '2018.2'
type 'IU'
updateSinceUntilBuild = false
pluginName 'JS GraphQL'
plugins = ['JavaScriptLanguage', 'CSS']
ideaDependencyCachePath = project.buildDir
}

runIde {
jvmArgs '-Xmx2G'
}

patchPluginXml {

}

sourceSets {

main.java.srcDirs = ['src/main', 'gen']
main.resources.srcDir 'resources'

test.java.srcDirs = ['src/test']
test.resources.srcDir 'test-resources'

}

apply plugin: 'org.jetbrains.grammarkit'

// import is optional to make task creation easier
import org.jetbrains.grammarkit.tasks.*

// GraphQL Parser and Lexer
task generateGraphQLLexer(type: GenerateLexer) {
source 'src/grammars/GraphQLLexer.flex'
targetDir 'gen/com/intellij/lang/jsgraphql/'
targetClass 'GraphQLLexer'
purgeOldFiles = true
}

task generateGraphQLParser(type: GenerateParser) {
source "src/grammars/GraphQLParser.bnf"
targetRoot = 'gen/'
purgeOldFiles = true
pathToParser = 'com/intellij/lang/jsgraphql/GraphQLParser'
pathToPsiRoot = 'com/intellij/lang/jsgraphql/psi'
}

// GraphQL Endpoint Parser and Lexer
task generateGraphQLEndpointLexer(type: GenerateLexer) {
source 'src/grammars/JSGraphQLEndpointLexer.flex'
targetDir 'gen/com/intellij/lang/jsgraphql/endpoint/lexer/'
targetClass 'JSGraphQLEndpointLexer'
purgeOldFiles = true
}

task generateGraphQLEndpointParser(type: GenerateParser) {
source "src/grammars/JSGraphQLEndpointParser.bnf"
targetRoot = 'gen/'
purgeOldFiles = true
pathToParser = 'com/intellij/lang/jsgraphql/endpoint/parser/JSGraphQLEndpointParser'
pathToPsiRoot = 'com/intellij/lang/jsgraphql/endpoint/psi'
}


// GraphQL Endpoint Doc Parser and Lexer
task generateGraphQLEndpointDocLexer(type: GenerateLexer) {
source 'src/grammars/JSGraphQLEndpointDocLexer.flex'
targetDir 'gen/com/intellij/lang/jsgraphql/endpoint/doc/lexer/'
targetClass 'GraphQLLexer'
purgeOldFiles = true
}

task generateGraphQLEndpointDocParser(type: GenerateParser) {
source "src/grammars/JSGraphQLEndpointDocParser.bnf"
targetRoot = 'gen/'
purgeOldFiles = true
pathToParser = 'com/intellij/lang/jsgraphql/endpoint/doc/JSGraphQLEndpointDocParser'
pathToPsiRoot = 'com/intellij/lang/jsgraphql/endpoint/doc/psi'
}

task downloadMinimatchNashorn(type: Download) {
src 'https://raw.githubusercontent.com/jimkyndemeyer/minimatch-nashorn/1.0.1/dist/minimatch-nashorn.js'
dest 'resources/META-INF'
overwrite false
}

compileJava {
dependsOn downloadMinimatchNashorn
dependsOn generateGraphQLEndpointLexer
dependsOn generateGraphQLEndpointParser
dependsOn generateGraphQLEndpointDocLexer
dependsOn generateGraphQLEndpointDocParser
dependsOn generateGraphQLLexer
dependsOn generateGraphQLParser
}

compileJava.options.encoding = 'UTF-8'
Binary file added docs/assets/graphql-config-introspect.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/installation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/introspect-endpoint.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/introspect-re-run.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/introspect-startup.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit a34e36b

Please sign in to comment.