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

Revert "Expose composed middleware via getMiddleware()" #3046

Merged
merged 1 commit into from
Jul 16, 2019

Conversation

abernix
Copy link
Member

@abernix abernix commented Jul 16, 2019

This reverts commit 4149a97 from #2435,
which has resulted in a change to middleware endpoints which I need to think about a bit more and just caught just before the graduation of the 2.7.0 release to latest.

In a nutshell 🌰: While this affects the apollo-server-express and apollo-server-koa integrations directly, the previous pattern allowed the path to function in a wildcard-y/glob-y manner which also allowed, e.g., /graphql-literally-anything to work as the GraphQL endpoint (for both GraphQL Playground and actual GraphQL execution). In reality, I don't think that should have been permitted, but if anyone had inadvertently leveraged this pattern, they might be surprised by this change. In particular, the apollo-server package, which leverages apollo-server-express under the hood, specifies path: '/', so it falls into this category of permissiveness.

The change being reverted here implemented a more exacting path match, which is arguably more correct, but I need to convince myself that this is fine for a bit longer so I'm going to punt this to 2.8.0 without enough time to discuss further.

That saddens me greatly as I'm quite excited about the newfound freedom that getMiddleware would have provided to those that previously felt constrained by the applyMiddleware pattern, but I think I can get clarity on this relatively soon and re-ship it. It does seem to work quite well!

This reverts commit 4149a97 from #2435,
which has resulted in a change to middleware endpoints which could be
perceived as major and breaking.
@abernix abernix merged commit 52ab22e into release-2.7.0 Jul 16, 2019
@abernix abernix deleted the abernix/revert-2435 branch July 16, 2019 13:26
abernix added a commit that referenced this pull request Jul 16, 2019
This reverts commit d05aceb which was
originally #2435, but was
reverted in 52ab22e (#3046) as a
precaution, prior to releasing 2.7.0.  This attempts to reland it.
@pechitook
Copy link
Contributor

Thank you for the explanation! Looking forward to 2.8 :)

abernix added a commit that referenced this pull request Aug 23, 2019
* Re-land "Expose composed middleware via getMiddleware()"

This reverts commit d05aceb which was
originally #2435, but was
reverted in 52ab22e (#3046) as a
precaution, prior to releasing 2.7.0.  This attempts to reland it.

* Use an `express.Router` rather than `compose-middleware`.

Aside from avoiding unnecessary dependencies, by using this Router, we avoid
the `apollo-server` base package from behaving different than it has in the
past.  Specifically, `apollo-server` uses `/` as the default path, but it
does so in a wild-card way which serves GraphQL requests on _any_ path.
That means that `/graphqlllll` and `/graphql` both also served the GraphQL
Playground interface, and also responded to GraphQL execution requests.

Since some may be leveraging that behavior, we should preserve it, if we
can.

* Add CHANGELOG.md link to #3184, for awareness.
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 22, 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