Commit graph

440 commits

Author SHA1 Message Date
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
Martijn Walraven
faf1494a7f
Remove runQuery.ts and fix tests to use GraphQLRequestProcessor 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
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
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
Evans Hauser
96af44e41a
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-17 22:45:34 -07:00
Evans Hauser
5adae649e3
Publish
- apollo-cache-control@0.2.4
 - apollo-engine-reporting@0.0.5
 - apollo-server-cloud-functions@2.0.4
 - apollo-server-cloudflare@2.0.5
 - apollo-server-core@2.0.7
 - apollo-server-express@2.0.7
 - apollo-server-hapi@2.0.7
 - apollo-server-integration-testsuite@2.0.7
 - apollo-server-koa@2.0.7
 - apollo-server-lambda@2.0.7
 - apollo-server-micro@2.0.7
 - apollo-server@2.0.8
 - apollo-tracing@0.2.4
 - graphql-extensions@0.2.0
2018-09-14 10:35:33 -07:00
C.J. Winslow
408198e5ac 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-09-07 18:10:30 -07:00
Martijn Walraven
996c73063a Publish
- apollo-engine-reporting@0.0.4
 - apollo-server-cloud-functions@2.0.3
 - apollo-server-cloudflare@2.0.4
 - apollo-server-core@2.0.6
 - apollo-server-express@2.0.6
 - apollo-server-hapi@2.0.6
 - apollo-server-integration-testsuite@2.0.6
 - apollo-server-koa@2.0.6
 - apollo-server-lambda@2.0.6
 - apollo-server-micro@2.0.6
 - apollo-server@2.0.7
2018-09-05 17:33:16 +02:00
Vincenzo Russo
88417b7398 Switch ApolloServerBase.schema from private access to protected access (#1610) 2018-09-05 16:02:06 +02:00
Martijn Walraven
b80a8f050c Publish
- apollo-cache-control@0.2.3
 - apollo-datasource-rest@0.1.5
 - apollo-datasource@0.1.3
 - apollo-engine-reporting@0.0.3
 - apollo-server-cache-memcached@0.1.3
 - apollo-server-cache-redis@0.1.3
 - apollo-server-cloud-functions@2.0.2
 - apollo-server-cloudflare@2.0.3
 - apollo-server-core@2.0.5
 - apollo-server-env@2.0.3
 - apollo-server-express@2.0.5
 - apollo-server-hapi@2.0.5
 - apollo-server-integration-testsuite@2.0.5
 - apollo-server-koa@2.0.5
 - apollo-server-lambda@2.0.5
 - apollo-server-micro@2.0.5
 - apollo-server@2.0.6
 - apollo-tracing@0.2.3
 - graphql-extensions@0.1.3
2018-09-03 15:06:00 +02:00
Martijn Walraven
49d4ffb682 Augment typeDefs with cacheControl directive so SDL validation doesn't fail 2018-09-02 11:50:09 +02:00
Martijn Walraven
497b514511 Add processRequest to apollo-upload-server types 2018-09-01 11:37:45 +02:00
Martijn Walraven
ef67851997 Only require apollo-upload-server if uploads are enabled 2018-09-01 11:37:45 +02:00
Yipeng Zhao
984c47d07a Use playground default settings when possible (#1516)
Playground can either use external settings or its default settings (browser settings), in incompatible ways. The original implementation of default settings here would always provide 'settings' for Playground, in turn make its own settings mechanism disabled, with consequences such as altering settings in-browser cannot work as expect. Besides, once the default settings here go different with Playground provided, it would cause other problems.

The intention here is to use Playground setting as default, while explicit passing Playground settings in Apollo server would still work with defaults defined here merged.
2018-09-01 09:50:10 +02:00
Rob Richard
23ee9ec53e Update default version of graphql-playground 2018-09-01 09:34:38 +02:00
Evans Hauser
2657e9b25b
Publish
- apollo-server-cloud-functions@2.0.1
 - apollo-server-cloudflare@2.0.2
 - apollo-server-core@2.0.4
 - apollo-server-express@2.0.4
 - apollo-server-hapi@2.0.4
 - apollo-server-integration-testsuite@2.0.4
 - apollo-server-koa@2.0.4
 - apollo-server-lambda@2.0.4
 - apollo-server-micro@2.0.4
 - apollo-server@2.0.5
2018-08-20 14:17:37 -07:00
Jesse Rosenberger
8347511db8 Switch to a fork of apollo-upload-server to fix missing core-js dependency. (#1556)
* Switch to a fork of `apollo-upload-server` to fix missing `core-js` dependency.

As reported in https://github.com/apollographql/apollo-server/issues/1542,
the `apollo-upload-server` package (v5.0.0, which `apollo-server` relies on)
is no longer able to provide a `core-js` package because of change that was
outside of its control in a Babel release.

The problem is resolved in newer versions of `apollo-upload-server`,
however, regrettably, the newer versions of that package (notably, v6 and
v7) drop support for Node.js 6 — one of two versions of Node.js that are
currently under the terms of the Node.js Foundation's Long-Term-Support
(LTS) agreements.

Since Apollo Server aims to support versions of Node.js which are under LTS
(and will drop support for Node.js 6 in April 2019, per Node.js' schedule)
the current, immediate solution is to fork the `apollo-upload-server`
package as `@apollographql/apollo-upload-server`.

With the inclusion of
https://github.com/apollographql/apollo-upload-server/pull/1, we are able to
keep supporting Node.js 6.  Without this change, every new installation
of `apollo-server`, which doesn't have a `package-lock.json` preventing
transitive dependency updates - specifically, the updates to
`@babel/runtime` versions newer than `-beta.56` - is broken.

* [squash] Update to `@apollographql/apollo-upload-server@5.0.2`.

* [squash] Update to `@apollographql/apollo-upload-server@5.0.3`.
2018-08-20 13:27:15 -07:00
Evans Hauser
3e54e60ced
Publish
- apollo-server-cloudflare@2.0.1
 - apollo-server-core@2.0.3
 - apollo-server-express@2.0.3
 - apollo-server-hapi@2.0.3
 - apollo-server-integration-testsuite@2.0.3
 - apollo-server-koa@2.0.3
 - apollo-server-lambda@2.0.3
 - apollo-server-micro@2.0.3
 - apollo-server@2.0.3
2018-08-16 11:40:49 -07:00
Curtis Layne
0f17f7c50e Pass payload into the context function for subscriptions (#1513)
* Pass payload into the context function for subscriptions

The payload can be used for things like auth. You can pass a token on
the payload of the message and use it to fetch the user.

* Update CHANGELOG.md
2018-08-16 11:26:39 -07:00
Evans Hauser
efc5302930
Add option to mock the entire schema(i.e. set preserveResolvers) (#1546)
* add mockEntireSchema as configuration for preserveResolvers

* add mockEntireSchema to api reference

* add changelog
2018-08-16 11:21:13 -07:00
Evans Hauser
f7b5d63d03
Publish
- apollo-cache-control@0.2.2
 - apollo-datasource-rest@0.1.3
 - apollo-datasource@0.1.2
 - apollo-engine-reporting-protobuf@0.0.1
 - apollo-engine-reporting@0.0.2
 - apollo-server-cache-memcached@0.1.2
 - apollo-server-cache-redis@0.1.2
 - apollo-server-caching@0.1.2
 - apollo-server-cloudflare@2.0.0-rc.14
 - apollo-server-core@2.0.2
 - apollo-server-env@2.0.2
 - apollo-server-errors@2.0.2
 - apollo-server-express@2.0.2
 - apollo-server-hapi@2.0.2
 - apollo-server-integration-testsuite@2.0.2
 - apollo-server-koa@2.0.2
 - apollo-server-lambda@2.0.2
 - apollo-server-micro@2.0.2
 - apollo-server@2.0.2
 - apollo-tracing@0.2.2
 - graphql-extensions@0.1.2
2018-08-14 11:49:10 -07:00
Evans Hauser
ef82add05b
Publish
- apollo-cache-control@0.2.1
 - apollo-datasource-rest@0.1.2
 - apollo-datasource@0.1.1
 - apollo-engine-reporting-protobuf@0.0.0
 - apollo-engine-reporting@0.0.1
 - apollo-server-cache-memcached@0.1.1
 - apollo-server-cache-redis@0.1.1
 - apollo-server-caching@0.1.1
 - apollo-server-cloudflare@2.0.0-rc.13
 - apollo-server-core@2.0.1
 - apollo-server-env@2.0.1
 - apollo-server-errors@2.0.1
 - apollo-server-express@2.0.1
 - apollo-server-hapi@2.0.1
 - apollo-server-integration-testsuite@2.0.1
 - apollo-server-koa@2.0.1
 - apollo-server-lambda@2.0.1
 - apollo-server-micro@2.0.1
 - apollo-server@2.0.1
 - apollo-tracing@0.2.1
 - graphql-extensions@0.1.1
2018-08-14 11:05:31 -07:00
Jim (_nderscore)
412be208c1 Fixed GraphQL Playground with custom configuration in production. (#1495)
* Fixed support for GraphQL Playground with custom configuration in production environments.

* Updated logic in `createPlaygroundOptions` to cast the `playground` option to a boolean
  if it is defined. Fall back to `isDev` logic only if undefined.
* Updated unit test for partial graphql playground options to emulate a 'production'
  environment, mimicking the scenario that was broken before.

* Add PR #1495 to CHANGELOG.

* Restore partial playground options test when no `NODE_ENV`
2018-08-14 10:43:52 -07:00
Martijn Walraven
2369b06be2 Use strict top-level tsconfig and fix type issues or override per-package 2018-08-11 16:45:03 +02:00
Martijn Walraven
40bc73f61f Remove per-package Jest config and replace with single top-level config 2018-08-11 16:45:03 +02:00
Martijn Walraven
0d89fa7cde Make sure package.json includes clean script 2018-08-11 16:45:03 +02:00
Martijn Walraven
c049792057 Fix setupFiles reference in Jest config 2018-08-11 16:45:03 +02:00
Martijn Walraven
ef4d5e4f95 Switch to using file specifiers and root level dev dependencies only 2018-08-11 16:45:03 +02:00
Martijn Walraven
ea6faf770a Replace prepublish scripts with prepare 2018-08-11 16:45:03 +02:00
Martijn Walraven
06e31c3249 Remove per-package test, coverage and circle scripts 2018-08-11 16:45:03 +02:00
Martijn Walraven
943b91a564 Don't ignore package-lock.json 2018-08-11 16:45:03 +02:00