Commit graph

1116 commits

Author SHA1 Message Date
Andre Eberhardt
b640be4fe6 feature(apollo-engine-reporting): Add custom http agent support (#1879)
This PR fixes #1836.

This PR enables developers to inject the http agent to be used on the network requests to apollo engine endpoint.

<!--
  Thanks for filing a pull request on GraphQL Server!

  Please look at the following checklist to ensure that your PR
  can be accepted quickly:
-->

TODO:

* [x] Update CHANGELOG.md with your change (include reference to issue & this PR)
* [x] Make sure all of the significant new logic is covered by tests
* [x] Rebase your changes on master so that they can be merged easily
* [x] Make sure all tests and linter rules pass

<!--**Pull Request Labels**

While not necessary, you can help organize our pull requests by labeling this issue when you open it.  To add a label automatically, simply [x] mark the appropriate box below:

- [ ] feature
- [ ] blocking
- [ ] docs

To add a label not listed above, simply place `/label another-label-name` on a line by itself.
-->
2018-10-26 20:14:18 +03:00
Jesse Rosenberger
c229b93f59 Fix incorrect comment about which graphql-playground- version this is.
It's actually the version of `graphql-playground-react` which is getting
served by `graphql-playground-html`.
2018-10-26 20:02:04 +03:00
Jesse Rosenberger
517264d579 Update to GraphQL Playground 1.7.8.
In addition to updating the `@apollographql/graphql-playground-html` fork,
which is necessary to avoid bundling `graphql-config` which had been
problematic in serverless environments, this updates the version number
which is served from the CDN.

I've just published `@apollographql/graphql-playground-html@1.6.4`.

Ref: https://github.com/apollographql/apollo-server/issues/1746
Ref: https://github.com/apollographql/graphql-playground/pull/2
Ref: https://github.com/apollographql/graphql-playground/pull/1

Thanks for @javlund for kicking off some of this work!
2018-10-26 20:02:04 +03:00
Jesse Rosenberger
1f8570b21d (test) Ensures the willStart event is triggered before a request. 2018-10-26 15:07:13 +03:00
Jesse Rosenberger
7dd30a62ed Remove incorrect comment: The health path is not the same as Engine.
Engine uses `engine-health` and this uses `server-health`.  They are
different!
2018-10-26 15:07:13 +03:00
Jesse Rosenberger
aae212f869 Triggers for newly introduced serverWillStart lifecycle hooks.
This commit follows-up on #1795, which introduced the new request pipeline, and
implements the triggers for its new life-cycle hooks within the various
integration packages.  Previously, the only implementation was within the
`apollo-server` package and didn't get triggered for those invoking the
`applyMiddleware` method on integrations (e.g. `apollo-server-express`,
`...-hapi` and `...-koa`).

While in an ideal world, ALL existing `applyMiddleware` functions would be
marked as `async` functions and allow us to `await ApolloServer#willStart`,
in practice the only `applyMiddleware` which is currently `async` is the one
within the Hapi implementation.  Therefore, we'll instead kick off the
`willStart` lifecycle hook as soon as `applyMiddleware` is started, return
as quickly as we have before and then (essentially) yield the completion of
Apollo Server's `willStart` prior to serving the first request — thus
ensuring the completion of server-startup activities.

Similarly, we'll do the same for `createHandler` methods on integrations
which don't utilize Node.js server frameworks but don't have `async`
handlers (e.g. AWS, Lambda, etc.).
2018-10-26 15:07:13 +03:00
Jesse Rosenberger
50a76d1786 Change types of the Google Cloud Funcs handler to allow options-as-a-function.
In the same manner as AWS Lambda, this now utilizes the
`ServerOptionsFunction` type pattern.  Previously, this typing still appears
to be incorrect, but that incorrectness was being missed because the
sole invocation of this at the end of this integrations `createHandler`
method was utilizing `this.createGraphQLServerOptions.bind(this)`, whose
types were unable to be inferred.  (I'm making a slight assumption on this
last bit because this mis-typing only surfaced after I switched to a more
explicit notation, but I believe this to be true).
2018-10-26 15:07:13 +03:00
Jan Hartmann
458bc71ead Enables parsing of application/hal+json as JSON in RESTDataSource (#1853) 2018-10-26 05:14:00 +02:00
Martijn Walraven
c1b0af18be
Add delete method to mock cache in integration tests 2018-10-25 14:40:57 +03:00
Jesse Rosenberger
4bad240ae4
Add delete implementations to the various cache store implementations. (#1878)
Includes:

* InMemory
* Redis
* Memcached
2018-10-25 14:32:14 +03:00
renovate[bot]
d35acecc38 chore(deps): update dependency koa to v2.6.1 (#1873) 2018-10-25 13:37:39 +03:00
Martijn Walraven
e5b0b57ef0 Avoid ReferenceError when accessing app in browser-like environments
Fixes #1804.
2018-10-16 16:40:49 +02:00
Martijn Walraven
6dd71d3824 Replace GraphQLRequestPipeline with function 2018-10-16 13:59:30 +02:00
Martijn Walraven
71b1ae4242 Export GraphQL request and reponse types from apollo-server-plugin-base 2018-10-15 12:42:09 +02:00
Martijn Walraven
2385558bea Fix types in apollo-cache-control test helper 2018-10-12 14:13:21 +02:00
Jesse Rosenberger
9a69ad3f3a
Merge branch 'master' into testing-improvements 2018-10-12 14:58:04 +03:00
Martijn Walraven
4fac07b8f1 Consistently leave out explicit tsconfig.json when referring to TypeScript project 2018-10-12 13:34:07 +02:00
Martijn Walraven
ad3562a335 Replace {} with Object.create(null) in jest.config.js 2018-10-12 13:00:13 +02:00
Martijn Walraven
2a2e3ffe4f Improve global fetch type 2018-10-12 11:23:53 +02:00
Martijn Walraven
823d68d318 Work around typing issue with promisified Redis client 2018-10-12 11:13:45 +02:00
Martijn Walraven
fd34771841 Fix typing issues in handler arguments and introduce generic type
These issues became apparent because `typescript@next` correctly types `Function#bind` instead of returning `any`.
2018-10-12 10:46:07 +02:00
Martijn Walraven
d6b222da91 Depend on output of requestPipelineAPI project instead of source 2018-10-12 09:46:49 +02:00
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
304074f336 Expose global fetch and URL types to avoid relying on dom lib 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
68f4e83fb2 Fix import in apollo-cache-control 2018-10-11 20:17:37 +02:00
Martijn Walraven
9e843dbf4b Fix apollo-cache-control tests by augmenting schemas with cache control support 2018-10-11 15:05:06 +02:00
Martijn Walraven
787846c64b Fix apollo-server-env mock 2018-10-11 14:43:29 +02:00
Martijn Walraven
cef701e6c1 Remove test dependencies from non-test tsconfig.json files 2018-10-11 12:58:03 +02:00
renovate[bot]
73cbd03be0 chore(deps): update dependency @types/ws to v6 (#1609) 2018-10-11 12:05:19 +03:00
Martijn Walraven
6796ff310b Add paths config for shared __mocks__ to avoid relative imports 2018-10-11 08:20:49 +02:00
Martijn Walraven
f5d5981ffc Add TypeScript and Jest projects for tests in individual packages 2018-10-11 04:33:23 +02:00
Martijn Walraven
1ccef23906 Remove some empty tests 2018-10-11 04:11:49 +02:00
Martijn Walraven
ad758567b1 Rename apollo-cache-control tests so they will be picked up
It turns out we weren't running these tests before because they didn't end in `.test.ts`.
2018-10-11 04:10:51 +02:00
Jesse Rosenberger
dec2b94a0e
Publish
- apollo-cache-control@0.3.0-alpha.0
 - apollo-datasource-rest@0.2.0-alpha.0
 - apollo-datasource@0.2.0-alpha.0
 - apollo-engine-reporting-protobuf@0.1.0-alpha.0
 - apollo-engine-reporting@0.1.0-alpha.0
 - apollo-server-cache-memcached@0.2.0-alpha.0
 - apollo-server-cache-redis@0.2.0-alpha.0
 - apollo-server-caching@0.2.0-alpha.0
 - apollo-server-cloud-functions@2.2.0-alpha.0
 - apollo-server-cloudflare@2.2.0-alpha.0
 - apollo-server-core@2.2.0-alpha.0
 - apollo-server-env@2.1.0-alpha.0
 - apollo-server-errors@2.1.0-alpha.0
 - apollo-server-express@2.2.0-alpha.0
 - apollo-server-hapi@2.2.0-alpha.0
 - apollo-server-integration-testsuite@2.2.0-alpha.0
 - apollo-server-koa@2.2.0-alpha.0
 - apollo-server-lambda@2.2.0-alpha.0
 - apollo-server-micro@2.2.0-alpha.0
 - apollo-server-plugin-base@0.1.0-alpha.0
 - apollo-server@2.2.0-alpha.0
 - apollo-tracing@0.3.0-alpha.0
 - graphql-extensions@0.3.0-alpha.0
2018-10-10 22:30:54 +03: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
960810c3f2 Remove jest types from tsconfig.base and add it to test configs 2018-10-09 12:02:11 +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