zuplo 6.71.0 → 6.71.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,29 +8,27 @@ tags:
8
8
  - backends
9
9
  ---
10
10
 
11
- Zuplo fronts GraphQL APIs the same way it fronts REST: requests pass through a
12
- gateway route with whatever authentication, rate limiting, and
13
- GraphQL-specific policies you attach and your Dev Portal documents the schema.
14
- This guide covers both halves: adding a GraphQL endpoint to your gateway routes,
15
- then rendering a schema reference and playground in the Dev Portal with
16
- `@zudoku/plugin-graphql`.
17
-
18
- ## Prerequisites
19
-
20
- - A Zuplo project
21
- - An upstream GraphQL API to proxy
22
- - For the Dev Portal section: your project's
23
- [Dev Portal](../dev-portal/introduction.mdx) lives in its `docs/` folder. The
24
- plugin requires the `zudoku` package version `0.80.1` or newer — check the
25
- version in `docs/package.json` and
26
- [update the Dev Portal](../dev-portal/updating.mdx) if yours is older.
11
+ Zuplo fronts a GraphQL API like any other backend: requests pass through a
12
+ gateway route with the policies you attach, and your Dev Portal documents the
13
+ schema. This guide proxies the endpoint, reports failed operations to analytics,
14
+ and publishes a schema reference and playground.
15
+
16
+ :::tip{title="TL;DR"}
17
+
18
+ - [ ] Proxy your GraphQL endpoint through a route with the URL Rewrite handler
19
+ - [ ] Tag the route with the `x-graphql` extension so the Portal recognizes it
20
+ - [ ] Surface failed operations with the `graphql-analytics-outbound` policy
21
+ - [ ] Publish a schema reference and playground with the `graphqlPlugin` for the
22
+ Developer Portal
23
+
24
+ :::
27
25
 
28
26
  ## Add a GraphQL endpoint to your gateway
29
27
 
30
- A GraphQL API serves every query and mutation from a single endpoint, so the
31
- gateway route uses the [URL Rewrite handler](../handlers/url-rewrite.mdx) —
32
- every request goes to exactly the upstream URL — rather than URL Forward, which
33
- appends the incoming path.
28
+ Because GraphQL uses a single endpoint, the route uses the
29
+ [URL Rewrite handler](../handlers/url-rewrite.mdx) — every request goes to
30
+ exactly the upstream URL — rather than URL Forward, which appends the incoming
31
+ path.
34
32
 
35
33
  ### Add a new GraphQL route
36
34
 
@@ -45,10 +43,11 @@ appends the incoming path.
45
43
  2. **Add the endpoint**
46
44
 
47
45
  Click **Add** and select **GraphQL Endpoint**. This creates a `POST /graphql`
48
- route preconfigured with the URL Rewrite handler and a demo upstream. If
49
- `/graphql` is already taken, the Portal appends a short suffix (for example
50
- `/graphql-b891`) edit the path to whatever you prefer. GraphQL routes show
51
- a **GraphQL** badge in the route list instead of an HTTP method.
46
+ route preconfigured with the URL Rewrite handler, a demo upstream, and the
47
+ [GraphQL Analytics policy](#report-failed-operations-to-analytics) for error
48
+ reporting. If `/graphql` is already taken, the Portal appends a short suffix
49
+ (for example `/graphql-b891`) edit the path to whatever you prefer. GraphQL
50
+ routes show a **GraphQL** badge in the route list instead of an HTTP method.
52
51
 
53
52
  3. **Point it at your upstream**
54
53
 
@@ -106,44 +105,100 @@ set:
106
105
 
107
106
  :::tip{title="Secure the endpoint"}
108
107
 
109
- GraphQL has its own attack surface deeply nested queries, expensive
110
- operations, and schema introspection. Zuplo ships policies for all three. See
108
+ Zuplo ships policies for query depth, complexity, and introspection. See
111
109
  [Secure your GraphQL API](./graphql-security.mdx) to add complexity limits and
112
110
  disable introspection in production.
113
111
 
114
112
  :::
115
113
 
116
- ## Document the API in your Dev Portal
114
+ ## Report failed operations to analytics
115
+
116
+ Failed GraphQL operations return `200 OK` with an `errors[]` array in the body
117
+ (the Apollo Server and graphql-yoga convention). HTTP-level analytics read that
118
+ `200` as a success, so those failures never show up on the
119
+ [GraphQL analytics dashboard](../analytics/tabs/graphql.md).
117
120
 
118
- The `@zudoku/plugin-graphql` package renders GraphQL APIs in your Dev Portal
119
- from a schema. Each plugin instance produces a browsable type reference
120
- (queries, mutations, objects, enums, and so on) plus a playground, generated
121
- straight from your schema.
121
+ The **GraphQL Analytics** policy closes that gap. It reads each response body,
122
+ counts the GraphQL errors, and classifies every one by its `extensions.code` —
123
+ `syntax`, `validation`, `auth`, `timeout`, or `resolver` so failed operations
124
+ appear on the dashboard as failures, broken down by error class. The response
125
+ passes through to the client unchanged.
122
126
 
123
127
  :::caution{title="Beta"}
124
128
 
125
- The GraphQL plugin is in beta. During the beta it isn't available in your
126
- project's working copy it only works in projects
127
- [connected to source control](./source-control.mdx).
129
+ The GraphQL Analytics policy is in beta. You can use it today, but it may change
130
+ in non-backward compatible ways before the final release.
128
131
 
129
132
  :::
130
133
 
131
- <Stepper>
134
+ New GraphQL endpoints include this policy automatically — the
135
+ [Add a new GraphQL route](#add-a-new-graphql-route) flow attaches a
136
+ `graphql-analytics-outbound` policy to the route's `outbound` chain, so error
137
+ reporting works out of the box. If you instead
138
+ [marked an existing route as GraphQL](#mark-an-existing-route-as-graphql), add a
139
+ `graphql-analytics-outbound` policy and reference it in that route's `outbound`
140
+ list.
141
+
142
+ Tune the policy by editing its `options` in `config/policies.json`. Out of the
143
+ box it classifies the standard Apollo error codes — for example, it reports
144
+ `GRAPHQL_VALIDATION_FAILED` as `validation` and `UNAUTHENTICATED` as `auth` —
145
+ and falls back to `resolver` for anything it doesn't recognize:
146
+
147
+ ```json title="config/policies.json"
148
+ {
149
+ "policies": [
150
+ {
151
+ "name": "graphql-analytics",
152
+ "policyType": "graphql-analytics-outbound",
153
+ "handler": {
154
+ "export": "GraphqlAnalyticsOutboundPolicy",
155
+ "module": "$import(@zuplo/runtime)",
156
+ "options": {
157
+ "errorCodeClassification": {
158
+ "RATE_LIMITED": "resolver",
159
+ "NOT_LOGGED_IN": "auth"
160
+ },
161
+ "defaultErrorClass": "resolver",
162
+ "logErrors": true
163
+ }
164
+ }
165
+ }
166
+ ]
167
+ }
168
+ ```
132
169
 
133
- 1. **Install the plugin**
170
+ - `errorCodeClassification` — Maps custom `extensions.code` values your server
171
+ emits to an error class. Entries merge over, and win against, the built-in
172
+ Apollo code map. Defaults to none.
173
+ - `defaultErrorClass` — The class for an error whose code is missing or
174
+ unrecognized. One of `syntax`, `validation`, `auth`, `timeout`, or `resolver`.
175
+ Defaults to `resolver`.
176
+ - `logErrors` — When `true`, also writes a structured warning to the request log
177
+ — the message, code, and path of each error, capped at the first 10 — for
178
+ every errored response. Defaults to `false`.
179
+ - `maxResponseBytes` — The largest response body, in bytes, the policy inspects.
180
+ Larger responses pass through unscanned, so any errors they carry go
181
+ unreported. Defaults to `5242880` (5 MiB).
182
+
183
+ See the
184
+ [GraphQL Analytics policy reference](../policies/graphql-analytics-outbound.mdx)
185
+ for the full classification table and schema.
134
186
 
135
- Check `docs/package.json` first new projects ship with
136
- `@zudoku/plugin-graphql` already listed in `dependencies`, so there's nothing
137
- to install. Only older projects need to add it. In your project's `docs/`
138
- folder (where `zudoku.config.tsx` lives), install the plugin:
187
+ ## Document the API in your Dev Portal
139
188
 
140
- ```bash
141
- npm install @zudoku/plugin-graphql
142
- ```
189
+ The `@zudoku/plugin-graphql` package renders a browsable type reference and a
190
+ playground in your Dev Portal, generated from your schema. Register one instance
191
+ per API.
143
192
 
144
- The plugin requires `zudoku` `0.80.1` or newer.
193
+ :::caution{title="Beta"}
194
+
195
+ The GraphQL plugin is in beta.
145
196
 
146
- 2. **Register the plugin**
197
+ :::
198
+
199
+ <Stepper>
200
+
201
+ 1. **Register the plugin**
147
202
 
148
203
  Import `graphqlPlugin` and add an instance per API. The `path` is where the
149
204
  docs mount, and `input` points at your GraphQL endpoint:
@@ -168,11 +223,11 @@ project's working copy — it only works in projects
168
223
  export default config;
169
224
  ```
170
225
 
171
- With `type: "url"`, the schema is fetched via introspection when the portal
172
- builds, and the playground sends operations to that same URL by default.
173
- Point `input` at the gateway route from the first half of this guide so
174
- readers run real queries through your gateway — or keep the playground
175
- separate from the schema source with `options.playground.endpoint`.
226
+ With `type: "url"`, the portal fetches the schema via introspection at build
227
+ time, and the playground sends operations to that same URL by default. Point
228
+ `input` at the gateway route from the first half of this guide so readers run
229
+ real queries through your gateway — or keep the playground separate from the
230
+ schema source with `options.playground.endpoint`.
176
231
 
177
232
  Have a GraphQL schema definition language (SDL) file instead of a live
178
233
  endpoint? Use `type: "file"` and set `input` to the file's path (for example
@@ -184,7 +239,17 @@ project's working copy — it only works in projects
184
239
  You can register the plugin more than once to document several schemas, each
185
240
  with its own `path`.
186
241
 
187
- 3. **Link it in the navigation**
242
+ :::note
243
+
244
+ New projects ship with `@zudoku/plugin-graphql` in `dependencies` already.
245
+ Older projects might need to add it to `docs/package.json`. The plugin
246
+ requires `zudoku` version `0.80.1` or newer.
247
+ [Update the Dev Portal](../dev-portal/updating.mdx) to get the latest
248
+ version.
249
+
250
+ :::
251
+
252
+ 2. **Link it in the navigation**
188
253
 
189
254
  Point a navigation link at the instance's `path`. Set `stack: true` so the
190
255
  API's own pages render as a stacked sub-navigation instead of expanding
@@ -254,6 +319,8 @@ playground runs operations against your configured endpoint.
254
319
  introspection policies
255
320
  - [Testing GraphQL queries](./testing-graphql.mdx) — test the endpoint from the
256
321
  Zuplo Portal or external tools
322
+ - [GraphQL analytics](../analytics/tabs/graphql.md) — monitor operation volume,
323
+ latency, and error classes once traffic flows
257
324
  - [URL Rewrite handler](../handlers/url-rewrite.mdx) — full reference for the
258
325
  handler GraphQL routes use
259
326
  - [MCP Server GraphQL endpoints](../mcp-server/graphql.mdx) — expose GraphQL
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zuplo",
3
- "version": "6.71.0",
3
+ "version": "6.71.2",
4
4
  "type": "module",
5
5
  "description": "The programmable API Gateway",
6
6
  "author": "Zuplo, Inc.",
@@ -19,9 +19,9 @@
19
19
  "zuplo": "zuplo.js"
20
20
  },
21
21
  "dependencies": {
22
- "@zuplo/cli": "6.71.0",
23
- "@zuplo/core": "6.71.0",
24
- "@zuplo/runtime": "6.71.0",
22
+ "@zuplo/cli": "6.71.2",
23
+ "@zuplo/core": "6.71.2",
24
+ "@zuplo/runtime": "6.71.2",
25
25
  "@zuplo/test": "1.4.0"
26
26
  }
27
27
  }