Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Inline usage reporting protobuf into main package (#6515)
Keeping it separate mostly just means we have to worry about version skew. It doesn't let us avoid the protobufjs dependency (it was just transitive). Other packages that may need these types (like `@apollo/gateway`) will have a peer dependency on `@apollo/server` anyway. Note that this package consists of .js and .d.ts files that are not generated from .ts files, so they exist outside of `src`. We ensure they end up in the published package via a change to `.npmignore`. As before, the only code that can import the protobuf code should be tests, `import type`s, or code under `src/plugin` that is only evaluated if the plugin is actually used. Also fixes missing dependencies on cors and body-parser needed for the standalone server. (As part of #6243 we may make sure that these are only needed if you actually import the standalone server directory.) Fixes #6510.
- Loading branch information
Showing
31 changed files
with
1,443 additions
and
4,774 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ src/**/__tests__/** | |
dist/**/__tests__/** | ||
!package.json | ||
!README.md | ||
!usageReportingProtobuf/**/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/server/src/__tests__/plugin/usageReporting/stats.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/server/src/__tests__/plugin/usageReporting/traceDetails.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/server/src/plugin/usageReporting/defaultSendOperationsAsTrace.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Usage reporting protobuf | ||
|
||
> **Note:** The Apollo usage reporting API is subject to change. We strongly | ||
> encourage developers to contact Apollo support at `support@apollographql.com` | ||
> to discuss their use case prior to building their own reporting agent using | ||
> this module. | ||
This subdirectory provides JavaScript/TypeScript [Protocol | ||
buffer](https://developers.google.com/protocol-buffers/) definitions for the | ||
Apollo usage reporting API. These definitions are generated for consumption | ||
from the `reports.proto` file which is defined internally within Apollo. | ||
|
||
## Development | ||
|
||
> **Note:** Due to a dependency on Unix tools (e.g. `bash`, `grep`, etc.), the | ||
> development of this module requires a Unix system. There is no reason why | ||
> this can't be avoided, the time just hasn't been taken to make those changes. | ||
> We'd happily accept a PR which makes the appropriate changes! | ||
This directory contains .js and .d.ts files. The index files are written | ||
manually and the files in `generated` are automatically generated with | ||
`@apollo/protobufjs` (a fork of | ||
[`protobufjs`](https://www.npmjs.com/package/protobufjs) that we maintain | ||
specifically for this package) based on the `reports.proto` file. None of these | ||
files are generated from .ts files by tsc, which is why this directory is not | ||
under `src`. | ||
|
||
To update `reports.proto` to the current version recognized by the Studio usage | ||
reporting ingress, run `npm run protobuf-update`. To then regenerate the JS and | ||
TS files, run `npm run protobuf-generate`. We check in the generated code and only | ||
regenerate it manually, partially to make builds faster (no need to run pbjs on | ||
every `npm install`) and partially so that we don't have to make sure that | ||
`pbjs` runs on every Node version that we support. | ||
|
||
The files in this subdirectory are large, so we want to avoid loading them at | ||
runtime unless necessary. Thus, files in this directory should only be imported | ||
in three contexts: | ||
- Inside `src/plugin`, in files that will only be loaded indirectly via the | ||
runtime require calls in `src/plugin/index.ts` | ||
- In tests | ||
- At compile-time only via `import type` calls |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import * as protobuf from './generated/protobuf'; | ||
export = protobuf; |
2 changes: 1 addition & 1 deletion
2
...ges/usage-reporting-protobuf/src/index.js → ...es/server/usageReportingProtobuf/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.