-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TODO(AS4) squashing #6936
TODO(AS4) squashing #6936
Conversation
✅ Deploy Preview for apollo-server-docs ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit cd783e3:
|
610f392
to
4f7d34e
Compare
packages/server/src/ApolloServer.ts
Outdated
>): Promise<GraphQLResponse>; | ||
|
||
async executeOperation({ | ||
request, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I sorta liked the mandatory operation object being an unnamed parameter, but maybe that's silly.
I also don't know if I love calling it request, which doesn't pair well with the name executeOperation
, even though it is of request type... honestly I'd call this executeParsedRequest
or something but prefer keeping the name matching the AS3 name.
In any case, there are docs showing executeOperation that need to be updated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can deprecate to rename and keep as an alias for the life of AS4?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We chatted on Slack and have decided to leave the method name as executeOperation
but to move the operation itself back to being a first unnamed argument before the options object.
External headers types are now an actual HeaderMap rather than a Map. The HeaderMap downcases all incoming keys for get/set/delete since headers are case-insensitive. The HeaderMap class is now exported by @apollo/server, since it can be useful in crafting response headers for GraphQLError.extensions.
I don't think this TODO is necessary. `runHttpQuery` is only called in the event that `httpRequest.body` is not an array from the `runPotentiallyBatchedHttpQuery` function. These are both private API. In the event that we do pass a batched body for some reason, we'll still get an error, it just won't be quite as helpful as we'd want.
4f7d34e
to
0bace22
Compare
@trevor-scheer I rebased and resolved conflicts, though I didn't make any of the other changes we talked about. |
This reverts commit feddeae.
The second parameter is now an object which includes an optional `contextValue`. This allows us to introduce other optional execution options in the future without needing to change the signature.
Going to land this @glasser, please review in post. |
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to version-4, this PR will be updated.⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ `version-4` is currently in **pre mode** so this branch has prereleases rather than normal releases. If you want to exit prereleases, run `changeset pre exit` on `version-4`.⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ # Releases ## @apollo/server-integration-testsuite@4.0.0-alpha.13 ### Patch Changes - [#6936](#6936) [`a404bf17e`](a404bf1) Thanks [@trevor-scheer](https://github.com/trevor-scheer)! - Add test for batch requests with no elements - Updated dependencies \[[`a404bf17e`](a404bf1), [`a404bf17e`](a404bf1), [`a404bf17e`](a404bf1)]: - @apollo/server@4.0.0-alpha.13 ## @apollo/server@4.0.0-alpha.13 ### Patch Changes - [#6936](#6936) [`a404bf17e`](a404bf1) Thanks [@trevor-scheer](https://github.com/trevor-scheer)! - Update executeOperation second parameter to be an optional options object which includes an optional `contextValue`. - [#6936](#6936) [`a404bf17e`](a404bf1) Thanks [@trevor-scheer](https://github.com/trevor-scheer)! - `HTTPGraphQLRequest` now uses a specific `HeaderMap` class which we export instead of allowing a standard `Map`. The `HeaderMap` downcases all incoming keys, as header names are not case-sensitive. - [#6936](#6936) [`a404bf17e`](a404bf1) Thanks [@trevor-scheer](https://github.com/trevor-scheer)! - Update `validationRules` typing for correctness. This is sort of a breaking change for TS users in that the types were more permissive than they should have been. All `validationRules` list items should conform to the `graphql-js` `ValidationRule` type. Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
req: { headers: { name: 'world' } }, | ||
// highlight-start | ||
contextValue: { | ||
// A half-hearted attempt at making something vaguely like an express.Request, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is the AS3 version, so we shouldn't change it. (The comment is trying to point out that it was actually kind of hard to use the AS3 version since you theoretically had to come up with a whole express.Request.)
@@ -67,6 +67,8 @@ If you have enabled HTTP batching, you can send a batch of queries in a single ` | |||
|
|||
If you send a batched request, Apollo Server responds with a corresponding array of GraphQL responses. | |||
|
|||
> Note: In the case of duplicate response headers across separate requests, the later request's header will take precedence on a per-header basis. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should actually probably talk about operations not requests (will fix)
@@ -330,6 +330,8 @@ An object containing configuration options for connecting Apollo Server to [Apol | |||
|
|||
Controls whether to allow [Batching Queries](../workflow/requests/#batching) in a single HTTP Request. Defaults to `false`. If a request comes in formatted as an array rather than as a single request object, an error will be thrown ( i.e., `Operation batching disabled`) _unless_ batching is enabled. | |||
|
|||
> Note: In the case of duplicate response headers across separate requests, the later request's header will take precedence on a per-header basis. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
- A bit more clarity about batching and HTTP headers in one place; not even bothering in another place (it seems a bit specific for the options reference, which links to the first place anyway) - Revert accidental change to AS3 example
- A bit more clarity about batching and HTTP headers in one place; not even bothering in another place (it seems a bit specific for the options reference, which links to the first place anyway) - Revert accidental change to AS3 example
Address a number of v4-related TODOS.
Most notably (copied from changesets):
contextValue
.HTTPGraphQLRequest
now uses a specificHeaderMap
class which we export instead of allowing a standardMap
. TheHeaderMap
downcases all incoming keys, as header names are not case-sensitive.validationRules
typing for correctness. This is sort of a breaking change for TS users in that the types were more permissive than they should have been. AllvalidationRules
list items should conform to thegraphql-js
ValidationRule
type.