moleculer-apollo-server provides an Apollo GraphQL server as a mixin for the Moleculer API Gateway, enabling easy integration of GraphQL endpoints within a Moleculer microservices architecture. It allows developers to define GraphQL queries and mutations directly within Moleculer service actions, automatically generating a unified GraphQL schema. The current stable version is 0.4.1, released recently with updates to Moleculer 0.15.0 and Apollo Server 5. This package differentiates itself by tightly coupling GraphQL schema definition with Moleculer actions, streamlining the process of exposing microservice capabilities via GraphQL. It also offers advanced features like inter-service resolvers and subscription support. The release cadence appears to be moderate, with significant breaking changes typically occurring with major Apollo Server version upgrades, as seen in the recent v0.4.0 release.
npm install moleculer-apollo-serverVerified import paths — ran on the pinned version, not inferred.
This example sets up a Moleculer API Gateway with `moleculer-apollo-server` to expose GraphQL endpoints, demonstrating basic query and mutation definitions from a Moleculer service.
Consult Apollo Server's official migration documentation (e.g., v2 to v3, v3 to v4, v4 to v5) and update your `ApolloService` configuration, including `typeDefs`, `resolvers`, and `serverOptions`, to align with Apollo Server 5 API.
Upgrade your Node.js environment to version 20.x.x or higher. Verify other project dependencies for compatibility with Node.js 20.
Refactor your application to handle GraphQL file uploads through an alternative mechanism. This typically involves using a separate REST endpoint or a dedicated file upload service, then referencing the uploaded files in GraphQL mutations.
Implement a custom healthcheck endpoint within your Moleculer API Gateway using a standard `moleculer-web` route, or rely on Kubernetes/Docker healthcheck mechanisms that don't depend on the Apollo Server's internal endpoint.
Update your `moleculer` package to `^0.15.0` to ensure full compatibility and leverage the latest features and fixes. You may need to run `npm install moleculer@^0.15.0` or `yarn add moleculer@^0.15.0`.
Ensure `serverOptions` is correctly defined within the `ApolloService` mixin configuration, adhering to the Apollo Server 5 constructor options. For example, `serverOptions: { plugins: [...] }`.Verify that `graphql` is installed and meets the `^16.0.0` peer dependency requirement. Rebuild the project if using TypeScript, and ensure `typeDefs` and `resolvers` are valid GraphQL SDL and resolver maps.
Install the `moleculer-web` package: `npm install moleculer-web` or `yarn add moleculer-web`. Ensure it is added to your project's dependencies.
Ensure your `package.json` specifies `"type": "module"` for ES Modules, or use CommonJS `require()` syntax if not. Also, verify your `tsconfig.json` `module` option is appropriate (e.g., `"module": "Node16"` or `"ESNext"`).