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
@@ -29,149 +29,149 @@ Operations defined within client applications are automatically extracted and up
29
29
30
30
> Make sure you've met the requirements for _Prerequisites_ above.
31
31
32
-
1. Install the `apollo` command line tool as a development dependency of your client application:
32
+
**1. Install the `apollo` command line tool as a development dependency of your client application:**
33
33
34
-
```
35
-
npm install apollo --save-dev
36
-
```
34
+
```
35
+
npm install apollo --save-dev
36
+
```
37
37
38
-
> Yarn users can run `yarn add apollo --dev`.
38
+
> Yarn users can run `yarn add apollo --dev`.
39
39
40
-
2. Register the server's schema with Apollo Engine:
40
+
**2. Register the server's schema with Apollo Engine:**
41
41
42
-
> If this server's schema has already been registered using `apollo service:push`, you can skip this step. For additional options and details, see the [documentation for the schema registry](./schema-registry.html).
42
+
> If this server's schema has already been registered using `apollo service:push`, you can skip this step. For additional options and details, see the [documentation for the schema registry](./schema-registry.html).
43
43
44
-
First, make sure Apollo Server is running and that introspection is enabled (it is often disabled in production).
44
+
First, make sure Apollo Server is running and that introspection is enabled (it is often disabled in production).
45
45
46
-
Next, using the following command as a reference, replace the `<ENGINE_API_KEY>` with the Apollo Engine API key from the appropriate service and specify the correct server endpoint with the `--endpoint` flag:
46
+
Next, using the following command as a reference, replace the `<ENGINE_API_KEY>` with the Apollo Engine API key from the appropriate service and specify the correct server endpoint with the `--endpoint` flag:
47
47
48
-
```
49
-
npx apollo service:push \
50
-
--key <ENGINE_API_KEY> \
51
-
--endpoint https://server/graphql
52
-
```
48
+
```
49
+
npx apollo service:push \
50
+
--key <ENGINE_API_KEY> \
51
+
--endpoint https://server/graphql
52
+
```
53
53
54
-
When successful, this command should return output similar to the following:
54
+
When successful, this command should return output similar to the following:
55
55
56
-
```
57
-
✔ Loading Apollo config
58
-
✔ Fetching current schema
59
-
✔ Publishing <service> to Apollo Engine
56
+
```
57
+
✔ Loading Apollo config
58
+
✔ Fetching current schema
59
+
✔ Publishing <service> to Apollo Engine
60
60
61
-
id schema tag
62
-
------ ------------- -------
63
-
abc123 <service> current
64
-
```
61
+
id schema tag
62
+
------ ------------- -------
63
+
abc123 <service> current
64
+
```
65
65
66
-
> If you encounter any errors, refer to the _**Troubleshooting**_ section below.
66
+
> If you encounter any errors, refer to the _**Troubleshooting**_ section below.
67
67
68
-
3. Register operations from the client bundle.
68
+
**3. Register operations from the client bundle.**
69
69
70
-
Now we'll use `apollo queries:register` to locate operations within the client codebase and upload a manifest of those operations to Apollo Engine. Once Apollo Server has been configured to respect the operation registry, only operations which have been included in the manifest will be permitted.
70
+
Now we'll use `apollo queries:register` to locate operations within the client codebase and upload a manifest of those operations to Apollo Engine. Once Apollo Server has been configured to respect the operation registry, only operations which have been included in the manifest will be permitted.
71
71
72
-
The `apollo queries:register` command:
72
+
The `apollo queries:register` command:
73
73
74
-
* Supports multiple client bundles. Each bundle is identified by a `clientName` (e.g. `react-web`).
75
-
* Supports JavaScript, TypeScript and `.graphql` files.
76
-
* Accepts a list of files as a glob (e.g. `src/**/*.ts`) to search for GraphQL operations.
77
-
* By default, includes the `__typename` fields which are added by Apollo Client at runtime.
74
+
* Supports multiple client bundles. Each bundle is identified by a `clientName` (e.g. `react-web`).
75
+
* Supports JavaScript, TypeScript and `.graphql` files.
76
+
* Accepts a list of files as a glob (e.g. `src/**/*.ts`) to search for GraphQL operations.
77
+
* By default, includes the `__typename` fields which are added by Apollo Client at runtime.
78
78
79
-
To register operations, use the following command as a reference, taking care to replace the `<ENGINE_API_KEY>` with the appropriate Apollo Engine API key, specifying a unique name for this application with `<CLIENT_IDENTIFIER>`, and indicating the correct glob of files to search:
79
+
To register operations, use the following command as a reference, taking care to replace the `<ENGINE_API_KEY>` with the appropriate Apollo Engine API key, specifying a unique name for this application with `<CLIENT_IDENTIFIER>`, and indicating the correct glob of files to search:
80
80
81
-
```
82
-
npx apollo queries:register \
83
-
--key <ENGINE_API_KEY> \
84
-
--clientName <CLIENT_IDENTIFIER> \
85
-
--queries="src/**/*.{ts,js,graphql}"
86
-
```
81
+
```
82
+
npx apollo queries:register \
83
+
--key <ENGINE_API_KEY> \
84
+
--clientName <CLIENT_IDENTIFIER> \
85
+
--queries="src/**/*.{ts,js,graphql}"
86
+
```
87
87
88
-
When succesfull, the output from this command should look similar to the following:
88
+
When succesfull, the output from this command should look similar to the following:
89
89
90
A3D4
-
```
91
-
✔ Loading Apollo config
92
-
✔ Loading schema
93
-
✔ Resolving GraphQL document sets
94
-
✔ Scanning for GraphQL queries (N found)
95
-
✔ Isolating operations and fragments
96
-
✔ Combining operations and fragments
97
-
✔ Generating manifest
98
-
✔ Registering operations with Apollo Engine service <service>
99
-
```
90
+
```
91
+
✔ Loading Apollo config
92
+
✔ Loading schema
93
+
✔ Resolving GraphQL document sets
94
+
✔ Scanning for GraphQL queries (N found)
95
+
✔ Isolating operations and fragments
96
+
✔ Combining operations and fragments
97
+
✔ Generating manifest
98
+
✔ Registering operations with Apollo Engine service <service>
99
+
```
100
100
101
-
If you encounter any errors, check the _**Troubleshooting**_ section below.
101
+
If you encounter any errors, check the _**Troubleshooting**_ section below.
102
102
103
-
4. Enable demand control by adding the operation registry to Apollo Server.
103
+
**4. Enable demand control by adding the operation registry to Apollo Server.**
104
104
105
-
To enable the operation registry within Apollo Server, it's necessary to install and enable the `apollo-server-plugin-operation-registry` plugin and ensure Apollo Server is configured to communicate with Apollo Engine.
105
+
To enable the operation registry within Apollo Server, it's necessary to install and enable the `apollo-server-plugin-operation-registry` plugin and ensure Apollo Server is configured to communicate with Apollo Engine.
106
106
107
-
First, add the appropriate plugin to the Apollo Server's `package.json`:
107
+
First, add the appropriate plugin to the Apollo Server's `package.json`:
**5. Start Apollo Server with Apollo Engine enabled**
133
133
134
-
If the server was already configured to use Apollo Engine, no additional changes are necessary, but it's important to make sure that the server is configured to use the same service as the operations were registered with in step 3.
134
+
If the server was already configured to use Apollo Engine, no additional changes are necessary, but it's important to make sure that the server is configured to use the same service as the operations were registered with in step 3.
135
135
136
-
If the server was not previously configured with Apollo Engine, be sure to start the server with the `ENGINE_API_KEY` variable set to the appropriate API key. For example:
136
+
If the server was not previously configured with Apollo Engine, be sure to start the server with the `ENGINE_API_KEY` variable set to the appropriate API key. For example:
137
137
138
-
```
139
-
ENGINE_API_KEY=<ENGINE_API_KEY> npm start
140
-
```
138
+
```
139
+
ENGINE_API_KEY=<ENGINE_API_KEY> npm start
140
+
```
141
141
142
-
Alternatively, the API key can be specified with the `engine` parameter on the Apollo Server constructor options:
142
+
Alternatively, the API key can be specified with the `engine` parameter on the Apollo Server constructor options:
143
143
144
-
```js
145
-
constserver=newApolloServer({
146
-
// ...
147
-
engine:"<ENGINE_API_KEY>",
148
-
// ...
149
-
});
150
-
```
144
+
```js
145
+
constserver=newApolloServer({
146
+
// ...
147
+
engine:"<ENGINE_API_KEY>",
148
+
// ...
149
+
});
150
+
```
151
151
152
-
For security, it's recommended to pass the Engine API key as an environment variable so it will not be checked into version control (VCS).
152
+
For security, it's recommended to pass the Engine API key as an environment variable so it will not be checked into version control (VCS).
153
153
154
-
6. Verification
154
+
**6. Verification**
155
155
156
-
With the operation registry enabled, _only_ operations which have been registered will be permitted.
156
+
With the operation registry enabled, _only_ operations which have been registered will be permitted.
157
157
158
-
To confirm that everything is configured properly, try executing an operation against the server which was **not** registered from the client bundle in step 3.
158
+
To confirm that everything is configured properly, try executing an operation against the server which was **not** registered from the client bundle in step 3.
159
159
160
-
For example, using `curl` this could be done with a command similar to:
160
+
For example, using `curl` this could be done with a command similar to:
0 commit comments