Skip to content
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

Merged
merged 15 commits into from
Sep 26, 2022
Merged

TODO(AS4) squashing #6936

merged 15 commits into from
Sep 26, 2022

Conversation

trevor-scheer
Copy link
Member

@trevor-scheer trevor-scheer commented Sep 23, 2022

Address a number of v4-related TODOS.

Most notably (copied from changesets):

  • Update executeOperation second parameter to be an optional options object which includes an optional contextValue.
  • 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.
  • 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.
  • Add test for batch requests with no elements (this potentially affects integration testsuite users)

@netlify
Copy link

netlify bot commented Sep 23, 2022

Deploy Preview for apollo-server-docs ready!

Name Link
🔨 Latest commit cd783e3
🔍 Latest deploy log https://app.netlify.com/sites/apollo-server-docs/deploys/6331ddb82d527b00080a3fc4
😎 Deploy Preview https://deploy-preview-6936--apollo-server-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@codesandbox-ci
Copy link

codesandbox-ci bot commented Sep 23, 2022

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:

Sandbox Source
Apollo Server Typescript Configuration
Apollo Server Configuration

docs/source/api/apollo-server.mdx Outdated Show resolved Hide resolved
docs/source/workflow/requests.md Outdated Show resolved Hide resolved
>): Promise<GraphQLResponse>;

async executeOperation({
request,
Copy link
Member

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.

Copy link
Member Author

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?

Copy link
Member

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.

packages/server/src/utils/HeaderMap.ts Show resolved Hide resolved
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.
@glasser
Copy link
Member

glasser commented Sep 24, 2022

@trevor-scheer I rebased and resolved conflicts, though I didn't make any of the other changes we talked about.

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.
@trevor-scheer trevor-scheer marked this pull request as ready for review September 26, 2022 17:14
@trevor-scheer
Copy link
Member Author

Going to land this @glasser, please review in post.

@trevor-scheer trevor-scheer merged commit a404bf1 into version-4 Sep 26, 2022
@trevor-scheer trevor-scheer deleted the trevor/todos branch September 26, 2022 17:17
trevor-scheer pushed a commit that referenced this pull request Sep 26, 2022
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,
Copy link
Member

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.
Copy link
Member

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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

glasser added a commit that referenced this pull request Sep 26, 2022
- 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
glasser added a commit that referenced this pull request Sep 26, 2022
- 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
glasser added a commit that referenced this pull request Sep 26, 2022
- 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
@github-actions github-actions bot mentioned this pull request Oct 10, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants