You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+68-52Lines changed: 68 additions & 52 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -26,31 +26,35 @@ The Apollo GraphQL extension for VS Code brings an all-in-one tooling experience
26
26
27
27
<h2id="getting-started">Getting started</h2>
28
28
29
-
To get all the benefits of the VS Code experience, it's best to link the schema that is being developed against before installing the extension. The best way to do that is by [publishing a schema](https://www.apollographql.com/docs/graphos/delivery/publishing-schemas/) to the Apollo schema registry. After that's done:
29
+
For the VS Code plugin to know how to find the schema, it needs to be linked to either a published schema or a local one.
30
30
31
-
1. Create an `apollo.config.js` file at the root of the project.
32
-
Alternatively, you can create a `cjs`, `mjs`, or `ts` file with the same configuration.
33
-
2. Obtain a [Personal API key](https://www.apollographql.com/docs/graphos/api-keys) from GraphOS Studio.
31
+
First, create an `apollo.config.json` file at the root of the project.
32
+
Alternatively, you can create a `yaml`, `cjs`, `mjs`, or `ts` file with the same configuration.
34
33
35
-
<h3id="apollo-config">Setting up an Apollo config</h3>
34
+
For the contents of this configuration file, select one of these options:
36
35
37
-
For the VS Code plugin to know how to find the schema, it needs to be linked to either a published schema or a local one. To link a project to a published schema, edit the `apollo.config.js` file to look like this:
36
+
<details>
37
+
<summary>
38
+
<h3>Configure extension for schemas published to Apollo GraphOS</h3>
39
+
</summary>
38
40
39
-
```js
40
-
module.exports= {
41
-
client: {
42
-
service:"my-graphql-app",
43
-
},
44
-
};
41
+
To get all the benefits of the VS Code experience, it's best to link the schema that is being developed against before installing the extension. The best way to do that is by [publishing a schema](https://www.apollographql.com/docs/graphos/delivery/publishing-schemas/) to the Apollo schema registry.
42
+
43
+
After that's done, edit the `apollo.config.json` file to look like this:
44
+
45
+
```json
46
+
{
47
+
"client": {
48
+
"service": "graphos-graph-name"
49
+
}
50
+
}
45
51
```
46
52
47
53
The `service` name is the name of the graph you've created in [GraphOS Studio](https://studio.apollographql.com).
48
54
49
55
See [additional configuration options](#additional-apollo-config-options).
50
56
51
-
<h3id="api-key">Setting up the <code>.env</code> file</h3>
52
-
53
-
To authenticate with GraphOS Studio to pull down your schema, create a `.env` file in the same directory as the `apollo.config.js` file. This should be an untracked file (that is, don't commit it to Git).
57
+
To authenticate with GraphOS Studio to pull down your schema, create a `.env` file in the same directory as the `apollo.config.json` file. This should be an untracked file (that is, don't commit it to Git).
54
58
55
59
Then go to your [User Settings page](https://studio.apollographql.com/user-settings/api-keys?referrer=docs-content) in GraphOS Studio to create a new Personal API key.
After this is done, VS Code can be reloaded and the Apollo integration will connect to GraphOS Studio to provide autocomplete, validation, and more.
66
70
67
-
<h3id="local-schemas">Local schemas</h3>
71
+
</details>
72
+
73
+
<details>
74
+
<summary>
75
+
<h3id="local-schemas">Configure extension to use introspection from a locally running service</h3>
76
+
</summary>
68
77
69
-
Sometimes it may make sense to link the editor to a locally running version of a schema to try out new designs that are in active development. To do this, the `apollo.config.js` file can be linked to a local service definition:
78
+
Sometimes it may make sense to link the editor to a locally running version of a schema to try out new designs that are in active development. To do this, the `apollo.config.json` file can be linked to a local service definition:
70
79
71
-
```js
72
-
module.exports={
73
-
client: {
74
-
service: {
75
-
name:"my-graphql-app",
76
-
url:"http://localhost:4000/graphql",
77
-
},
78
-
},
79
-
};
80
+
```json
81
+
{
82
+
"client": {
83
+
"service": {
84
+
"name": "my-graphql-app",
85
+
"url": "http://localhost:4000/graphql"
86
+
}
87
+
}
88
+
}
80
89
```
81
90
82
91
Linking to the local schema won't provide all features, such as switching graph variants and performance metrics.
One of the best features of the VS Code extension is the automatic merging of remote schemas and local ones when using integrated state management with Apollo Client. This happens automatically whenever schema definitions are found within a client project. By default, the VS Code extension will look for all JavaScript, TypeScript and GraphQL files under `./src` to find both the operations and schema definitions for building a complete schema for the application.
104
120
105
-
Client side schema definitions can be spread throughout the client app project and will be merged together to create one single schema. The default behavior can be controlled by adding specifications to the `apollo.config.js`:
121
+
Client side schema definitions can be spread throughout the client app project and will be merged together to create one single schema. The default behavior can be controlled by adding specifications to the `apollo.config.json`:
When using GraphQL with JavaScript or TypeScript projects, it is common to use the `gql` tagged template literal to write out operations. Apollo tools look through your files for the `gql` tag to extract your queries, so if you use a different template literal, you can configure it like so:
0 commit comments