Skip to main content

Apollo Server v3 upgraded to Apollo Server v4

Strapi 5 has migrated to Apollo Server v4 and this might require some manual migration steps.

This page is part of the breaking changes database and provides information about the breaking change and additional instructions to migrate from Strapi v4 to Strapi 5.

🔌 Is this breaking change affecting plugins?Yes
🤖 Is this breaking change automatically handled by a codemod?No

Breaking change description

In Strapi v4

Apollo Server v3 for the GraphQL server and graphql ^15 for the GraphQL module.

In Strapi 5

Apollo Server v4 for the GraphQL server and graphql ^16 for the GraphQL module.

Migration

This section regroups useful notes and procedures about the introduced breaking change.

Notes

  • Strapi automatically sets status400ForVariableCoercionErrors: true in the Apollo Server configuration due to a breaking change introduced by Apollo in v4. This behavior will be the default again in Apollo v5.
  • Strapi 5 upgraded the package graphql from ^15 to ^16, and only one version can be included in any project. Therefore, user code or plugins relying on graphql:15 need to use the same version range as Strapi.
  • For guidance on upgrading to Apollo Server v4, please refer to the following Manual migration section. For more detailed information, consult the Apollo v4 migration documentation.

Manual migration

To migrate to Strapi 5:

  • Set the x-apollo-operation-name header or disable the new protection by adding csrfPrevention: false to apolloServer in the GraphQL plugin configuration for multipart messages (file uploads).
  • Replace ApolloError with GraphQLError.
  • Remove root level configuration options like formatResponse and replace them with plugin hooks in the plugins array.
  • Remove the modules configuration option and split it into typeDefs and resolvers.
  • Replace debug with includeStacktraceInErrorResponses.