import { EXAMPLE_DATA_LOADER } from ".";
import { ExampleModule } from "./module-types";

export const resolvers: ExampleModule.Resolvers = {
  Query: {
    world: async () => {
      return { x: 1, y: 2 };
    },
    worlds: async (_, { count }, ctx) => {
      const keys = Array.from({ length: count }, (_, i) => i.toString());

      return ctx.injector.get(EXAMPLE_DATA_LOADER).loadMany(keys);
    },
  },
  Mutation: {
    setMessage: async (_, { message }) => {
      return `Set message to: ${message}`;
    },
  },
};
