Commit graph

1116 commits

Author SHA1 Message Date
hrg921
d12f28089d docs: update apollo-server-lambda/README (#2364)
I think 'this' is better than 'the'
2019-02-25 17:33:05 +02:00
Chang Wang
1ef592adeb Fix: Remove incorrect cors option type from apollo-server-express's constructor (#2373)
* Fix: Remove incorrect cors option type from apollo-server-express's constructor

https://github.com/apollographql/apollo-server/pull/2330#discussion_r259773834

* update changelog

* Update CHANGELOG.md
2019-02-25 17:32:18 +02:00
Jesse Rosenberger
62587e037b Publish
- apollo-engine-reporting@1.0.5
 - apollo-server-azure-functions@2.4.6
 - apollo-server-cloud-functions@2.4.6
 - apollo-server-cloudflare@2.4.6
 - apollo-server-core@2.4.6
 - apollo-server-express@2.4.6
 - apollo-server-fastify@2.4.6
 - apollo-server-hapi@2.4.6
 - apollo-server-integration-testsuite@2.4.6
 - apollo-server-koa@2.4.6
 - apollo-server-lambda@2.4.6
 - apollo-server-micro@2.4.6
 - apollo-server-plugin-base@0.3.5
 - apollo-server-testing@2.4.6
 - apollo-server@2.4.6
 - graphql-extensions@0.5.5
2019-02-22 07:21:47 +00:00
Jesse Rosenberger
8b02c0c440
Allow Node.js-like runtimes to identify as Node.js as well. (#2357)
Previously, in order to only load dependencies which only work on Node.js
and fail in non-Node.js environments, we introduced a check which did a
string-comparison of `process.release.name` to see if it is was `node`.

This was first introduced in 9c563fae50 as
part of #2054, but has gone on to be useful for other purposes as well.

Some Node.js forks such as NodeSource's N|Solid, which is a fork of Node.js
which follows-up each Node.js release with a custom build that includes
additional native addons but is otherwise the same, override this value with
their own name.  This means that N|Source returns `nsolid`, despite the fact
that it is almost entirely the same as Node.js.

Luckily, N|Solid leaves the base version of its Node.js in
`process.versions.node` (and additionally adds its own
`process.versions.nsolid`).  By relaxing the string comparison on
`process.release.name`, we should still be able to accurately detect the
environment we want - which is "Close enough to Node.js!".

Fixes https://github.com/apollographql/apollo-server/issues/2356
2019-02-22 09:04:16 +02:00
Jesse Rosenberger
750f0010ca Re-align version numbers after 587c660d.
cc @cheapsteak
2019-02-22 06:37:16 +00:00
Chang Wang
587c660dc1 Publish
- apollo-server-express@2.4.5
 - apollo-server@2.4.5
2019-02-21 14:35:58 -05:00
KATT
7cb33769cb Tests using ApolloServerExpressConfig 2019-02-21 15:46:10 -03:00
KATT
f0a3c69635 export interface ExpressContext 2019-02-21 15:46:07 -03:00
Chang Wang
879ed19034 Publish
- apollo-cache-control@0.5.2
 - apollo-datasource-rest@0.3.2
 - apollo-engine-reporting@1.0.4
 - apollo-server-azure-functions@2.4.4
 - apollo-server-cloud-functions@2.4.4
 - apollo-server-cloudflare@2.4.4
 - apollo-server-core@2.4.4
 - apollo-server-errors@2.2.1
 - apollo-server-express@2.4.4
 - apollo-server-fastify@2.4.4
 - apollo-server-hapi@2.4.4
 - apollo-server-integration-testsuite@2.4.4
 - apollo-server-koa@2.4.4
 - apollo-server-lambda@2.4.4
 - apollo-server-micro@2.4.4
 - apollo-server-plugin-base@0.3.4
 - apollo-server-testing@2.4.4
 - apollo-server@2.4.4
 - apollo-tracing@0.5.2
 - graphql-extensions@0.5.4
2019-02-21 13:05:33 -05:00
Chang Wang
a4ebadc876
Type parameters for context function separately from the context it produces (#2350)
* Add AS constructor with context usage to tests

* fix(typing): Context template type should be 'object' and not 'any'

```context?: ContextFunction<ExpressContext, any> | Context<any>;```
is
```context?: ContextFunction<ExpressContext, any> | any;```
which is
```context?: any;```

https://github.com/Microsoft/TypeScript/issues/18568

Since the ContextFunction<...> part is ignored, no type hinting will be provided when a function is passed to `context`. We don't really mean `any`, we mean an object with any shape, so we should use `object` instead

* fix(typing): type ContextFunction params separately from resulting context object

* Update changelog

* rename: ContextContent -> ProducedContext
2019-02-21 12:49:04 -05:00
Chang Wang
8850e0f7ed
Add more accurate typings to formatError (#2343)
* Type formatErrors function to specify that it accepts and returns ApolloError

* Update changelog

* type(formatErrors): accept GraphQLError, return GraphQLFormattedError

* update changelog
2019-02-21 09:10:13 -05:00
Jesse Rosenberger
e1d7078817
Publish
- apollo-engine-reporting@1.0.3
 - apollo-server-azure-functions@2.4.3
 - apollo-server-cloud-functions@2.4.3
 - apollo-server-cloudflare@2.4.3
 - apollo-server-core@2.4.3
 - apollo-server-express@2.4.3
 - apollo-server-fastify@2.4.3
 - apollo-server-hapi@2.4.3
 - apollo-server-integration-testsuite@2.4.3
 - apollo-server-koa@2.4.3
 - apollo-server-lambda@2.4.3
 - apollo-server-micro@2.4.3
 - apollo-server-plugin-base@0.3.3
 - apollo-server-testing@2.4.3
 - apollo-server@2.4.3
 - graphql-extensions@0.5.3
2019-02-20 19:00:08 +02:00
Jesse Rosenberger
e727a252fe
Replace Slack shields in project README.mds with Spectrum shields. (#2345)
As we're moving the community from Slack to Spectrum, its time to update
these shields from our project README files (which show on npm and in
GitHub) to reflect the new home for conversation.

If you haven't already joined the new Apollo community on Spectrum.chat,
visit https://spectrum.chat/apollo/ to join the discussion!

For more details on the move, checkout the Apollo blog post by @hwillson:

https://blog.apollographql.com/goodbye-slack-hello-spectrum-8fa6b979645b
2019-02-20 17:55:16 +02:00
Jesse Rosenberger
72f410da46
Stop casting to net.AddressInfo type as that should already be inferred.
This is necessary after the changes in 0f75909e35
and https://github.com/apollographql/apollo-server/pull/2344, as the
`AddressInfo` type didn't become available until a future version of
`@types/node`.

Regardless, it seems to me that this should be inferred without any problem
and we don't actually rely on the `AddressInfo` type, and instead are only
looking for an interface which has `port`, `address` and `family`, as the
inferred return value from `http.Server.prototype.address()` does.
2019-02-20 17:11:09 +02:00
Jesse Rosenberger
0d4fb48d9a
Merge branch 'master' into patch-1 2019-02-20 13:09:50 +02:00
Jesse Rosenberger
c1607cb919
Switch to import = for ws types, since @types/ws uses export =.
While it would be perfectly fine to use `import *` in this particular case,
we've moved away from the star-import pattern in this repository, instead
preferring the `esModuleInterop` compiler option which seems to be the
direction that TypeScript is moving as it's now the default with `tsc --init`.

TypeScript clearly lost its battle with `import *` which many consider to
have been an incorrect direction in the first place.  Some build tools won't
work with star imports, and using them can make some optimizations more
difficult.  By avoiding this pattern here, hopefully we'll avoid moving back
in that direction inadvertently.

Here's a read I found at one point which roughly explains:

https://itnext.io/great-import-schism-typescript-confusion-around-imports-explained-d512fc6769c2
2019-02-20 12:45:42 +02:00
Jesse Rosenberger
6905e6dfdd
Use specific types from aws-lambda, rather than star-imports.
We've generally moved away from the star-import pattern which TypeScript
also no longer generates with its default `tsc --init` configuration, so it
seems to make sense to keep picking exactly what we want since this pattern
is no longer forced upon us by TypeScript.
2019-02-20 12:45:32 +02:00
Chang Wang
63089961f5 Provide more accurate types for apollo-server-express's ContextFunction (#2330)
* typing: context function could return value synchronously

* Create ApolloServerExpressConfig type that has req and res in context

* Have apollo-server-express's constructor also use the express-specific config

* Update changelog
2019-02-19 20:00:12 +02:00
Ralph
2f773625c0 apollo-server-koa: Respond to OPTIONS (#2288)
Closes #2253
2019-02-19 18:01:17 +02:00
Arthur Petrie
212eb94430
Merge branch 'master' into patch-1 2019-02-19 15:55:37 +01:00
Arthur Petrie
5efa6a5175
Update ApolloServer.ts
Fix lambda types import: aws-lambda types has no default export
2019-02-19 15:54:11 +01:00
Jesse Rosenberger
c1669c3d74
Publish
- apollo-cache-control@0.5.1
 - apollo-datasource-rest@0.3.1
 - apollo-datasource@0.3.1
 - apollo-engine-reporting-protobuf@0.2.1
 - apollo-engine-reporting@1.0.2
 - apollo-server-azure-functions@2.4.2
 - apollo-server-cache-memcached@0.3.1
 - apollo-server-cache-redis@0.3.1
 - apollo-server-caching@0.3.1
 - apollo-server-cloud-functions@2.4.2
 - apollo-server-cloudflare@2.4.2
 - apollo-server-core@2.4.2
 - apollo-server-express@2.4.2
 - apollo-server-fastify@2.4.2
 - apollo-server-hapi@2.4.2
 - apollo-server-integration-testsuite@2.4.2
 - apollo-server-koa@2.4.2
 - apollo-server-lambda@2.4.2
 - apollo-server-micro@2.4.2
 - apollo-server-plugin-base@0.3.2
 - apollo-server-testing@2.4.2
 - apollo-server@2.4.2
 - apollo-tracing@0.5.1
 - graphql-extensions@0.5.2
2019-02-14 15:25:38 +02:00
Jesse Rosenberger
f988a30e8c
Publish
- apollo-cache-control@0.5.1-rc.0
 - apollo-datasource-rest@0.3.1-rc.0
 - apollo-datasource@0.3.1-rc.0
 - apollo-engine-reporting-protobuf@0.2.1-rc.0
 - apollo-engine-reporting@1.0.2-rc.0
 - apollo-server-azure-functions@2.4.2-rc.0
 - apollo-server-cache-memcached@0.3.1-rc.0
 - apollo-server-cache-redis@0.3.1-rc.0
 - apollo-server-caching@0.3.1-rc.0
 - apollo-server-cloud-functions@2.4.2-rc.0
 - apollo-server-cloudflare@2.4.2-rc.0
 - apollo-server-core@2.4.2-rc.0
 - apollo-server-express@2.4.2-rc.0
 - apollo-server-fastify@2.4.2-rc.0
 - apollo-server-hapi@2.4.2-rc.0
 - apollo-server-integration-testsuite@2.4.2-rc.0
 - apollo-server-koa@2.4.2-rc.0
 - apollo-server-lambda@2.4.2-rc.0
 - apollo-server-micro@2.4.2-rc.0
 - apollo-server-plugin-base@0.3.2-rc.0
 - apollo-server-testing@2.4.2-rc.0
 - apollo-server@2.4.2-rc.0
 - apollo-tracing@0.5.1-rc.0
 - graphql-extensions@0.5.2-rc.0
2019-02-14 15:16:36 +02:00
Jesse Rosenberger
8f204f4906
Align apollo-server-fastify's version in preparation for publishing.
This will allow Lerna to release the first version as
`apollo-server-fastify@2.4.2`.
2019-02-14 15:02:38 +02:00
Jesse Rosenberger
8ac2884cfa
Merge branch 'master' into re-stage-pr-1971 2019-02-14 15:01:00 +02:00
Trevor Scheer
4f24edc1f6 Migrate apollo-graphql package to apollo-tooling repo (#2316)
The purpose of this PR is to remove the `apollo-graphql` package from this repository, to be added to `apollo-tooling` instead.

https://github.com/apollographql/apollo-tooling

Ref: https://github.com/apollographql/apollo-tooling/pull/1018
2019-02-14 12:41:58 +02:00
Jesse Rosenberger
8c71adf2aa
azure-functions: Add missing test configuration files. (#2312)
These missing configurations, which weren't identified in the original
implementation of `apollo-server-azure-functions` in #1926, are responsible
for the failures which have surfaced in the #2228, which updates Jest to v24.x.
2019-02-13 20:24:32 +02:00
Jesse Rosenberger
e7709588fb
Update to apollo-tools@0.3.3, even for nested dependencies.
There was a breaking change to `core-js` in `3.0.0-beta.12` which seems to
warrant this extra protection.
2019-02-13 16:16:45 +02:00
Chang Wang
5918e188d9 Follow-up #2298 with regression test (#2308)
* test: ensure "total duration" > "duration of resolvers"

Add test for https://github.com/apollographql/apollo-server/pull/2298

* Update tracing duration test to be more comprehensive

Previously we were only guaranteeing that individual resolvers didn't have a duration longer than the total duration. The updated test guarantees that the duration (from when the first resolver started to when the last resolver ended) should be less than total duration

* Add another resolver to tracing test

* Prefer `const` over `let` for variables which aren't mutated.
2019-02-13 15:09:38 +02:00
Ben Newman
4116b2ff4a
Publish
- apollo-engine-reporting@1.0.1
 - apollo-server-azure-functions@2.4.1
 - apollo-server-cloud-functions@2.4.1
 - apollo-server-cloudflare@2.4.1
 - apollo-server-core@2.4.1
 - apollo-server-express@2.4.1
 - apollo-server-hapi@2.4.1
 - apollo-server-integration-testsuite@2.4.1
 - apollo-server-koa@2.4.1
 - apollo-server-lambda@2.4.1
 - apollo-server-micro@2.4.1
 - apollo-server-plugin-base@0.3.1
 - apollo-server-testing@2.4.1
 - apollo-server@2.4.1
 - graphql-extensions@0.5.1
2019-02-12 16:34:47 -05:00
Ben Newman
b89de2675b
Allow passing parseOptions to ApolloServerBase constructor. (#2289) 2019-02-12 14:09:12 -05:00
Ben Newman
3f7a7f3d67
Avoid importing entire crypto dependency tree if not in Node.js. (#2304)
The apollo-server-core package uses Node's built-in crypto module only to
create SHA-256 and -512 hashes.

When we're actually running in Node, the native crypto library is clearly
the best way to create these hashes, not least because we can assume it
will be available without having to bundle it first.

Outside of Node (such as in React Native apps), bundlers tend to fall back
on the crypto-browserify polyfill, which comprises more than a hundred
separate modules. Importing this polyfill at runtime (likely during
application startup) takes precious time and memory, even though almost
all of it is unused.

Since we only need to create SHA hashes, we can import the much smaller
sha.js library in non-Node environments, which happens to be what
crypto-browserify uses for SHA hashing, and is a widely used npm package
in its own right: https://www.npmjs.com/package/sha.js.
2019-02-12 14:07:42 -05:00
Chang Wang
bf120018bf Await on graphql.execute() before calling executionDidEnd handler (AS-59) (#2298)
* Wait on graphql.execute() before calling end handler

* Update changelog
2019-02-12 20:34:56 +02:00
Jacob Marshall
e3070a51d6 Correct Azure Functions type definitions (#2287)
* Rename azureFunctions.d.ts to azureFunctions.ts

See https://github.com/apollographql/apollo-server/issues/2085#issuecomment-449686772

* Update CHANGELOG.md
2019-02-12 18:28:12 +02:00
Ben Newman
543b9c8432
Require apollo-engine-reporting only if EngineReportingAgent used. (#2305)
When getEngineServiceId does not return a truthy value, we can save memory
and startup time by avoiding importing apollo-engine-reporting, which
(among its other dependencies) imports the protobuf.js implementation.
2019-02-12 11:21:07 -05:00
Ben Newman
96351a4db6 Remove unused lodash dependency. (#2303)
The only usage of lodash was removed by @martijnwalraven in commit
a09d514e59.
2019-02-12 17:44:22 +02:00
Jesse Rosenberger
b4df18b31a
Merge branch 'master' into re-stage-pr-1971 2019-02-08 12:48:41 +02:00
Jesse Rosenberger
a3222ece11
Publish
- apollo-cache-control@0.5.0
 - apollo-datasource-rest@0.3.0
 - apollo-datasource@0.3.0
 - apollo-engine-reporting@1.0.0
 - apollo-graphql@0.1.0
 - apollo-server-azure-functions@2.4.0
 - apollo-server-cache-memcached@0.3.0
 - apollo-server-cache-redis@0.3.0
 - apollo-server-caching@0.3.0
 - apollo-server-cloud-functions@2.4.0
 - apollo-server-cloudflare@2.4.0
 - apollo-server-core@2.4.0
 - apollo-server-express@2.4.0
 - apollo-server-hapi@2.4.0
 - apollo-server-integration-testsuite@2.4.0
 - apollo-server-koa@2.4.0
 - apollo-server-lambda@2.4.0
 - apollo-server-micro@2.4.0
 - apollo-server-plugin-base@0.3.0
 - apollo-server-testing@2.4.0
 - apollo-server@2.4.0
 - apollo-tracing@0.5.0
 - graphql-extensions@0.5.0
2019-02-07 14:08:23 +02:00
Jesse Rosenberger
f74610b290
Publish
- apollo-cache-control@0.5.0-alpha.3
 - apollo-datasource-rest@0.3.0-alpha.3
 - apollo-engine-reporting@1.0.0-alpha.3
 - apollo-graphql@0.0.1-alpha.1
 - apollo-server-azure-functions@2.4.0-alpha.4
 - apollo-server-cloud-functions@2.4.0-alpha.4
 - apollo-server-cloudflare@2.4.0-alpha.4
 - apollo-server-core@2.4.0-alpha.4
 - apollo-server-express@2.4.0-alpha.4
 - apollo-server-hapi@2.4.0-alpha.4
 - apollo-server-integration-testsuite@2.4.0-alpha.4
 - apollo-server-koa@2.4.0-alpha.4
 - apollo-server-lambda@2.4.0-alpha.4
 - apollo-server-micro@2.4.0-alpha.4
 - apollo-server-plugin-base@0.3.0-alpha.4
 - apollo-server-testing@2.4.0-alpha.4
 - apollo-server@2.4.0-alpha.4
 - apollo-tracing@0.5.0-alpha.3
 - graphql-extensions@0.5.0-alpha.4
2019-02-07 13:01:14 +02:00
Jesse Rosenberger
e971bdf8b4
TEMP: Revert "feat(Fastify) Apollo server Fastify integration #626 (#1971)"
This TEMPORARILY reverts commit 069110b353,
which was the result of the work done in #1971 by @rkorrelboom.

Unfortunately, we need to put this on ice while we wait for movement on a
package naming conflict.  The dialog surrounding this is under way, as
I've explained in the PR:

https://github.com/apollographql/apollo-server/pull/1971#issuecomment-456817749

I'm excited to re-land this in an upcoming version, but there's no reason to
block the 2.4.0 release for it right now.

I will open a new PR with the work from #1971 in due time.
2019-02-07 12:56:03 +02:00
Jesse Rosenberger
60b8bca6da
Merge branch 'master' into release-2.4.0 2019-02-07 12:40:37 +02:00
Jesse Rosenberger
5ee9845537
Compare Engine reporting's privateHeaders case-insensitively, as documented.
The documentation for `privateHeaders`[[0]] suggests that it is
case-insensitive.  While that statement is true, and the incoming header is
lower-cased before checking it against the `privateHeaders` configuration,
it assumed that the headers in the `privateHeaders` object were specified in
lower-case.

This changes the comparison to lower-case both sides prior to determining
equality.

[0]: https://github.com/apollographql/apollo-server/blob/abb8dc58/packages/apollo-engine-reporting/src/agent.ts#L67-L70

Fixes: https://github.com/apollographql/apollo-server/issues/2273
2019-02-06 12:50:10 +02:00
Jesse Rosenberger
3dfbfcc0d8
Use Array.isArray rather than typeof ... === 'object' to check Arrayness. 2019-02-06 12:24:01 +02:00
Jesse Rosenberger
5666235119
Merge branch 'master' into release-2.4.0 2019-02-06 12:06:02 +02:00
Jesse Rosenberger
f99ebd373b
Set apollo-datasource-rest version back to v0.2.2.
Lerna will take care of this on publishing.
2019-02-05 13:11:43 +02:00
Chris Airey
e8e49026dd Serialize arrays as JSON on fetch in RESTDataSource 2019-02-05 03:38:21 -05:00
Dennis Johnson
95949971d4 chore(deps): update dependency @types/koa-bodyparser to a valid 4.2.1… (#2217)
… version

This PR should hopefully correct some typing issues we are currently facing.

The problem:
- this package references v5.0.1 for @types/koa-bodyparser
- when we start our server that also uses koa-bodyparser for non-graphql routes, the type for koa.Request sets the "body" field to:

```
declare module "koa" {
    interface Request {
        body: {} | null | undefined;
        rawBody: {} | null | undefined;
    }
}
```

Which breaks our type defs for koa-bodyparser as we actually want "body" to be set to "any."

The v5.0.1 that was originally placed here is no longer "latest" and they have published a new v4 version that has the correct typing for koa-bodyparser (setting body to any). - https://www.npmjs.com/package/@types/koa-bodyparser

<!--
  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:

* [ ] 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
2019-02-04 18:10:07 +02:00
Jesse Rosenberger
d0998e7e28
Merge remote-tracking branch 'origin/master' into release-2.4.0 2019-02-04 17:22:15 +02:00
Jesse Rosenberger
59d5a5088a
Add apollo-graphql as a project reference to apollo-engine-reporting. 2019-02-01 20:40:28 +02:00
Jesse Rosenberger
b3758d8e47
Update apollo-engine-reporting's CHANGELOG.md for a major breaking change. 2019-02-01 20:40:27 +02:00