Commit graph

636 commits

Author SHA1 Message Date
Martijn Walraven
54a8fac80b RESTDataSource: Serialize request bodies that have a toJSON method as JSON 2018-07-11 14:31:32 -07:00
uosl
1022ae17ed RESTDataSource: Do not serialize body values that aren't objects (#1316) 2018-07-11 13:53:56 -07:00
Martijn Walraven
c200df05d3 RESTDataSource: Add data to errors thrown for error responses
Closes #1311.
2018-07-11 13:49:35 -07:00
Evans Hauser
de4760ba3b
Expose Cors option from vanilla ApolloServer constructor (#1335)
* add cors option to apollo-server's constructor

* docs: add cors option to costructor for apollo-server

* expose CorsOptions from vanilla and express integrations

* Update apollo-server.md
2018-07-11 13:46:51 -07:00
Gauthier Rodaro
ecc56690df RESTDataSource: add didReceiveResponse method (#1325) 2018-07-11 06:17:03 -07:00
Radu Achim
e83dcbc433 Round the ttl to an integer so that redis doesn't b0rk (#1323)
Fixes #1306.
2018-07-10 09:50:06 -07:00
Prosper Otemuyiwa
61b4939327
Enable GraphQLUpload for Apollo Server 2.0 (#1322)
* export GraphQLUpload

* fix GraphQLScalar typing
2018-07-10 05:36:34 +01:00
Evans Hauser
13b796fe34
Publish
- apollo-cache-control@0.2.0-rc.0
 - apollo-datasource-rest@2.0.0-rc.7
 - apollo-engine-reporting@0.0.0-rc.1
 - apollo-server-caching@2.0.0-rc.7
 - apollo-server-cloudflare@2.0.0-rc.7
 - apollo-server-core@2.0.0-rc.7
 - apollo-server-env@2.0.0-rc.7
 - apollo-server-errors@2.0.0-rc.7
 - apollo-server-express@2.0.0-rc.7
 - apollo-server-hapi@2.0.0-rc.7
 - apollo-server-integration-testsuite@2.0.0-rc.7
 - apollo-server-koa@2.0.0-rc.7
 - apollo-server-lambda@2.0.0-rc.7
 - apollo-server-memcached@2.0.0-rc.7
 - apollo-server-micro@2.0.0-rc.7
 - apollo-server-redis@2.0.0-rc.7
 - apollo-server@2.0.0-rc.7
 - apollo-tracing@0.2.0-rc.0
 - graphql-extensions@0.1.0-rc.1
2018-07-09 19:32:59 -07:00
Evans Hauser
e29f8048e4
Enable engine reporting in Lambda (#1313)
* add disableInterval option to engine reporting

* set engine options for lambda

* lambda: add comment on constructor

* lambda: update readme typo and include callout to use graphql.js

* disableInterval -> sendReportsImmediately

* use sendReportsImmediately correctly and fix compilation

* uses new Header to fix different header combination, fixes #1301

* add apollo-server-env dependency

* fix logic error in engine reporting
2018-07-09 19:29:05 -07:00
Martijn Walraven
f551e2bb44 Use apq prefix for persisted query caching 2018-07-09 19:28:21 -07:00
Martijn Walraven
9e60f42845 Use main cache for persisted queries by default 2018-07-09 19:25:09 -07:00
Martijn Walraven
f8feca870a Move lru-cache dependency to apollo-server-caching 2018-07-09 16:51:30 -07:00
Martijn Walraven
d01b18a704 Update GraphQL Playground version 2018-07-09 16:35:30 -07:00
C. T. Lin
dbaa465646 Apollo Server 2 Koa integration (#1282)
* koa integration

* use koa-bodyparser v3 for node 6 support

* use middlewareFromPath instead of koa-router

* use async/await in koa fileUploadMiddleware
2018-07-06 13:52:56 -07:00
Hugh Willson
c356bcf3f2 Apollo Server 2 Micro integration (#1279)
* Initial basic Micro integration

* Wire up health check capabilities

* Add playground support; Refactoring

* Add custom path support

* Add file upload support

* Add subscription support

* Documentation and formatting updates

* Wire up tests

* Add Node 10 workaround for file upload testing

* Code review changes (docs, naming, formatting)

* Adjust exports to line up with other integrations

* micro: add graphql to npm install and lines to highlight in docs
2018-07-05 11:40:15 -07:00
Martijn Walraven
94d4d4968c Use for-of loops instead of standard for loops 2018-07-04 22:31:55 +02:00
Martijn Walraven
4793c5ad7e Rename apollo-cache-control-js and apollo-tracing-js and unify configs 2018-07-04 22:26:28 +02:00
Martijn Walraven
4114bc5a0b Enable strict typing for apollo-server-core and fix issues 2018-07-04 21:31:55 +02:00
Danilo Bürger
73a5da149a Replaced RESTDataSource with generic DataSource typing (#1293) 2018-07-04 09:26:39 +02:00
Evans Hauser
19c8adf019
Import apollo-cache-control-js (#1294)
* Initial commit

* Add .npmignore to avoid ignoring lib when publishing

* 0.0.2

* Update graphql-extensions dependency to 0.0.2

* 0.0.3

* Reorganize code and add tests

* 0.0.4

* Add tests and reorganize code

* 0.0.5

* Update dependency to graphql-extensions 0.0.4

* 0.0.6

* Update graphql-extensions dependency and downgrade TS target

* 0.0.7

* Update README

* Update README

* Update README

* Update README

* Add import instructions for TypeScript to README (#7)

* Add cache hints when the directive is defined on interfaces (#10)

* Increase version range for `graphql` peerDependency. (#12)

* 0.0.8

* Update dependencies

* 0.0.9

* [apollo-bot] Update the Issue/PR Templates with auto label (#13)

* [apollo-bot] Update the Templates with docs label (#15)

* Add cache hints to info.cacheControl (#16)

This exposes the `cacheControl` hints on the schema, to the resolvers at runtime.

* Update `graphql` peer dependency range to allow 0.13.x.

* dev: Update TypeScript to latest version, v2.7.2.

* dev: Update jest & dependencies to latest versions.

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

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

* 0.0.10

* Add defaultMaxAge option

This is an easy way to quickly say "I want everything in my schema to be cached
for 5 seconds". You can override it with specific maxAges on specific fields or
types.

An upcoming release of apollo-server-* will allow you to specify options to
cacheControl.

* Add CircleCI config

* Add partial CHANGELOG

* 0.1.0

* Honor overwrite default maxAge with maxAge=0 (Fixes #22) (#23)

* 0.1.1

* Allow default caching to apply to interfaces

* remove unused files

* update versions and use a-s style config

* run prettier

* fix tests and typing
2018-07-03 15:08:42 -07:00
Evans Hauser
8496387c78
Import apollo-tracing-js (#1292)
* Initial commit

* 0.0.3

* Replace endOffset with duration in resolver calls

* 0.0.4

* Fix duration

* 0.0.5

* Remove unnecessary schema level resolve function and return schema

* Update README

* 0.0.6

* Update README

* Update dependencies

* 0.0.7

* Update README

* set package.json to point to this repository (#3)

* Update dependencies

Fixes #4.

* 0.0.8

* Add asynciterable support to tsconfig.json

* Skip trace collection when context or context._traceCollector is undefined

Fixes #5.

* 0.0.9

* Rewrite to use graphql-extensions

* 0.0.10

* 0.0.11

* 0.1.0

* Update graphql-extensions dependency and downgrade TS target

* 0.1.1

* Update README

* Update README

* Increase version range for `graphql` peerDependency. (#7)

* 0.1.2

* Update dependencies

* 0.1.3

* [apollo-bot] Update the Issue/PR Templates with auto label (#9)

* Update `graphql` peer dependency range to allow 0.13.x.

* dev: Update TypeScript to latest version, v2.7.2.

* dev: Update jest & dependencies to latest versions.

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

* Allow `undefined` to return from `format`. (#12)

* Allow `undefined` to return from `format`.

TypeScript 2.7 introduced new "Strict Class Instantiation" rules which,
as the name suggests, require properties which are intended to be set
(eventually, to a type) be set during construction.

Before this change, the `TracingExtension` class was deferred setting these
private properties (namely, `startWallTime`, `endWallTime`, `startHrTime`
and `duration`), but not during instantiation which required setting
marking them as optional and guarding their usage in other methods which
might use those (temporarily `undefined`, if even for a tick) properties.
For example, the expectation that `format` is _only_ called after
`requestDidStart` is not guaranteed with this configuration, even if it is
expected under normal operation.

Therefore, this change adds the additional guarding and updates the `format`
method to return `undefined` in the event that it doesn't have the appropriate
data.

* Update `graphql-extensions` dependency to `~0.0.9`.

Specifically, to take advantage of a type which landed in
`graphql-extensions@0.0.9` thanks to
https://github.com/apollographql/graphql-extensions/pull/10.

* 0.1.4

* Update for graphql-extensions@0.1.0 API (#13)

* Upgrade to TypeScript 2.8

* Add tslint and prettier

* Update for graphql-extensions@0.1.0 API

* 0.2.0-beta.0

* Make work with newest API usage

format() now gets called before the requestDidStart() EndHandler.

* 0.2.0-beta.1

* remove unused files from tracing package

* upgrade packages, fix compilation bugs, and add test
2018-07-03 13:53:25 -07:00
C. T. Lin
8c8729f066 fix README badge links and test imports (#1281) 2018-07-03 10:32:02 -07:00
Martijn Walraven
0b5c7f31c8 Export RequestOptions from apollo-datasource-rest 2018-07-03 14:45:13 +02:00
Martijn Walraven
928ef7d441
Allow dynamic configuration of data sources (#1277)
Closes #1181 and #1238.
2018-07-03 11:41:43 +02:00
Martijn Walraven
16a336d3e5 Remove unused core-js and source-map-support dependencies from graphql-extensions 2018-07-03 09:58:47 +02:00
Evans Hauser
035175144a
lambda: add existance check for result 2018-07-02 18:04:20 -07:00
Evans Hauser
19478920e4
Removes flattening of Errors inside of formatApolloErrors (#1288)
* remove unnesting of errors to support yup

* add test for error thrown by yup
2018-07-02 14:54:32 -07:00
Martijn Walraven
3ad0c43b82 Fix test typings 2018-06-30 08:35:15 +02:00
Evans Hauser
63f6b4790b
Publish
- apollo-datasource-rest@2.0.0-rc.6
 - apollo-engine-reporting@0.0.0-rc.0
 - apollo-server-caching@2.0.0-rc.6
 - apollo-server-cloudflare@2.0.0-rc.6
 - apollo-server-core@2.0.0-rc.6
 - apollo-server-env@2.0.0-rc.6
 - apollo-server-errors@2.0.0-rc.6
 - apollo-server-express@2.0.0-rc.6
 - apollo-server-hapi@2.0.0-rc.6
 - apollo-server-integration-testsuite@2.0.0-rc.6
 - apollo-server-lambda@2.0.0-rc.6
 - apollo-server-memcached@2.0.0-rc.6
 - apollo-server-redis@2.0.0-rc.6
 - apollo-server@2.0.0-rc.6
 - graphql-extensions@0.1.0-rc.0
2018-06-29 11:27:36 -07:00
Martijn Walraven
cbb5bf3547 [2.0] Switch apollo-engine-reporting to use fetch instead of the Node request module (#1274)
* Remove Node dependencies from package.json

* Replace Node request with fetch

* Wrap fetch in @zeit/fetch-retry, convert to async/await, and fix types

* Use async-retry directly because @zeit/fetch-retry doesn't support Node 6

* bump server-env version in graphql-extensions

* explicitly include factor in async-retry

* change apollo-server-env to rc.5
2018-06-29 11:15:33 -07:00
Evans Hauser
e0f7052fb1
Errors Lifecycle: user extensions > engine reporting > formatError (#1272)
* enable willSendResponse to return a modified response

* add formatError as an extension that wraps engine reporting

* ensure that formatError once on every error path

* move old formatError express tests into integration suite

* add error lifecycle with minimal engine reporting check

* increase granularity of formatError test

* return 400 error for GraphQL error created by context

* add check for internal server error for errors thrown in context

* comment about context error status code
2018-06-29 10:36:52 -07:00
Martijn Walraven
8ea36d80f7 Use scoped graphql-playground-html 2018-06-29 13:57:03 +02:00
Martijn Walraven
84233d2010 Centralize playgroundVersion in ApolloServerBase and remove pass-through of gui options 2018-06-29 13:57:03 +02:00
Evans Hauser
c5258182a9
export Request from graphql-extensions 2018-06-28 12:00:01 -07:00
Martijn Walraven
53d7a753c2 Re-export Request from apollo-datasource-rest 2018-06-28 20:56:05 +02:00
Martijn Walraven
49a802d593 Don't attempt to parse request.url at all 2018-06-28 19:06:53 +02:00
Martijn Walraven
43c36c4d60 Don't expect request.url to be a well-formed URL 2018-06-28 18:29:50 +02:00
Martijn Walraven
c2e4dfb265 Import graphql-extensions+apollo-engine-reporting/no global apollo-server-env (#1259)
* Export polyfills and types separately

* More imports from apollo-server-env

* Initial commit

* Add .npmignore to avoid ignoring lib when publishing

* 0.0.2

* Reorganize code and clean up GraphQLExtension interface

* 0.0.3

* Add support for timing callbacks and add GraphQLExtensionStack

* 0.0.4

* Downgrade target in tsconfig.json from es2015 to es5

* 0.0.5

* Bump `graphql` peerDependency. (#3)

* 0.0.6

* Update dependencies

* 0.0.7

* whenResultIsFinished fix for array results (#4)

* 0.0.8

* [apollo-bot] Update the Issue/PR Templates with auto label (#6)

* Bump `graphql` peerDependency. (#7)

* Update `graphql` peer dependency range to allow 0.13.x. (#8)

* Update `devDependencies` to latest versions. (#9)

* 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`.

* Allow `undefined` return values to `GraphQLExtension`'s `format()`. (#10)

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.

* 0.0.9

* Fix lifecycle method invocations on extensions

* 0.0.10

* Add changelog

* Upgrade to TypeScript 2.8

Makes my editor integration happier (a bugfix in tsserver I think)

* Add tslint and prettier

Same configuration as apollo-engine-js

* Remove magic from GraphQLExtensionStack constructor

It's not hard to consistently pass in an actual extension object to this
low-level API.

* New extension API: didStart handlers return didEnd handlers

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.

* 0.1.0-beta.0

* Changelog

* Add magic back into GraphQLExtensionStack constructor

But now it actually gets more context (the execution arguments) and doesn't have
to be a constructor.

* 0.1.0-beta.1

* Export more types

* 0.1.0-beta.2

* Fix lifecycle handlers to pass proper "this"

* 0.1.0-beta.3

* Pass options directly to start handlers; eliminate factory again

* 0.1.0-beta.4

* error handling in didEnd

* 0.1.0-beta.5

* pass multiple errors to EndHandler

* 0.1.0-beta.6

* add willSendResponse

* 0.1.0-beta.7

* prettier

* setFieldResolver for custom fieldResolver

* reverse

* get more initial options into requestDidStart

* 0.1.0-beta.8

* 0.1.0-beta.9

* Actually, we already get the fieldResolver!

* 0.1.0-beta.10

* work without extensionStack

* 0.1.0-beta.11

* 0.1.0-beta.12

* Send errors to willResolveField callback

* 0.1.0-beta.13

* willSendResponse can return a result

* 0.1.0-beta.14

* Revert 1063be8..56912fc

This reverts commit 1063be8..56912fc.

* add PQ options to requestDidStart

* 0.1.0-beta.14

* 0.1.0-beta.15

* Initialize an empty TypeScript/Jest package

Template based on apollo-engine-js

* Basic trace node structure building

* basic timing

* Checkpoint towards signature implementation

The new signature implementation does not try to compress whitespace.

* Basic signature implementation

* progress towards actual reporting

* basic checkpoint for reporting

* 0.0.0-beta.1

* pull in @types/long, since it is in the external api

* 0.0.0-beta.2

* get rid of Long

* 0.0.0-beta.3

* debug log request what happened

* 0.0.0-beta.4

* 0.0.0-beta.5

* correct url

* 0.0.0-beta.6

* request headers

* 0.0.0-beta.7

* leave out a few headers

* 0.0.0-beta.8

* prettier

* move stuff into multiple files, and stop exporting the extension

* lots of doc comments

* address agent.ts XXX comments

* implement privateVariables

simplify API by removing flush() and allowing flush-ers to just call sendReport
directly

* privateHeaders and error tracking

* gzip, signals

* fix test

* 0.0.0-beta.9

* Error handling for reports

* 0.0.0-beta.10

* no need to include boring stacktrace

* 0.0.0-beta.11

* tweak error reporting

* 0.0.0-beta.12

* package-lock update (npm@6?)

* Reduce target report size to 512KB from 4MB.

Load testing revealed that protobuf encoding for large FullTraceReports could
tie up CPU and reduce p99 request latency (eg, to 200ms from 10ms). Reducing the
default target report size spreads out the encoding time and mitigates the
impact on latency.  If this is not acceptable for all users, we may have to
investigate reintroducing agent-side stats aggregation to keep report sizes
small.

* 0.0.0-beta.13

* Encode Traces as they come in

This improves p99 times with little effect on p50 times. It also lets us get rid
of the heuristic average trace size estimation.

* 0.0.0-beta.14

* support PQ fields

* npm audit fix

* 0.0.0-beta.15

* ignore coverage

* Make the default signature more aggressive

We'd rather tell people confused by literal removal to tweak the signature than
tell people causing outages to do so.

* 0.0.0-beta.16

* Remove obsolete files from graphql-extensions and apollo-engine-reporting

* Fix dependencies and configs

* Fix apollo-server-cloudflare to import from apollo-server-env

* Fix compilation and test configs

* Get all tests passing again

* Switch to Lerna independent versioning

* Polyfill promisify for Node < 8 and load polyfills in tests

* ES2016 exponentiation operator is only supported in Node > 6

* add dependency cache for circle

* add missing env dependencies in REST datasource
2018-06-27 16:29:00 -07:00
Matías Olivera
8ef18187ae Fix graphql-tools/subscriptions dependencies and exports (#1257)
* Reorder dependencies

* Fix dependencies and exports

* Remove unused exports
2018-06-27 12:09:38 -07:00
Evans Hauser
62ff5c6ce6
Improve Subscriptions Dev/Docs Experience (#1255)
* fix hapi playground version, a-s exports subscription url, and document subscriptions

* remove unused subscription lifecycle methods
2018-06-27 09:59:21 -07:00
Martijn Walraven
e0c169dea9 Update GraphQL Playground to fix tracing 2018-06-27 11:56:01 +02:00
Martijn Walraven
6bf286d838 Fix async context test and add test for cloning 2018-06-26 11:57:38 +02:00
Martijn Walraven
7e35305353 Always clone the context if it's not a function
Fixes #1247.
2018-06-26 10:40:41 +02:00
Evans Hauser
3ad05191bd
v2.0.0-rc.5 2018-06-25 16:51:07 -07:00
Alessio Dionisi
2b925c4725 add graphql dependency to docs (#1244) 2018-06-25 16:37:12 -07:00
Evans Hauser
d85ef48070
Ensures formatError receives a value that passes instanceof Error (#1235)
* ensure that formatError receives instanceof Error

* add formatError test for instanceof

* apply Martijn's feedback to usse Object.create 🎉

* check constructor name inside of formatError
2018-06-25 16:36:37 -07:00
Evans Hauser
c88630333c
Hapi: reenable cors test
It seems that hapi does not send all allowed origins in the
Access-Control-Allow-Origin header, so it is necessary to use another
configuration option to see if the config is being propagated
2018-06-25 16:05:59 -07:00
David Glasser
2ca26ab29b v2.0.0-rc.4 2018-06-25 13:58:12 -07:00
David Glasser
325f11408e apollo-engine-reporting: more aggressive signataure 2018-06-25 13:58:03 -07:00
Martijn Walraven
b6e2096876 Allow passing a body to POST, PATCH and PUT in data source 2018-06-25 21:52:19 +02:00