Commit graph

1011 commits

Author SHA1 Message Date
Martijn Walraven
f11914ac71 Type plugin definitions and invoke serverWillStart with service context 2018-10-08 13:50:47 +02:00
Martijn Walraven
c28e3e2087 Add note about http property in GraphQLRequest needing to be optional 2018-10-08 11:16:47 +02:00
Martijn Walraven
ba61960430 Clean up passing throughhttp property in GraphQLResponse 2018-10-08 11:03:01 +02:00
Martijn Walraven
5281f3f98f Introduce request context and refactor pipeline code 2018-10-07 18:23:27 +02:00
Martijn Walraven
f4d3a37f78 Fix failing tests by passing in structured engine apiKey
Since activating the EngineReportingAgent is now dependent on being able to extract an engineServiceId from the API key, tests need to specify one that follows the expected structure.
2018-10-06 08:39:39 +02:00
Martijn Walraven
e928adfdfc Simplify plugin API and fix circular dependency issues
We compile `requestPipelineAPI.ts` as a separate TypeScript project to avoid circular dependency issues from the `apollo-server-plugin-base` package depending on the types in `apollo-server-core`.
2018-10-06 06:59:32 +02:00
Martijn Walraven
482a32008d Fix new type error in TypeScript 3.1 with explicit cast 2018-10-06 04:56:19 +02:00
Martijn Walraven
282ea7e022 Merge remote-tracking branch 'origin/typescript-project-references' into abernix/re-new-request-pipeline 2018-10-06 03:49:36 +02:00
Martijn Walraven
11a13cd3dd Remove apollo-server-env as a project reference
We can't use `apollo-server-env` as a project reference because that requires `composite: true`, and that implies `declaration: true`, which doesn't work for `apollo-server-env` because we need to write our own declaration files for re-exported imports.

This commit also removes `apollo-engine-reporting-protobuf` as a reference, which errored out because it doesn't actually contain any TypeScript code.
2018-10-05 23:05:49 +02:00
Martijn Walraven
8932091e67 Add root level tsconfig.json as entry point 2018-10-05 21:48:49 +02:00
Martijn Walraven
1aee215e68 Switch to tsc --build and remove run scripts from packages 2018-10-05 17:48:34 +02:00
Martijn Walraven
fcaa6ad79d Enable TypeScript project references 2018-10-05 17:47:29 +02:00
Martijn Walraven
5d03ae1650 Update to TypeScript 3.1 2018-10-05 17:18:13 +02:00
Martijn Walraven
f051c7cb80 Add comment about cloning the context 2018-10-05 16:30:21 +02:00
Jesse Rosenberger
d7d7b0babd
Merge branch 'abernix/plugin-base' into abernix/re-new-request-pipeline 2018-10-05 16:27:34 +03:00
Martijn Walraven
87463582ed Fix cacheControl property in Config and GraphQLServerOptions
While cacheControl can take a boolean when passing it in  to ApolloServer as part of a Config, these will be converted to default options before passing them on as options.
2018-10-05 14:33:32 +02:00
Jesse Rosenberger
68f50cd09c Import specifically createHash, rather than * as crypto from crypto.
This silences the deprecation messages which have been showing up in recent
local development on the new request pipeline work.  e.g.:

> ```
> [DEP0010] DeprecationWarning: crypto.createCredentials is deprecated.
>   Use tls.createSecureContext instead.
> [DEP0011] DeprecationWarning:
>   crypto.Credentials is deprecated. Use tls.SecureContext instead.
> ```
2018-10-05 13:12:10 +02:00
Martijn Walraven
d80209e4aa Fix typing of context property in GraphQLServerOptions
The actual resolving of the context happens in ApolloServer#graphQLServerOptions, but errors thrown while doing that are currently converted to a throwing function.
2018-10-05 09:48:58 +02:00
Martijn Walraven
891d62983a Refactor runHttpQuery and extract cache policy computation into CacheControlExtension 2018-10-05 09:08:12 +02:00
Jesse Rosenberger
2479473664
Introduce basic plugin and limited API to apollo-server-core. 2018-10-04 23:25:42 +03:00
Jesse Rosenberger
1ec383db36
Introduce a method to simplify the Engine service identifier. 2018-10-04 23:25:42 +03:00
Jesse Rosenberger
94a146a07e
Introduce a apollo-server-plugin-base as a foundation for plugins. 2018-10-04 23:25:42 +03:00
Jesse Rosenberger
98d4fc3674
Don't ever allow requestOptions to be undefined. 2018-10-04 23:25:42 +03:00
Jesse Rosenberger
f1bc734377
Import specifically createHash, rather than * as crypto from crypto.
This silences the deprecation messages which have been showing up in recent
local development on the new request pipeline work.  e.g.:

> ```
> [DEP0010] DeprecationWarning: crypto.createCredentials is deprecated.
>   Use tls.createSecureContext instead.
> [DEP0011] DeprecationWarning:
>   crypto.Credentials is deprecated. Use tls.SecureContext instead.
> ```
2018-10-04 23:25:07 +03:00
Martijn Walraven
7493077f18 Fix context and rootValue types in GraphQLServerOptions
The ability to pass in functions or promises shouldn't affect the type variable.
2018-10-02 14:00:34 +02:00
Martijn Walraven
ba0066edf8 Extract processHTTPRequest from runHttpQuery 2018-10-02 13:59:33 +02:00
Martijn Walraven
e2a22b23b5 Remove leftover debug output 2018-09-28 15:45:22 +02:00
Jesse Rosenberger
b90ccc2e8b
Make it more clear that generateClientInfo is an experimental API.
The `generateClientInfo` API, used to set client identification attributes
within traces, is an experimental API and is subject to removal or change in
a future (major) Apollo Server release.

Ref: #1631
2018-09-27 18:40:05 +03:00
Evans Hauser
81c46421a9
Provide ability to specify client info in traces (#1631)
* Provide ability to specify client info in traces

Adds the createClientInfo to apollo-engine-reporting, which enables the
differentiation of clients based on the request, operation, and
variables. This could be extended to include the response. However for
the first release. It doesn't quite make sense.

* Use extensions and context in createClientInfo

* Remove support for clientAddress

The frontend will not support it in the near future

* create -> generate and make default generator

createClientInfo -> generateClientInfo

* Clarify default values
2018-09-27 17:26:12 +03:00
Tim Griesser
261994ca7c
Allow an optional function to resolve the rootValue (#1555)
* Allow an optional function to resolve the rootValue

Passes the parsed DocumentNode AST to determine the root value,
useful when providing a different rootValue for query vs mutation

* Add API docs for rootValue
2018-09-27 16:57:46 +03:00
Martijn Walraven
7fbf35cc1c
Remove hash.js dependency and re-enable noUnusedLocals 2018-09-27 16:46:45 +03:00
Martijn Walraven
49248329ca
Move persisted query processing to GraphQLRequestProcessor 2018-09-27 16:46:45 +03:00
Martijn Walraven
faf1494a7f
Remove runQuery.ts and fix tests to use GraphQLRequestProcessor 2018-09-27 16:46:45 +03:00
Martijn Walraven
358b348677
Fix full lifecycle test with Engine reporting 2018-09-27 16:46:45 +03:00
Martijn Walraven
a09d514e59
Refactor runQuery into GraphQLRequestProcessor 2018-09-27 16:46:45 +03:00
Jesse Rosenberger
38e7b6a5b6
Revert "Allow an optional function to resolve the rootValue (#1555)"
This reverts commit 4175f1b9cd.
2018-09-27 16:46:39 +03:00
Jesse Rosenberger
2b470e1c11
Revert "Pass the context request and response extension methods (#1547)"
This reverts commit 408198e5ac.
2018-09-27 16:36:28 +03:00
Jesse Rosenberger
68c82e63c6
Revert "Provide ability to specify client info in traces (#1631)"
This reverts commit 96af44e41a.
2018-09-27 16:35:00 +03:00
Jesse Rosenberger
03a894de1a
Revert "Make it more clear that generateClientInfo is an experimental API."
This reverts commit 6d6c9ff268.
2018-09-27 16:33:30 +03:00
Jesse Rosenberger
126dac7d3c
prettier: The tragic reformatting associated with c9375c40.
Some changes are easier to mentally consume before they've been prettier'd.

While I'll certainly allow Prettier to do what it wants to do, I've confined
it's changes to this commit for easier reviewability.

Note to the reviewer: this commit is exactly the result of running the
`npm run lint-fix` command on a clean Git working tree.

Ref: c9375c405b
2018-09-26 22:46:49 +03:00
Jesse Rosenberger
c9375c405b
Adjust tests which are Node.js version specific to use describe.skip.
The techniques previously used to skip particular tests for particular
Node.js versions (for example, file uploads, Hapi, etc.) were problematic in
a couple ways:

1. `return`-ing outside a function (say, at the top level of a module) is
   not valid ECMAScript.  While it works in this current state, it only works
   because of Babel's wrapping scope.  As we move toward less and less
   transpiled modules, this would become problematic anyway, but it's a
   short-term blocker for me since I intend on dropping the `skipBabel` option
   we currently pass to` `ts-jest` in its current (`package.json`)
   configuration. (My editor also dislikes top-level `return`, expectedly.)

2. By `return`-ing from a test which we wish to skip conditionally, we avoid
   the awareness which is provided by Jest (automatically) when using its
   built-in `.skip` helpers.  By switching to technique I've employed here,
   we're able to see `<num> skipped` in Jest's output and (rightfully) be able
   to question why something is being skipped.

By using the `atLeastMajorNodeVersion` helper, we'll also be able to more
easily find where this pattern is used in test-cases, to more easily
re-evaluate their use-cases when we add support newer Node.js versions.
2018-09-26 22:44:32 +03:00
Jesse Rosenberger
8e594d47f5
Revert #1698 renovate/graphql tools 4.x (#1716)
I'm reverting apollographql/apollo-server#1698 not because it's been problematic in any way, but because I'd like to give it a bit more thought and don't want this to accidentally get cut into a release prior to that consideration.

More specifically: The `graphql-tools` update on its own shouldn't really cause any problems, but the [4.x version of `graphql-tools`](https://github.com/apollographql/graphql-tools/releases/tag/4.0.0) is intended to support and enable the latest `graphql@14` which contains [breaking changes](https://github.com/graphql/graphql-js/releases/tag/v14.0.0).

I believe most of those breaking changes would be show-stoppers and the failures would surface immediately (meaning that servers would completely fail to start, rather than being a surprise in other, more delayed scenarios), but it's still worth pausing and carefully considering versioning to avoid any surprises.

That said, the 14.x version of `graphql` has been an acceptable range in the `peerDependencies` of `apollo-server-*` since before its final release came out, and I don't believe we've caught wind of anything that a major version bump would have prevented or made more clear.  In the end, `graphql` is a peer dependency and any problems should only surface if consumers also update their `graphql` dependency — a clear major version bump, which deserves review by the upgrader — so perhaps we can avoid bumping the major version after all?

Input welcomed, but again, merging this now to give this a bit more thought first.

cc @hwillson
2018-09-24 20:47:18 +03:00
Hugh Willson
dd86fa8a29 Re-enable Typescript esModuleInterop (#1699)
`esModuleInterop` was enabled in
e4164c8892
to help with importing from packages that use default exports.
Those changes were reverted in
https://github.com/apollographql/apollo-server/pull/1210
to work around a few reported issues. Those issues are no longer
relevant, so this commit re-enables `esModuleInterop`, and
updates all default imports to use the more common (standard)
import syntax.
2018-09-21 16:43:33 +03:00
Tim Griesser
4175f1b9cd Allow an optional function to resolve the rootValue (#1555)
* Allow an optional function to resolve the rootValue

Passes the parsed DocumentNode AST to determine the root value,
useful when providing a different rootValue for query vs mutation

* Add API docs for rootValue
2018-09-20 11:47:40 -07:00
renovate[bot]
f2a4673006 chore(deps): update dependency graphql-tools to v4 (#1698) 2018-09-20 17:13:03 +03:00
Jesse Rosenberger
749538daee
Specify explicit cursorShape default for Playground options. (#1607)
* Specify explicit `cursorShape` to avoid missing cursor in GraphQL Playground.

This solves a problem with the text cursor caret not being visible in the
operation input box within GraphQL Playground by explicitly setting a
GraphQL Playground configuration option called `cursorShape` to `line`.

All credit for the actual solution goes to @lpellegr for their discovery in
https://github.com/prisma/graphql-playground/issues/790#issuecomment-409221277

* Update CHANGELOG.md
2018-09-20 17:12:11 +03:00
Jesse Rosenberger
6d6c9ff268
Make it more clear that generateClientInfo is an experimental API.
The `generateClientInfo` API, used to set client identification attributes
within traces, is an experimental API and is subject to removal or change in
a future (major) Apollo Server release.

Ref: #1631
2018-09-20 12:11:56 +03:00
Evans Hauser
86dd95e223
Publish
- apollo-cache-control@0.2.5
 - apollo-engine-reporting@0.0.6
 - apollo-server-cloud-functions@2.1.0
 - apollo-server-cloudflare@2.1.0
 - apollo-server-core@2.1.0
 - apollo-server-express@2.1.0
 - apollo-server-hapi@2.1.0
 - apollo-server-integration-testsuite@2.1.0
 - apollo-server-koa@2.1.0
 - apollo-server-lambda@2.1.0
 - apollo-server-micro@2.1.0
 - apollo-server@2.1.0
 - apollo-tracing@0.2.5
 - graphql-extensions@0.2.1
2018-09-18 15:26:48 -07:00
Marcel Miranda Ackerman
e949ab6a72 Updated Google Cloud Function request handler to handle null or undefined req.path (#1674)
* Updated request handler to handle null or undefined req.path

* Added test for GCF handling request.path being null

* Updated Changelog

* Add note about checking for null path
2018-09-18 14:04:01 -07:00
Jake Dawkins
f3df370b0a Fix header misreporting to engine (#1689)
* fix header reporting being cut short

* added changelog entry & fix npm version
2018-09-18 13:29:54 -07:00