Skip to content

Commit e1958fc

Browse files
committed
Initial commit of documentation website (#164)
1 parent ebac462 commit e1958fc

21 files changed

+515
-73
lines changed

.gitignore

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,11 @@ $RECYCLE.BIN/
7070
resources/META-INF/dist/
7171

7272
.gradle
73-
build
73+
build
74+
75+
# documentation website
76+
website/translated_docs
77+
website/build/
78+
website/yarn.lock
79+
website/node_modules
80+
website/i18n/*

.idea/misc.xml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
20.5 KB
Loading

docs/assets/installation.png

27 KB
Loading

docs/assets/introspect-endpoint.png

22.5 KB
Loading

docs/assets/introspect-re-run.png

17.9 KB
Loading

docs/assets/introspect-startup.png

10.8 KB
Loading
Lines changed: 44 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
# Developer Guide for JS GraphQL IntelliJ Plugin v2
1+
---
2+
id: developer-guide
3+
title: Developer guide
4+
sidebar_label: Developer guide
5+
---
26

37
This developer guide covers how to setup your project to get the most out of the GraphQL language tooling in this plugin.
48

@@ -16,7 +20,7 @@ The most important aspect of using the plugin is to configure how schema types a
1620
If the schema types are not discovered correctly, language features such as completion and error highlighting
1721
will be based on the wrong type information.
1822

19-
Schemas and their types are declared using [GraphQL Type System Definition Language](http://facebook.github.io/graphql/June2018/#sec-Type-System)
23+
Schemas and their types are declared using [GraphQL Type System Definition Language](https://graphql.github.io/graphql-spec/June2018/#sec-Type-System)
2024
which is also widely known as GraphQL Schema Definition Language (often abbreviated as SDL).
2125

2226
If you're authoring your schemas in SDL, the plugin provides the following features:
@@ -42,68 +46,39 @@ scope is to prevent types from being picked up in more than one GraphQL type reg
4246
errors as types appear to have been declared more than once. In addition, the scopes prevent non-conflicting types from
4347
showing up in completions and ensure that validation only recognizes the types that belong to the current schema.
4448

45-
The plugin allows you to configure your schema scopes in two different ways:
49+
The plugin allows you to configure your schema scopes using [graphql-config](https://github.com/prismagraphql/graphql-config) configuration files with `includes` and `excludes` glob patterns
4650

47-
- Using the IDE "Settings" page called "Appearance & Behaviour" > ["Scopes"](https://www.jetbrains.com/help/idea/2018.1/settings-scopes.html) with patterns for inclusion and exclusion
48-
- Using [graphql-config](https://github.com/prismagraphql/graphql-config) configuration files with `includes` and `excludes` glob patterns
51+
### Example projects ###
4952

50-
### Setting up Multi-schema Projects using "Appearance & Behaviour" > "Scopes"
51-
In a multi-schema project, each schema needs its own separate scope.
52-
53-
The recommended structure for multi-schema projects is to place each schema in a separate project module or folder.
54-
55-
For example:
56-
57-
```
58-
- project root/
59-
- product a (schema one)/
60-
- schema files and graphql aware components
61-
- product b (schema two)/
62-
- schema files and graphql aware components
63-
```
64-
65-
With this structure there is no need to use exclude patterns.
66-
67-
To setup the project, Open "Settings" > "Language & Frameworks" > "GraphQL" and select the "Multiple schemas".
68-
69-
The scopes can be created via the "Edit scopes" link:
70-
71-
- Click "Add scope"
72-
- Click Shared scope
73-
- Name it the same as the folder
74-
- Select "Project" in the drop down above the project tree
75-
- Select the "product a (schema one)" folder and click the "Include Recursively" button on the right
76-
- Repeat for other schemas
77-
78-
Given a file which contains GraphQL, the plugin finds the first matching schema scope based on the file name, and then
79-
proceeds with schema discovery by processing only the files that the scope accepts.
80-
81-
__Points to consider__:
82-
- You don't have to restrict the patterns to specific file extensions since the plugin only searches relevant file types
83-
- If you do limit to file extensions, make sure you include file extensions for components that use injected GraphQL, e.g. `.jsx`
84-
- When adding scopes, use the "Shared" scopes to create scopes that can be checked into source control and used by other
85-
developers on the project
86-
- If you have created scopes for uses other than GraphQL schema discovery, you should place the GraphQL scopes at the top
87-
of the list since the first matching scope is used by this plugin
53+
See https://github.com/jimkyndemeyer/graphql-config-examples for example uses of `.graphqlconfig` to control schema discovery.
8854

8955
### Setting up Multi-schema Projects using graphql-config
90-
The second option for multi-schema projects is graphql-config. With graphql-config you don't get the scopes UI which
91-
displays the files in the scopes, but it may be the better option if you use other tools that support graphql-config.
92-
93-
To setup the project, Open "Settings" > "Language & Frameworks" > "GraphQL" and select the "graphql-config".
94-
9556
Please familiarize yourself with the [graphql-config format](https://github.com/prismagraphql/graphql-config/blob/master/specification.md)
9657
before proceeding.
9758

9859
The next step is to decide where to place the `.graphqlconfig` file. The config file controls schema discovery from the
9960
directory it's placed in, as well as any sub folders that don't have their own `.graphqlconfig`.
10061

101-
To create a `.graphqlconfig` file, right click a folder and select "New GraphQL Configuration File".
62+
To create a `.graphqlconfig` file, right click a folder and select "New GraphQL Configuration File" or use the "+" Button in the GraphQL Tool window tab called "Schemas and Project Structure".
10263

10364
Depending on your preference, you can use a single `.graphqlconfig` file in a folder that is a parent to each schema
10465
folder, or you can place `.graphqlconfig` files in each schema folder.
10566

106-
__Option A: Single config file:__
67+
__Option A: Multiple config files (recommended):__
68+
69+
```
70+
- project root/
71+
- product a (schema one)/
72+
- .graphqlconfig <-----
73+
- schema files and graphql aware components
74+
- product b (schema two)/
75+
- .graphqlconfig <-----
76+
- schema files and graphql aware components
77+
```
78+
79+
With this approach the location of the config files creates separate scopes for the two schemas.
80+
81+
__Option B: Single config file:__
10782

10883
```
10984
- project root/
@@ -129,19 +104,6 @@ With a single config file you need to separate the schemas using the `includes`
129104
}
130105
```
131106

132-
__Option B: Multiple config files:__
133-
134-
```
135-
- project root/
136-
- product a (schema one)/
137-
- .graphqlconfig <-----
138-
- schema files and graphql aware components
139-
- product b (schema two)/
140-
- .graphqlconfig <-----
141-
- schema files and graphql aware components
142-
```
143-
144-
With this approach the location of the config files creates separate scopes for the two schemas.
145107

146108
### Working with GraphQL Endpoints and Scratch Files
147109

@@ -156,16 +118,26 @@ toolbar button in the top left side of the scratch file editor.
156118
See https://github.com/prisma/graphql-config#specifying-endpoint-info for the expected format of endpoint details such as
157119
the URL, headers etc.
158120

159-
GraphQL scratch files use the following rules for schema discovery and endpoints:
121+
The following example is from [graphql-config-examples/remote-schema-introspection](https://github.com/jimkyndemeyer/graphql-config-examples/tree/master/remote-schema-introspection)
122+
123+
It demonstrates how to use the endpoints configured in `.graphqlconfig` to fetch an existing remote schema.
124+
125+
![](assets/graphql-config-introspect.png)
126+
127+
With `introspect: true` the plugin asks at project startup whether to update the local schema using the configured endpoint.
128+
129+
![](assets/introspect-startup.png)
130+
131+
The update works by sending an introspection query to the endpoint, and then writing the result to the configured `schemaPath`.
132+
133+
The latest introspection query can easily be re-run using the schemas panel:
160134

161-
- If there is a single `.graphqlconfig` the scratch file automatically uses the schema and endpoints from that configuration
162-
- For a project with multiple `.graphqlconfig` files, add the following GraphQL comment to your scratch file to pick the relevant `.graphqlconfig`:
163-
- `# .graphqlconfig=<absolute path to your config dir>\.graphqlconfig`
164-
- In case no matching `.graphqlconfig` was found, the project base dir will be used for schema discovery, and no endpoints
165-
will be available for queries or other operations
135+
![](assets/introspect-re-run.png)
166136

167-
### ---- TODO BELOW THIS LINE ----
137+
Introspection queries can also be executed by double-clicking endpoints in the schemas tree view:
168138

169-
## Breaking changes from v1
139+
![](assets/introspect-endpoint.png)
170140

171-
## Troublshooting
141+
__Notes and comments__
142+
- If you're both developing the server schema and consuming it in a client, e.g. via component queries, you'll get the best tooling by having your schema expressed using GraphQL Schema Definition Language directly in your project. With that setup the plugin immediately discovers your schema, and you don't have to perform an introspection after server schema changes.
143+
- Tip: The re-run introspection action can be bound to a keyboard shortcut for convienience

docs/getting-started.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
id: getting-started
3+
title: Prerequisites & Installation
4+
sidebar_label: Prerequisites & Installation
5+
---
6+
7+
## Prerequisites
8+
9+
The plugin and this documentation site assumes you are already familiar with the GraphQL language. If you're not, please
10+
visit the official [graphql.org](https://graphql.org/) website first.
11+
12+
The plugin works out of the box with popular GraphQL clients such as [Apollo GraphQL](https://www.apollographql.com/) and
13+
[Relay](https://facebook.github.io/relay/), but you're free to choose your client and server frameworks.
14+
15+
## Installation
16+
17+
The plugin is hosted in the JetBrains Plugin Repository at https://plugins.jetbrains.com/plugin/8097-js-graphql
18+
19+
You can install it directly from your IDE via the "Settings > Plugins" screen.
20+
21+
On the "Marketplace" tab simply search for "graphql" and select the "JS GraphQL" suggestion:
22+
23+
![installation](assets/installation.png)
24+
25+
## Compatible IDEs and Versions
26+
27+
The plugin works with all IDEs in the IntelliJ Platform, including but not limited to WebStorm, PhpStorm, IntelliJ IDEA,
28+
and Android Studio. The minimum version is 2018.2 (182.711 or later).

docs/graphql-config-examples.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
id: graphql-config-examples
3+
title: Example Projects
4+
sidebar_label: Example Projects
5+
---
6+
7+
Below you'll find examples that demonstrate how to set up your projects to get the most out of the plugin.
8+
9+
## Project Structure and Schema Discovery
10+
11+
See the [graphql-config-examples](https://github.com/jimkyndemeyer/graphql-config-examples/) repository which demonstrate
12+
how to setup schema discovery and endpoints using `.graphqlconfig` files.

0 commit comments

Comments
 (0)