Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 21 additions & 17 deletions packages/apollo-cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,19 @@
Apollo CLI brings together your GraphQL clients and servers with tools for validating your schema, linting your operations for compatibility with your server, and generating static types for improved client-side type safety.

<!-- toc -->
* [Apollo CLI](#apollo-cli)
* [Usage](#usage)
* [Commands](#commands)
* [Configuration](#configuration)
* [Code Generation](#code-generation)
* [Contributing](#contributing)
<!-- tocstop -->

- [Apollo CLI](#apollo-cli)
- [Usage](#usage)
- [Commands](#commands)
- [Configuration](#configuration)
- [Code Generation](#code-generation)
- [Contributing](#contributing)
<!-- tocstop -->

# Usage

<!-- usage -->

```sh-session
$ npm install -g apollo
$ apollo COMMAND
Expand All @@ -27,17 +29,19 @@ USAGE
$ apollo COMMAND
...
```

<!-- usagestop -->

# Commands

<!-- commands -->
* [`apollo codegen:generate [OUTPUT]`](#apollo-codegengenerate-output)
* [`apollo help [COMMAND]`](#apollo-help-command)
* [`apollo queries:check`](#apollo-queriescheck)
* [`apollo schema:check`](#apollo-schemacheck)
* [`apollo schema:download OUTPUT`](#apollo-schemadownload-output)
* [`apollo schema:publish`](#apollo-schemapublish)

- [`apollo codegen:generate [OUTPUT]`](#apollo-codegengenerate-output)
- [`apollo help [COMMAND]`](#apollo-help-command)
- [`apollo queries:check`](#apollo-queriescheck)
- [`apollo schema:check`](#apollo-schemacheck)
- [`apollo schema:download OUTPUT`](#apollo-schemadownload-output)
- [`apollo schema:publish`](#apollo-schemapublish)

## `apollo codegen:generate [OUTPUT]`

Expand All @@ -51,11 +55,11 @@ ARGUMENTS
OUTPUT
Directory to which generated files will be written.
- For TypeScript/Flow generators, this specifies a directory relative to each source file by default.
- For TypeScript/Flow generators with the "outputFlat" flag is set, and for the Swift generator, this specifies a
- For TypeScript/Flow generators with the "outputFlat" flag is set, and for the Swift generator, this specifies a
file or directory (absolute or relative to the current working directory) to which:
- a file will be written for each query (if "output" is a directory)
- all generated types will be written
- For all other types, this defines a file (absolute or relative to the current working directory) to which all
- For all other types, this defines a file (absolute or relative to the current working directory) to which all
generated types are written.

OPTIONS
Expand Down Expand Up @@ -226,7 +230,7 @@ Let's take a look at a basic configuration file (`package.json` style):
"engineKey": "my-engine-key" // use this key when connecting to Apollo Engine
}
},
"queries": [
"queries": [ // optional if you only have one schema
{
"schema": "myPrimaryBackend", // reference the previously defined schema
"includes": [ "**/*.tsx" ], // load queries from .tsx files
Expand All @@ -250,7 +254,7 @@ module.exports = {
engineKey: "my-engine-key" // use this key when connecting to Apollo Engine
}
},
queries: [
queries: [ // optional if you only have one schema
{
schema: "myPrimaryBackend", // reference the previously defined schema
includes: [ "**/*.tsx" ], // load queries from .tsx files
Expand Down
60 changes: 60 additions & 0 deletions packages/apollo-vscode/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Apollo VSCode

An all-in-one tooling experience for developing apps with Apollo

- Get instant feedback and intelligent autocomplete as you write queries
- Run queries against your GraphQL server without leaving your editor
- View performance statistics next to your query definitions

![Code completing queries](images/variable-argument-completion.gif)
![Running a query with variables](images/query-with-vars.gif)
![Viewing Engine statistics](images/engine-stats.png)

## Features
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this extension work with non-Apollo GraphQL servers?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! Is there somewhere we can make this more clear?


- Loads your GraphQL schemas and queries automatically from an [Apollo Config](https://github.com/apollographql/apollo-cli/blob/master/packages/apollo-cli/README.md#configuration) file
- Adds syntax highlighting for GraphQL files and `gql` templates inside JavaScript files
- Code-completes fields, arguments, types, and variables in your queries
- Lets you run queries, mutations, and subscriptions within the IDE with code-completion for variables
- Displays performance statistics from [Apollo Engine](https://www.apollographql.com/engine) inline with your queries
- Jump-to-definition for fragments and schema types
- Detects fragment references and shows them next to definitions

## How to get it?

Open up VS Code and search for the extension "Apollo".
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this extension conflict with any other GraphQL extensions you have installed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably, since both register a GraphQL syntax. Should I add a line to warn users about installing it alongside other extensions?


## How to get it set up?
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about uploading your schema to Engine? What if you're not running your GraphQL server locally?


The extension searches for [Apollo Config](https://github.com/apollographql/apollo-cli/blob/master/packages/apollo-cli/README.md#configuration) definitions in `package.json` or `apollo.config.js` files. To set up a basic endpoint and queries defined in `.tsx` files, a config file would look like.

```js
// package.json

{
...,
"apollo": {
"schemas": {
"mainSchema": {
"endpoint": "http://localhost:4000/graphql"
}
}
}
}
```

## How do we run queries?

The extension enables query execution when an `endpoint` is specified for the schema you are targeting. When you hit `Run query/mutations/subscription`, the extension will open a menu for you to input variables if there are any defined or directly run the query otherwise.

Queries and mutations are executed the same network interface as Apollo Client. Subscriptions are configured to run against the `subscriptions` key in your schema or your endpoint with `http` replaced by `ws` if the key is not defined.

## Troubleshooting

### Extension not starting correctly? Check the logs!

If you're having trouble with the extension not launching or not detecting your configuration files, you can check the language server logs.

1. Open the VS Code output tab by running the command "View: Toggle Output"
2. Switch the output view to "Apollo GraphQL"
3. Check the logs and report any bugs you find!
Binary file added packages/apollo-vscode/images/engine-stats.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 packages/apollo-vscode/images/query-with-vars.gif
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.
2 changes: 1 addition & 1 deletion packages/apollo-vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"build": "tsc -p .",
"watch": "tsc -w -p ./",
"update-vscode": "node ./node_modules/vscode/bin/install",
"packageExtension": "npm run build && ./node_modules/vsce/out/vsce package"
"packageExtension": "npm run build && ./node_modules/vsce/out/vsce package --baseContentUrl https://raw.githubusercontent.com/apollographql/apollo-cli/master/packages/apollo-vscode"
},
"dependencies": {
"vscode": "^1.1.17",
Expand Down
Loading