-
Notifications
You must be signed in to change notification settings - Fork 651
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a AS/IJ plugin doc #5123
Merged
Merged
Add a AS/IJ plugin doc #5123
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
5e2073f
Add a AS/IJ plugin doc
BoD 260ab3d
Update docs/source/testing/android-studio-plugin.mdx
BoD c9eeb71
Update docs/source/testing/android-studio-plugin.mdx
BoD ab78919
Move plugin file before testing, also fix icons.
BoD 2a34e0b
Update getting started
BoD 7593eae
Add a few videos
BoD File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
--- | ||
title: Android Studio / IntelliJ plugin | ||
--- | ||
|
||
To help your day-to-day development with Apollo Kotlin, a plugin for Android Studio and IntelliJ is available. | ||
|
||
## Installation | ||
|
||
The plugin is available on the JetBrains plugin repository. To install it from the IDE, go to | ||
<kbd>Settings</kbd> | <kbd>Plugins</kbd> | <kbd>Marketplace</kbd> | search for "Apollo GraphQL" | <kbd>Install</kbd> | ||
|
||
The plugin is supported on: | ||
|
||
- IntelliJ 2022.2 and above | ||
- Android Studio 2022.2 (Flamingo) and above | ||
BoD marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
## Features | ||
|
||
### Automatic code generation | ||
|
||
The plugin automatically generates models whenever GraphQL files change. | ||
This means you don't need to manually run `./gradlew generateApolloSources` after editing the files. | ||
|
||
Note: this works by running Gradle in continuous mode, and can be disabled in the plugin settings. | ||
|
||
### Integration with the GraphQL IntelliJ Plugin | ||
|
||
The plugin depends on and integrates with the [GraphQL IntelliJ Plugin](https://plugins.jetbrains.com/plugin/8097-js-graphql). | ||
The file structure of the Apollo project is automatically contributed, so there is no need to create a `graphql.config.yml` / `.graphqlconfig` file. | ||
|
||
### Navigation | ||
|
||
#### Kotlin → GraphQL | ||
|
||
When editing Kotlin code, <img src="images/gutter-icon.png" alt="Gutter icon" width="16" valign="top"/> icons will show next to references to generated operation and fragment classes. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
Clicking on them will navigate to the corresponding GraphQL definition. | ||
|
||
You can also go to the GraphQL definition with <kbd>Cmd</kbd> Click (Mac) or <kbd>Ctrl</kbd> Click (Windows / Linux) on an operation, field, enum, etc. | ||
|
||
#### GraphQL → Kotlin | ||
|
||
You can search for code usages of a GraphQL operation, fragment, enum type/value and input type/field, with right click | <kbd>Find Usages</kbd>. | ||
|
||
### Unused operations / fields | ||
|
||
In GraphQL files, operations and fields are shown in grey if the corresponding generated code is not used in your project. | ||
|
||
### Migration helpers | ||
|
||
In the <kbd>Refactor</kbd> | <kbd>Apollo</kbd> menu, you can find helpers to migrate your project: | ||
|
||
- Apollo Android 2.x → Apollo Kotlin 3.x | ||
- `compat` codegen → `operationBased` codegen | ||
- Apollo Kotlin 3.x → Apollo Kotlin 4.x | ||
|
||
Note: while these helpers will automatically update your code when possible, there are some cases where this isn't possible and manual changes are required. | ||
Please refer to the migration guides ([3.x](../migration/3.0/), [4.x](../migration/4.0/)) when upgrading. | ||
|
||
### Open in Apollo Sandbox | ||
|
||
You can open a GraphQL file in [Apollo Sandbox](https://studio.apollographql.com/sandbox/explorer) with right click | <kbd>Open in</kbd> | <kbd>Apollo Sandbox</kbd>. | ||
This is a handy way to share operations with coworkers for instance. There, they will be able to execute the operation and see the result. | ||
|
||
This is also accessible from the <img src="images/open-in-sandbox.png" alt="Sandbox icon" width="16" valign="top"/> button at the top of the editor. | ||
|
||
### High latency fields | ||
|
||
If your project uses Apollo GraphOS, the plugin can use the collected metrics (["Field Insights"](https://www.apollographql.com/docs/graphos/metrics/field-usage)) and report a warning on fields that have a high latency. | ||
|
||
<img src="images/high-latency-field-editor.png" width="400" alt="High latency in editor"/> | ||
|
||
By default, fields with a latency above 100ms will be highlighted. You can change this threshold in <kbd>Settings</kbd> | <kbd>Editor</kbd> | <kbd>Inspections</kbd> | <kbd>GraphQL</kbd> | <kbd>Apollo GraphOS</kbd> | <kbd>High latency field</kbd>. | ||
|
||
A quick fix is available to encapsulate the field in a fragment with the [`@defer`](../fetching/defer) directive. | ||
|
||
For the plugin to be able to fetch the metrics, you need to configure your project with its [Apollo GraphOS API key](https://www.apollographql.com/docs/graphos/api-keys/). To do this, go to the plugin's settings: <kbd>Settings</kbd> | <kbd>Languages & Frameworks</kbd> | <kbd>GraphQL</kbd> | <kbd>Apollo Kotlin</kbd>. Here you can find the <kbd>API keys</kbd> table where you can add: | ||
- API key: should start with `service:` or `user:` | ||
- Graph ID: can be found on your graph page in Apollo Studio | ||
BoD marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
## Weekly snapshots | ||
|
||
If you wish to try the latest features, you can install the weekly snapshots. To do so, add the following repository in <kbd>Settings</kbd> | <kbd>Plugins</kbd> | <kbd>⚙</kbd>️ | <kbd>Manage Plugin Repositories</kbd> | <kbd>+</kbd>: `https://raw.githubusercontent.com/apollographql/apollo-kotlin/main/intellij-plugin/snapshots/plugins.xml`. | ||
|
||
Then installing the plugin by searching "Apollo GraphQL" in the Marketplace will install the latest snapshot. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would move it up before testing in the list because you should set this up before you start testing. Also update the "Get Started" to link to this page?