1.4.4 • Published 9 days ago

@mvf/servicer-apollo v1.4.4

Weekly downloads
-
License
MIT
Repository
-
Last release
9 days ago

MVF servicer Apollo

Usage

To install the package

Run npm install @mvf/servicer-apollo

Configuration

Set the following environment variables in your project

  • ENVIRONMENT_FILE should be set to one of development | testing | staging | production
  • APOLLO_SERVER_PORT defaults to 80

Servicer Apollo

To setup Servicer Apollo you will need an entrypoint.ts or equivalent file.

import { Application, DaemonCommand } from "@mvf/servicer";
import { Apollo, Resolvers, IApolloConfig } from "@mvf/servicer-apollo";
import { ApolloEventSources } from "EventSources";
import schema, { actionResolvers, dataSources, graphqlResolvers } from "Services/Apollo";
import { verifyToken } from "Services/Middleware/Auth/Auth";

const environmentConfig: IApolloConfig = process.env.ENVIRONMENT_FILE === "development" ? {
  playground: true,
  introspection: true,
} : {};

const config: IApolloConfig = {
  context: verifyToken,
  dataSources,
  ...environmentConfig,
};

const setupApplication = async () => {
  const application = new Application();
  const resolvers = new Resolvers(ApolloEventSources, actionResolvers(), graphqlResolvers());
  application.addCommands(
    new DaemonCommand(new Apollo(resolvers, schema, config)),
  );
  await application.run();
};

setupApplication();

Contributing

Setup

  • Run make to build the container
  • Run make shell to enter the container
  • Run npm install to install dependencies

Refer to package.json for commands

After merging

After you have merged a PR to master, you need to rebuild and publish your changes.

  1. Checkout master git checkout master && git pull
  2. Use one of the following make publish commands to publish changes:
    • make publish kind=patch - Use this if your change is a bug fix and is backwards compatible.
    • make publish kind=minor - Use this if your change adds new functionality and is backwards compatible.
    • make publish kind=major - Use this if your change is not backwards compatible.