Skip to content
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

[2.0] Import graphql-extensions and apollo-engine-reporting and avoid global apollo-server-env #1259

Merged
merged 123 commits into from
Jun 27, 2018

Conversation

martijnwalraven
Copy link
Contributor

@martijnwalraven martijnwalraven commented Jun 27, 2018

This PR imports graphql-extensions and apollo-engine-reporting into this monorepo. It adjusts dependencies and configuration to make sure everything compiles and tests are able to run.

It also ensures explicit imports from apollo-server-env are used for fetch and URL types, instead of relying on these being set on the global environment. This avoids type conflicts when people compile their projects with similar global types (like those from the dom lib).

Unfortunately, apollo-fetch (used in tests) and graphql-request (a dependency of GraphQL Playground) still rely on global fetch. So I've had to add back the dom lib to tsconfig.json for the packages that depend on those. This shouldn't affect anything at runtime, but we should still find a better solution for this.

I also had to jump through some hoops to get the apollo-datasource-rest tests to use a mocked version of apollo-server-env (so we can get a mocked fetch). Setting the Jest roots let to an unfortunate side effect: all tests in dependent packages also run. As a workaround, I adjusted testRegex to include the package name, but that feels like a hack.

martijnwalraven and others added 30 commits June 25, 2018 19:30
* dev: Update TypeScript to latest version, v2.7.2.

* dev: Update `graphql` to latest version, v0.13.2.

* dev: Update jest & dependencies to latest versions.

* dev: Update type definitions for `graphql`, `node` and `jest`.
)

In some cases, it's conceivable that the `format()` method may need to abort
its decision to provide extension information at runtime, in the event that
it doesn't have the proper information to return a full-result.

The `format` method already removed false-y results, so this simply changes
the types to allow the same.
Makes my editor integration happier (a bugfix in tsserver I think)
Same configuration as apollo-engine-js
It's not hard to consistently pass in an actual extension object to this
low-level API.
This is a backwards-incompatible change: GraphQLExtension implementations and
users of GraphQLExtensionStack (ie apollo-server-core) must change their
implementations, if they implement any of the xDidStart/xDidEnd APIs.

This allows "didEnd" handlers to refer to closure variables from the "didStart"
handler rather than needing to store state on the extension.

The new "didEnd" handlers run in the opposite order of the "didStart" handlers,
so that they properly nest.
@evans evans force-pushed the server-2.0/avoid-global-env branch 6 times, most recently from ac10e22 to e413f2d Compare June 27, 2018 22:42
@evans evans force-pushed the server-2.0/avoid-global-env branch from e413f2d to b654b5b Compare June 27, 2018 22:47
@evans evans force-pushed the server-2.0/avoid-global-env branch from 1dc3459 to 9fa227c Compare June 27, 2018 23:06
@evans evans merged commit c2e4dfb into version-2 Jun 27, 2018
@evans evans deleted the server-2.0/avoid-global-env branch June 27, 2018 23:29
@evans
Copy link
Contributor

evans commented Jun 27, 2018

@martijnwalraven Thank you! There seemed to be a large amount of noise in the commits, so I decided to squash

@evans evans mentioned this pull request Jun 29, 2018
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants