8000 More space/formatting adjustments to work around code fence issues · JavaScriptExpert/apollo@588993f · GitHub
[go: up one dir, main page]

Skip to content

Commit 588993f

Browse files
committed
More space/formatting adjustments to work around code fence issues
1 parent 4e11540 commit 588993f

File tree

1 file changed

+101
-101
lines changed

1 file changed

+101
-101
lines changed

docs/source/platform/operation-registry.md

Lines changed: 101 additions & 101 deletions
A3D4
Original file line numberDiff line numberDiff line change
@@ -29,149 +29,149 @@ Operations defined within client applications are automatically extracted and up
2929

3030
> Make sure you've met the requirements for _Prerequisites_ above.
3131
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:**
3333

34-
```
35-
npm install apollo --save-dev
36-
```
34+
```
35+
npm install apollo --save-dev
36+
```
3737

38-
> Yarn users can run `yarn add apollo --dev`.
38+
> Yarn users can run `yarn add apollo --dev`.
3939
40-
2. Register the server's schema with Apollo Engine:
40+
**2. Register the server's schema with Apollo Engine:**
4141

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).
4343
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).
4545

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:
4747

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+
```
5353

54-
When successful, this command should return output similar to the following:
54+
When successful, this command should return output similar to the following:
5555

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
6060
61-
id schema tag
62-
------ ------------- -------
63-
abc123 <service> current
64-
```
61+
id schema tag
62+
------ ------------- -------
63+
abc123 <service> current
64+
```
6565

66-
> If you encounter any errors, refer to the _**Troubleshooting**_ section below.
66+
> If you encounter any errors, refer to the _**Troubleshooting**_ section below.
6767
68-
3. Register operations from the client bundle.
68+
**3. Register operations from the client bundle.**
6969

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.
7171

72-
The `apollo queries:register` command:
72+
The `apollo queries:register` command:
7373

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.
7878

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:
8080

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+
```
8787

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:
8989

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-
```
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+
```
100100

101-
If you encounter any errors, check the _**Troubleshooting**_ section below.
101+
If you encounter any errors, check the _**Troubleshooting**_ section below.
102102

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.**
104104

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.
106106

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`:
108108

109-
```
110-
npm install apollo-server-plugin-operation-registry
111-
```
109+
```
110+
npm install apollo-server-plugin-operation-registry
111+
```
112112

113-
> Yarn uses run: `yarn add apollo-server-plugin-operation-registry`.
113+
> Yarn uses run: `yarn add apollo-server-plugin-operation-registry`.
114114
115-
Next, the plugin must be enabled. This requires adding the appropriate module to the `plugins` parameter to the Apollo Server options:
115+
Next, the plugin must be enabled. This requires adding the appropriate module to the `plugins` parameter to the Apollo Server options:
116116

117-
```js
118-
const server = new ApolloServer({
119-
// Existing configuration
120-
typeDefs,
121-
resolvers,
122-
// ...
123-
// New configuration
124-
plugins: [
125-
require("apollo-server-plugin-operation-registry")({
126-
forbidUnregisteredOperations: true,
127-
}),
128-
],
129-
});
130-
```
117+
```js
118+
const server = new ApolloServer({
119+
// Existing configuration
120+
typeDefs,
121+
resolvers,
122+
// ...
123+
// New configuration
124+
plugins: [
125+
require("apollo-server-plugin-operation-registry")({
126+
forbidUnregisteredOperations: true,
127+
}),
128+
],
129+
});
130+
```
131131

132-
5. Start Apollo Server with Apollo Engine enabled
132+
**5. Start Apollo Server with Apollo Engine enabled**
133133

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.
135135

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:
137137

138-
```
139-
ENGINE_API_KEY=<ENGINE_API_KEY> npm start
140-
```
138+
```
139+
ENGINE_API_KEY=<ENGINE_API_KEY> npm start
140+
```
141141

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:
143143

144-
```js
145-
const server = new ApolloServer({
146-
// ...
147-
engine: "<ENGINE_API_KEY>",
148-
// ...
149-
});
150-
```
144+
```js
145+
const server = new ApolloServer({
146+
// ...
147+
engine: "<ENGINE_API_KEY>",
148+
// ...
149+
});
150+
```
151151

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).
153153

154-
6. Verification
154+
**6. Verification**
155155

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.
157157

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.
159159

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:
161161

162-
```
163-
curl 'http://server/graphql/' \
164-
-H 'Content-Type: application/json' \
165-
--data-binary '{"query":"query { likes{title} }"}'
166-
```
162+
```
163+
curl 'http://server/graphql/' \
164+
-H 'Content-Type: application/json' \
165+
--data-binary '{"query":"query { likes{title} }"}'
166+
```
167167

168-
If the server is configured properly, it should return:
168+
If the server is configured properly, it should return:
169169

170-
```
171-
Execution forbidden
172-
```
170+
```
171+
Execution forbidden
172+
```
173173

174-
Finally, to confirm that the server will allow permitted operations, try running an operation from the client.
174+
Finally, to confirm that the server will allow permitted operations, try running an operation from the client.
175175

176176
## Troubleshooting
177177

0 commit comments

Comments
 (0)
0