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
Upgrade to Apollo v4 #19173
Upgrade to Apollo v4 #19173
Conversation
BREAKING CHANGE: Update from 'apollo-server-koa' to '@apollo/server' and '@as-integrations/koa'
Size Change: +2.15 kB (0%) Total Size: 1.32 MB
ℹ️ View Unchanged
|
Few thoughts - is it worth abstracting the configs so we can upgrade this library without mass breaking changes? Has there been any discussion on how we might tackle the ESM issue? This is one of a few packages we now have this issue with (prettier being the other off the top of my head). I'm concerned were gonna lock ourselves into a position where there are security issues but we can't fix them. |
I don't think so, most of the config is going to be specific to the graphql server used, and if we try to build in auto-fixes for breaking changes here it could just confuse people and create a headache for us to maintain. TBH, considering the amount of breaking changes they made here and what they plan for Apollo v5, Strapi v6 may shift to a different graphql server package altogether We could potentially provide a legacy graphql plugin that would still support Apollo v3, seeing that they've extended EOL from Oct 2023 to Oct 2024. Or maybe we deprecate @strapi/graphql and create a new @strapi/graphql-apollo-v4 that strapi defaults to? I will bring it up with @marcoautiero
This is definitely something we need to open a discussion on, doing this migration brought it even more to my attention. Let's sync on this asap! |
} | ||
|
||
// TODO: we shouldn't combine playground exceptions with documentation for all routes, we should first check the path and then return exceptions specific to that |
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.
Note: this and the TODO below are handled in #19202
packages/core/content-type-builder/server/src/controllers/component-categories.ts
Outdated
Show resolved
Hide resolved
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.
Nice work!
@@ -16,7 +16,7 @@ const getFirstLevelPath = map((path: string) => path.split('.')[0]); | |||
const controller = { | |||
async getNonLocalizedAttributes(ctx) { | |||
const { user } = ctx.state; | |||
const { model, id, locale } = ctx.request.body; | |||
const { model, id, locale } = ctx.request.body as any; // TODO: add correct typings |
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 guess this shouldn't really be part (as any other change in i18n types) of the PR and will be fixed directly in main. Do we need to keep those changes anyway?
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'll revert them and update from v5/main now that it's apparently fixed there
(Update)
Narrator: It was not fixed there.
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.
Note on this: adding @types/koa-bodyparser to graphql caused it to start working throughout the monorepo, switching the type of body from 'any' to 'unknown'. So I had to "fix" CTB and i18n so that ts:test:back will pass. Functionally there's no difference, just allowing body to be treated as any
as it was before this PR (and in the future, new code should treat it as unknown because it is)
What does it do?
Some significant changes:
Apollo v4 has many breaking changes such as server config options
upgrade from
graphql
v15 to v16 which has its own long list of breaking changesupgrade from
graphql-upload
v13 to v15 (note: didn't use v16 because it's esm only)Graphql Playground replaced with Apollo LandingLocal
helmet
exceptions for itadded some test utility functionality so request agent can send specific headers globally or per-request
Follow-up in later PRs:
context
no longer exists in ApolloConfig and moved to the KoaMiddleware, so we may need to provide a mechanism for users to inject code and configuration there as wellPlayground
is EOL, onlyLandingLocalDefault
is supported)productionLandingPage
andlandingPage
with options 'LocalDefault' and 'ProductionDefault' (so that in the future we can then support other landing pages)Why is it needed?
Apollo v3 is already EOL, so Strapi v5 must support Apollo v4.
How to test it?
Related issue(s)/PR(s)
#19202 - First follow-up on this to improve the helmet security config