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
Don't install the usage reporting plugin by default in subgraphs (#7184)
The usage reporting plugin is designed for monolithic graphs and
Gateways, not for subgraphs. You will get strange results in
GraphOS/Studio if you send usage reports from a subgraph to Studio. This
PR changes the defaults so that subgraphs do not automatically install
the usage reporting plugin even if API key and graph ref are provided;
in this case, a warning is logged.
You still can explicitly install ApolloServerPluginUsageReporting in
subgraphs, though a warning will be logged.
Fixes#7121.
Also, update terminology around subgraphs. Various log messages and
internal
symbol names and comments referred to "federated service" rather than
the
newer and clearer "subgraph".
Co-authored-by: Danielle Man <[email protected]>
Co-authored-by: Trevor Scheer <[email protected]>
Don't automatically install the usage reporting plugin in servers that appear to be hosting a federated subgraph (based on the existence of a field `_Service.sdl: String`). This is generally a misconfiguration. If an API key and graph ref are provided to the subgraph, log a warning and do not enable the usage reporting plugin. If the usage reporting plugin is explicitly installed in a subgraph, log a warning but keep it enabled.
Copy file name to clipboardExpand all lines: docs/source/api/plugin/usage-reporting.mdx
+9-3Lines changed: 9 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,16 +5,20 @@ api_reference: true
5
5
6
6
Apollo Server's built-in usage reporting plugin gathers data on how your clients use the operations and fields in your GraphQL schema. The plugin also handles pushing this usage data to [Apollo Studio](/studio/), as described in [Metrics and logging](../../monitoring/metrics/).
7
7
8
+
This plugin is designed to be used in an Apollo Gateway or in a monolithic server; it is not designed to be used from a subgraph. In a supergraph running Apollo Federation, the Apollo Gateway or Apollo Router will send usage reports to Apollo's cloud. Subgraphs don't need to also send usage reports to Apollo's cloud; instead, they send it to the Router via [inline traces](./inline-trace/) and the Router combines execution information across all subgraphs and sends summarized reports to the cloud.
9
+
8
10
## Default installation
9
11
10
12
> 📣 **New in Apollo Server 4**: error details are not included in traces by default. For more details, see [Error Handling](../../data/errors/#masking-and-logging-errors).
11
13
12
-
Apollo Server automatically installs and enables this plugin with default settings if you [provide a graph API key and a graph ref to Apollo Server](../../monitoring/metrics/#connecting-to-apollo-studio). You usually do this by setting the `APOLLO_KEY` and `APOLLO_GRAPH_REF` (or `APOLLO_GRAPH_ID` and `APOLLO_GRAPH_VARIANT`) environment variables. No other action is required.
14
+
Apollo Server automatically installs and enables this plugin with default settings if you [provide a graph API key and a graph ref to Apollo Server](../../monitoring/metrics/#connecting-to-apollo-studio) and your server is not a federated subgraph. You usually do this by setting the `APOLLO_KEY` and `APOLLO_GRAPH_REF` (or `APOLLO_GRAPH_ID` and `APOLLO_GRAPH_VARIANT`) environment variables. No other action is required.
13
15
14
-
If you don't provide an API key and graph ref, this plugin is not installed.
16
+
If you don't provide an API key and graph ref, or if your server is a federated subgraph, this plugin is not automatically installed.
15
17
16
18
If you provide an API key but _don't_ provide a graph ref, a warning is logged. You can [disable the plugin](#disabling-the-plugin) to hide the warning.
17
19
20
+
If you provide an API key and graph ref but your server _is_ a federated subgraph, a warning is logged. You can [disable the plugin](#disabling-the-plugin) to hide the warning.
21
+
18
22
## Custom installation
19
23
20
24
If you want to configure the usage reporting plugin, import it and pass it to your `ApolloServer` constructor's `plugins` array:
@@ -38,6 +42,8 @@ const server = new ApolloServer({
38
42
39
43
</MultiCodeBlock>
40
44
45
+
> While you can install the usage reporting plugin in a server that is a federated subgraph, this is not recommended, and a warning will be logged.
46
+
41
47
Supported configuration options are listed below.
42
48
43
49
#### Options
@@ -529,4 +535,4 @@ const server = new ApolloServer({
529
535
530
536
</MultiCodeBlock>
531
537
532
-
This also disables the warning log if you provide an API key but do not provide a graph ref.
538
+
This also disables the warning log if you provide an API key but do not provide a graph ref, or if you provide an API key and graph ref and your server is a federated subgraph.
Copy file name to clipboardExpand all lines: docs/source/migration.mdx
+9Lines changed: 9 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1743,6 +1743,15 @@ new ApolloServer({
1743
1743
1744
1744
(As [described above](#rewriteerror-plugin-option), the `rewriteError` option has been replaced by a `transform` option on `sendErrors` or `includeErrors`.)
1745
1745
1746
+
1747
+
### Usage reporting plugin is off by default on subgraphs
1748
+
1749
+
In an Apollo Federation supergraph, your Apollo Gateway or Apollo Router sends [usage reports](./api/plugin/usage-reporting/) to Apollo's servers; information about what happens inside individual subgraph servers is sent from the subgraphs to the Gateway or Router via [inline traces](./api/plugin/inline-trace/). That is to say: the usage reporting plugin is *not* designed for use in federated subgraphs.
1750
+
1751
+
In Apollo Server 3, if you provide an Apollo API key and graph ref and do not explicitly install the `ApolloServerPluginUsageReporting` or `ApolloServerPluginUsageReportingDisabled` plugins, the `ApolloServerPluginUsageReporting` plugin will be installed with its default configuration, even if the server is a subgraph.
1752
+
1753
+
In Apollo Server 4, this automatic installation does not occur in federated subgraphs. You still can explicitly install `ApolloServerPluginUsageReporting` in your subgraph, though this is not recommended and a warning will be logged.
1754
+
1746
1755
## Renamed packages
1747
1756
1748
1757
The following packages have been renamed in Apollo Server 4:
0 commit comments