add shared memory object to context

This commit is contained in:
2024-12-21 16:51:52 -08:00
parent 3cb15f7a5d
commit 0bb17e1b08
2 changed files with 14 additions and 3 deletions

View File

@@ -2,11 +2,12 @@ import { readFileSync } from "fs";
import { ApolloServer } from "@apollo/server";
import { startStandaloneServer } from "@apollo/server/standalone";
import { resolvers } from "./resolvers";
import { sharedMemory, SharedMemory } from "./sharedMemory";
const typeDefs = readFileSync("./schema.graphql", "utf8");
interface ServerContext {
sharedMemory: SharedMemory,
}
async function main() {
@@ -20,7 +21,9 @@ async function main() {
port: 4000,
},
context: async ({ req, res }) => {
return {}
return {
sharedMemory,
}
},
});

View File

@@ -1 +1,9 @@
export const
import { System } from "./generated/graphql";
export interface SharedMemory {
systems: System[],
};
export const sharedMemory: SharedMemory = {
systems: [],
};