Home

>

Tools

>

Strapi

>

Releases

>

3.0.0-beta.4

Strapi Release: 3.0.0-beta.4

Tag Name: v3.0.0-beta.4

Release Date: 6/12/2019

Strapi LogoStrapi

Open-source headless CMS built with Node.js. Provides developers with complete freedom in choosing their favorite tools and frameworks for frontend development.

TL;DR

Strapi v3.0.0-beta.4 introduces a breaking change in middleware initialization, moving from callback-based to async/await patterns. This release also includes several GraphQL plugin fixes, improved error handling, and documentation updates. The middleware loading system has been simplified, and various bug fixes enhance the overall stability of the framework.

Highlight of the Release

    • Breaking change in middleware initialization pattern from callback to async/await
    • Multiple GraphQL plugin fixes including amountLimit, primaryKey, and schema extensions
    • Simplified middleware ordering algorithm
    • Improved error handling for plugin operations
    • Enhanced link helper to work outside of workspace
    • Added status code handler to health checks

Migration Guide

Updating Middleware Implementation

The most significant change in this release is the middleware initialization pattern. You need to update your custom middlewares from callback-based to async/await pattern:

Before:

module.exports = () => {
  return {
    initialize(cb) {
      // async code
      cb();
    },
  };
};

After:

module.exports = () => {
  return {
    async initialize() {
      // sync code or async code
    },
  };
};
  1. Remove the callback parameter from your initialize function
  2. Add the async keyword to the initialize function
  3. Replace callback invocations with direct returns or await statements

If you have custom GraphQL resolvers, ensure they correctly handle primaryKey lookups as this has been fixed in this release.

Upgrade Recommendations

This release contains a breaking change to middleware initialization, so developers should plan accordingly:

  1. For Development Environments: Upgrade as soon as possible to test your custom middlewares with the new async/await pattern.

  2. For Production Environments: Since this is still a beta release (v3.0.0-beta.4), it's recommended to test thoroughly in a staging environment before deploying to production.

  3. Priority: Medium - The breaking change affects developers with custom middlewares, but the migration is straightforward.

  4. Preparation: Review all custom middleware code and update the initialization pattern as described in the migration guide.

  5. Testing Focus: Pay special attention to testing GraphQL queries if you're using custom resolvers or extensions, as several fixes in this area might affect behavior.

Bug Fixes

  • GraphQL Improvements:

    • Fixed amountLimit in GraphQL queries to properly handle query limits
    • Fixed primaryKey not found issue for custom resolvers
    • Added support for loading extensions in GraphQL schemas
    • Fixed issue #3224 related to GraphQL plugin
  • Framework Fixes:

    • Fixed wrong parameter name in getType bookshelf hook
    • Fixed error handling in getPlugins to properly ignore certain errors
  • Admin Interface:

    • Updated Russian translation for "welcome.again" text
  • Documentation:

    • Improved clarity in plugin-architecture.md
    • Fixed typo changing "every where" to "everywhere"

New Features

  • Link Helper Enhancement: The link helper now works on projects outside of the workspace, making it more versatile for different development environments.
  • Health Check Status Codes: Added proper status code handling to health checks, improving API reliability and monitoring capabilities.
  • GraphQL Schema Extensions: Added support for loading extensions in GraphQL schemas, providing more flexibility when customizing GraphQL functionality.

Security Updates

No specific security fixes were mentioned in this release.

Performance Improvements

  • Middleware System Refactoring: Removed strapi.koaMiddlewares and simplified the middleware ordering algorithm, which should result in more efficient middleware processing and reduced overhead.

  • Error Handling Optimization: Improved error handling in plugin operations, particularly in the marketplace plugin list, which prevents unnecessary processing when errors occur.

Impact Summary

This release represents an important step in Strapi's evolution toward a more modern, async-first approach to middleware handling. The breaking change to middleware initialization aligns with JavaScript best practices by embracing async/await over callbacks.

The numerous GraphQL fixes address several pain points reported by the community, particularly around query limits, primary keys in custom resolvers, and schema extensions. These improvements make the GraphQL plugin more robust and reliable.

The simplified middleware ordering algorithm and removal of strapi.koaMiddlewares indicate Strapi's commitment to code simplification and maintainability. This should result in a more predictable middleware execution flow.

For developers, while the breaking change requires updates to custom middleware code, the migration path is clear and straightforward. The benefits of moving to async/await patterns include more readable code, better error handling, and alignment with modern JavaScript practices.

Full Release Notes

💥 Breaking changes

  • [Framework] Middlewares done receive a callback function anymore.

Before

module.exports = () => {
  return {
    initialize(cb) {
      // async code
      cb();
    },
  };
};

After

module.exports = () => {
  return {
   async  initialize() {
       // sync code or async code
     },
  };
};

🐛 Bug fix

💅 Enhancement

Statistics:

File Changed89
Line Additions1,187
Line Deletions1,004
Line Changes2,191
Total Commits33

User Affected:

  • Need to update middleware implementations to use async/await instead of callbacks
  • Benefit from improved GraphQL plugin stability with fixes for amountLimit, primaryKey, and schema extensions
  • Can now use link helper outside of the workspace
  • Will experience more reliable error handling for plugin operations

Contributors:

bkoshelevMichaelDonoalexandrebodinsoupette