Skip to content

Hot module reloading with Webpack #289

@DevNebulae

Description

@DevNebulae

Describe the issue
Currently, the library provides no documentation on how to implement hot module reloading in combination with Webpack. Is it even possible? If so, how can one achieve this?

Are you able to make a PR that fix this?
At the moment, just looking for a hotfix.

index.ts

import "reflect-metadata";
import { ApolloServer } from "apollo-server";
import { environment } from "./Environment";
import { buildSchema } from "type-graphql";
import BoardResolver from "./types/boards/BoardResolver";

async function bootstrap() {
  const schema = await buildSchema({
    resolvers: [BoardResolver]
  });

  const server = new ApolloServer({
    schema
  });

  server.listen(environment.port).then(({ url }) => {
    console.log(`Server is ready at ${url}`);
  });

  if (module.hot) {
    module.hot.accept();
    module.hot.dispose(() => server.stop());
  }
}

bootstrap();

Result
Every time I reload a type, the module throws this error:

UnhandledPromiseRejectionWarning: Error: Schema must contain unique named types but contains multiple types named "Board".

Metadata

Metadata

Assignees

No one assigned

    Labels

    Question ❔Not future request, proposal or bug issueSolved ✔️The issue has been solved

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions