-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move apollo-engine-reporting
signatures into apollo-graphql
.
#2259
Conversation
As of this commit, this package provides nothing!
…graphql`. Many of these signature calculation functions are now utilized in tools or helpers which are not directly related to `apollo-server` functionality, including various aspects of the `apollo` CLI which live within `apollo-tooling`. Currently, because of `apollo`'s dependency on `apollo-engine-reporting` for this signature, this requires bringing in the entire dependency tree which `apollo-server-core` relies on since `apollo-engine-reporting` depends on `apollo-server-core`. By moving this into this new `apollo-graphql` utility library, we're able to trim that rather hefty dependency tree and drastically reduce the download for running, say, `npx apollo`.
Moving this out of the reporting package sounds like a great idea. A few thoughts:
|
…odule. These AST visitors and transformations are more generally usable for other purposes rather than just the Apollo Engine signature reporting and would seem to belong in a module of their own.
Currently, the only place that we use `lodash` in the entire `apollo-server` repository is to utilize the `sortBy` function in this signature generation. Looking at the bundle stats, it appears that lodash represents 7.1% of the `apollo-server` package. We're a server, so bundle size is generally less of a concern, but it's still not to be ignored, particularly as we move into worker environments. More pressingly though, since this package will be utilized by the `apollo` CLI, we'll be shaving precious download time off the invocation of `npx apollo` if we can get this down. By switching to the modular package (but still depending on `@types/lodash` for _just_ the `ListIteratee` type — which we only need in development — we should be able to trim 55.4kB minified (19.1kB minified+gzip'd) off the `apollo-server` build. cc @trevor-scheer @jbaxleyiii @martijnwalraven
7662d53
to
e84aca2
Compare
Concretely, once published and consumed this solves an undesired dependency on We can explore moving formatting functions into another package if it makes sense but there are more concrete plans (which, admittedly, are yet to be fully publicized and finalized) for this package aside from it being a home for signature algorithms, which is certainly not its sole purpose. |
As of #2259, the signature normalization transformations no longer live in `apollo-engine-reporting`. They now live in `apollo-graphql` which allows us to drop a large portion of the dependency tree since `apollo-engine-reporting` currently depends on `apollo-server-core` for its type definitions. We'll use path-based imports at the moment because not everything is exported from the main module of `apollo-graphql` (intentionally).
As of #2259, the signature normalization transformations no longer live in `apollo-engine-reporting`. They now live in `apollo-graphql` which allows us to drop a large portion of the dependency tree since `apollo-engine-reporting` currently depends on `apollo-server-core` for its type definitions. We'll use path-based imports at the moment because not everything is exported from the main module of `apollo-graphql` (intentionally).
As of #2259, the signature normalization transformations no longer live in `apollo-engine-reporting`. They now live in `apollo-graphql` which allows us to drop a large portion of the dependency tree since `apollo-engine-reporting` currently depends on `apollo-server-core` for its type definitions. We'll use path-based imports at the moment because not everything is exported from the main module of `apollo-graphql` (intentionally).
Many of these signature calculation functions are now utilized in tools or helpers which are not directly related to
apollo-server
functionality, including various aspects of theapollo
CLI which live within theapollo-tooling
repository.Currently, because of
apollo
's dependency onapollo-engine-reporting
forthis signature, this requires bringing in the entire dependency tree since
apollo-engine-reporting
depends onapollo-server-core
.By moving this into this new
apollo-graphql
utility library, we're able to trim that rather hefty dependency tree and drastically reduce the download for running, say,npx apollo
.Furthermore, this PR makes the additional change of switching to the modular
lodash.sortby
package instead of using the whole oflodash
. (The only place we uselodash
in the entireapollo-server
repository is to utilize the
sortBy
function for this signature generation.)Looking at the bundle stats, it appears that
lodash
represents 7.1% of theapollo-server
package. We're a server, so bundle size is generally less of a concern, but it's still not to be ignored and it's something we want to work on, particularly as we move into worker environments. But, back to the immediate concern about theapollo
CLI, since this package will be utilized by theapollo
CLI, we'll be shaving additional precious download time off the invocation ofnpx apollo
if we can get this down.We'll still depend on
@types/lodash
for just theListIteratee
type (since the modular packages don't provide thelodash/common
types) and we should be able to trim 55.4kB minified (19.1kB minified+gzip'd) off theapollo-server
build.cc @trevor-scheer @jbaxleyiii @martijnwalraven