Conversation
- Made makeExecutableSchema method async in service.js - Made generateGraphQLSchema method async since it calls makeExecutableSchema - Added await to all calling places to maintain proper async flow - Updated TypeScript definitions to reflect Promise return types - Updated CHANGELOG.md to document the changes 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
|
@icebob This is awesome! A little while ago I discovered a race condition in We're running a local patch where we wrapped |
|
@kthompson23 please share your solution |
@icebob Here's my branch. I added the async-mutex package and wrapped the schema rebuild in the |
@kthompson23 Are there any reason of using async-mutex library instead of a simple "preparing: boolean` property what I set to true at the fbeginning of the methods and return if true to avoid parallel executions? |
@icebob The issue is that |
|
@kthompson23 do you have any idea how I can reproduce this situation in integration tests? |
I'm not entirely sure. When I first "audited" this code, I decided to add the mutex because I thought we were doing redundant work. Two requests can enter What if you first called |
- Updated eslint to version 9.36.0 - Updated jest and jest-cli to version 30.1.3 - Updated npm-check-updates to version 18.3.0 - Updated tsx to version 4.20.5 - Added a promise-based mechanism to prevent multiple preparations of the GraphQL schema in service.js - Implemented a test case to verify that the GraphQL schema is not prepared multiple times concurrently
Summary
This PR upgrades the Moleculer Apollo Server integration from Apollo Server 2 to Apollo Server 5, bringing significant modernization and breaking changes.
Breaking Changes
graphql-subscriptionstographql-wsMajor Updates
makeExecutableSchemaandgenerateGraphQLSchemamethods async for better async/await supportRemoved Features
Files Changed
src/service.jssrc/ApolloServer.jsfor Apollo Server 5 compatibilityThis is a major version bump (0.4.0) due to the breaking changes introduced by the Apollo Server 5 migration.