Commit graph

328 commits

Author SHA1 Message Date
Martijn Walraven
68b2c691f8 Move test tsconfig.json files under __tests__ to support editors
The TypeScript language server looks for `tsconfig.json` and doesn't take project references into account when resolving the config for a file.

See https://github.com/Microsoft/TypeScript/issues/27372.
2018-10-11 23:10:45 +02:00
Martijn Walraven
3cf067349b Fix some dependencies in tsconfig.test.json files 2018-10-11 23:10:45 +02:00
Martijn Walraven
0491af858d Avoid use of object spread in Jest config files to support Node 6 2018-10-11 23:10:09 +02:00
Martijn Walraven
cef701e6c1 Remove test dependencies from non-test tsconfig.json files 2018-10-11 12:58:03 +02:00
Martijn Walraven
f5d5981ffc Add TypeScript and Jest projects for tests in individual packages 2018-10-11 04:33:23 +02:00
Jesse Rosenberger
9089cc5c94
Follow-up un-reverted work to maintain support in the new request pipeline.
Prior to embarking on the request pipeline work, and to facilitate
development on the new request pipeline, @martijnwalraven and myself
intentionally reverted some commits that had been recently introduced but
conflicted with the request pipeline branch that was already in-flight.

Rather than dealing with an incredibly difficult merge conflict, it was
easier to revert them an re-apply them later.

Original commits, reversions, and reintroductions:

* 6d6c9ff, 03a894d, b90ccc2
* 96af44e, 68c82e6, 81c4642
* 408198e, 2b470e1, 84bc834
* 4175f1b, 38e7b6a, 261994c

As is demonstrated by this short follow-up commit, this was all that was
necessary to make it work in the new model - once that model was finished.

While we're certain that the new request pipeline and its plugin model will
actually better support some of the behavior that required these initial
commits in the name of not introducing breaking changes, we feel it's
necessary to maintain their support.

I will point out, if you are at all affected by the above commits, we may
consider deprecating portions of those APIs in the not too distant future,
but we hope that the new model will help support those needs even better.
2018-10-10 20:20:27 +03:00
C.J. Winslow
84bc8346cc
Pass the context request and response extension methods (#1547)
* Pass the context along to all the extension methods

Addresses #1343

With this change you should now be able to implement an extension like so:

```javascript
class MyErrorTrackingExtension extends GraphQLExtension {
    willSendResponse(o) {
        const { context, graphqlResponse } = o

        context.trackErrors(graphqlResponse.errors)

        return o
    }
}
```

Edit by @evans :
fixes #1343
fixes #614 as the request object can be taken from context or from requestDidStart
fixes #631 ""

* Remove context from extra extension functions

The context shouldn't be necessary for format, parse, validation, and
execute. Format generally outputs the state of the extension. Parse and
validate don't depend on the context. Execution includes the context
argument as contextValue

* Move change entry under vNext
2018-10-10 19:25:37 +03:00
Martijn Walraven
17ed84d720 Add queryHash to request context 2018-10-10 16:20:45 +02:00
Martijn Walraven
f4400ac8af Rename dispatcher methods to clarify they invoke hooks 2018-10-10 16:17:10 +02:00
Martijn Walraven
b4863f65e9 Compute query hash for non-APQ queries to use as a cache key 2018-10-10 16:05:04 +02:00
Martijn Walraven
3fab039c1c Add didResolveOperation hook to request pipeline API 2018-10-10 15:19:11 +02:00
Martijn Walraven
f942af77b2 Clean up APQ code a little bit 2018-10-10 14:13:52 +02:00
Martijn Walraven
cea6404e92 Improve type safety of request pipeline API 2018-10-10 08:20:27 +02:00
Martijn Walraven
0f6594ae8e Don't skip APQs if no query is passed in 2018-10-09 21:37:29 +02:00
Martijn Walraven
59bc1c9318 Fix some request pipeline types 2018-10-09 21:35:51 +02:00
Martijn Walraven
e40f4a2b9b Add additional lifecycle hooks and allow returning didEnd handlers 2018-10-09 17:29:21 +02:00
Martijn Walraven
5b1760d78a Update graphql-subscriptions dependency to 1.0.0 in all packages 2018-10-09 12:18:25 +02:00
Martijn Walraven
b5715410fb Merge remote-tracking branch 'origin/master' into abernix/re-new-request-pipeline 2018-10-09 11:30:16 +02:00
renovate[bot]
ebe8b39d3b chore(deps): update dependency graphql-tools to v4 (#1771) 2018-10-09 11:27:59 +02:00
Martijn Walraven
00e9838c66 Move shared type definitions to top-level types directory 2018-10-08 21:15:55 +02:00
Martijn Walraven
a12673a432 WIP of passing through plugins to pipeline and calling lifecycle methods 2018-10-08 14:25:32 +02:00
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
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
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
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