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
- We've decided to leave the usage reporting defaults in AS4 as "field
level instrumentation on for all operations, send some operations as
traces". But we'd like to at least provide a non-experimental
mechanism for entirely disabling sending traces to Studio. So there's
a new ApolloServerPluginUsageReporting: `sendTraces: false`.
- Rename the (new in AS4) usage reporting option `sendErrorsInTraces` to
`sendErrors`, because it does also affect error statistics in stats
reports if your `transform` function returns `null`.
- Remove Apollo-internal `internal_includeTracesContributingToStats`
option. This enabled some internal consistency monitoring which we are
no longer paying attention to.
- If you enable `debugPrintReports`, send the reports as `info` rather
than `warn`, which primarily lets us delete some large comments (and
makes sense because these debug messages are not warnings).
Fixes#6051. Fixes #6078.
Copy file name to clipboardExpand all lines: docs/source/data/errors.mdx
+11-9Lines changed: 11 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -438,7 +438,7 @@ You can use Apollo Studio to analyze your server's error rates. By default, the
438
438
439
439
If you _do_ want error information sent to Studio, you can send every error, or you can modify or redact specific errors before they're transmitted.
440
440
441
-
To send all errors to Studio you can pass `{ unmodified: true }` to `sendErrorsInTraces`, like so:
441
+
To send all errors to Studio you can pass `{ unmodified: true }` to `sendErrors`, like so:
442
442
443
443
```ts {7}
444
444
newApolloServer({
@@ -447,23 +447,23 @@ new ApolloServer({
447
447
ApolloServerPluginUsageReporting({
448
448
// If you pass unmodified: true to the usage reporting
449
449
// plugin, Apollo Studio receives ALL error details
450
-
sendErrorsInTraces: { unmodified: true },
450
+
sendErrors: { unmodified: true },
451
451
}),
452
452
],
453
453
});
454
454
```
455
455
456
-
If you want to report specific errors or modify an error before reporting it, you can pass a function to the `sendErrorsInTraces.transform` option, like so:
456
+
If you want to report specific errors or modify an error before reporting it, you can pass a function to the `sendErrors.transform` option, like so:
457
457
458
458
```ts {4-6}
459
459
newApolloServer({
460
460
// etc.
461
461
plugins: [
462
462
ApolloServerPluginUsageReporting({
463
-
sendErrorsInTraces: {
463
+
sendErrors: {
464
464
transform: (err) => {
465
465
if (err.extensions.code==='MY_CUSTOM_CODE') {
466
-
// returning null will skip reporting this error
466
+
// returning null will skip reporting this error
467
467
returnnull;
468
468
}
469
469
@@ -483,6 +483,8 @@ The function you pass to `transform` is called for each error (`GraphQLError`) t
483
483
- Return a modified form of the error (e.g., by changing the `err.message` to remove potentially sensitive information)
484
484
- Return `null` to prevent the error from being reported entirely
485
485
486
+
Note that returning `null`` also affects Studio's aggregated statistics about how many operations contain errors and at what paths those errors appear.
487
+
486
488
[As mentioned above](#for-client-responses), you can use the `unwrapResolverError` (from `@apollo/server/errors`) to remove the `GraphQLError` wrapping an original error.
In Apollo Server 3, you can specify a function to rewrite errors before sending them to Apollo's server via the `rewriteError` option to `ApolloServerPluginUsageReporting` (for monoliths) and `ApolloServerPluginInlineTrace` (for subgraphs).
938
938
939
-
In Apollo Server 4, you specify the same function as the `transform` option on the `sendErrorsInTraces` option to `ApolloServerPluginUsageReporting` and the `includeErrors` option to `ApolloServerPluginInlineTrace`.
939
+
In Apollo Server 4, you specify the same function as the `transform` option on the `sendErrors` option to `ApolloServerPluginUsageReporting` and the `includeErrors` option to `ApolloServerPluginInlineTrace`.
940
940
941
941
(Additionally, the [default behavior has changed to mask errors](#usage-reporting-and-inline-trace-plugins-mask-errors-by-default).)
942
942
@@ -962,7 +962,7 @@ you can now write:
962
962
// monoliths
963
963
newApolloServer({
964
964
plugins: [ApolloServerPluginUsageReporting({
965
-
sendErrorsInTraces: { transform: rewriteError },
965
+
sendErrors: { transform: rewriteError },
966
966
})],
967
967
// ...
968
968
})
@@ -1599,7 +1599,7 @@ To restore the Apollo Server 3 behavior, you can pass `{ unmodified: true }` to
1599
1599
// monoliths
1600
1600
newApolloServer({
1601
1601
plugins: [ApolloServerPluginUsageReporting({
1602
-
sendErrorsInTraces: { unmodified: true },
1602
+
sendErrors: { unmodified: true },
1603
1603
})],
1604
1604
// ...
1605
1605
})
@@ -1613,7 +1613,7 @@ new ApolloServer({
1613
1613
})
1614
1614
```
1615
1615
1616
-
(As [described above](#rewriteerror-plugin-option), the `rewriteError` option has been replaced by a `transform` option on `sendErrorsInTraces` or `includeErrors`.)
1616
+
(As [described above](#rewriteerror-plugin-option), the `rewriteError` option has been replaced by a `transform` option on `sendErrors` or `includeErrors`.)
* - { transform: ... }: a custom function for modifying variable values. Keys added by the custom function will
23
-
* be removed, and keys removed will be added back with an empty value. For security reasons, if an error occurs within this function, all variable values will be replaced with `[PREDICATE_FUNCTION_ERROR]`.
24
-
* - { exceptNames: ... }: a case-sensitive list of names of variables whose values should not be sent to Apollo servers
25
-
* - { onlyNames: ... }: A case-sensitive list of names of variables whose values will be sent to Apollo servers
53
+
* - { transform: ... }: a custom function for modifying variable values. Keys
54
+
* added by the custom function will be removed, and keys removed will be
55
+
* added back with an empty value. For security reasons, if an error occurs
56
+
* within this function, all variable values will be replaced with
57
+
* `[PREDICATE_FUNCTION_ERROR]`.
58
+
* - { exceptNames: ... }: a case-sensitive list of names of variables whose
59
+
* values should not be sent to Apollo servers
60
+
* - { onlyNames: ... }: A case-sensitive list of names of variables whose
61
+
* values will be sent to Apollo servers
62
+
*
63
+
* Defaults to not sending any variable values if both this parameter and the
64
+
* deprecated `privateVariables` are not set. The report will indicate each
65
+
* private variable key whose value was redacted by { none: true } or {
66
+
* exceptNames: [...] }.
26
67
*
27
-
* Defaults to not sending any variable values if both this parameter and
28
-
* the deprecated `privateVariables` are not set. The report will
29
-
* indicate each private variable key whose value was redacted by { none: true } or { exceptNames: [...] }.
68
+
* The value of this option is not relevant if you set `sendTraces: false`,
69
+
* because variable values only appear in traces.
30
70
*/
31
71
sendVariableValues?: VariableValueOptions;
32
72
/**
33
-
* By default, Apollo Server does not send the list of HTTP headers and values
73
+
* By default, Apollo Server does not send the HTTP request headers and values
34
74
* to Apollo's servers, as these headers may contain your users' private data.
35
75
* If you'd like this information included in traces, set this option. This
0 commit comments