mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-17 07:50:31 +00:00
add shared memory object to context
This commit is contained in:
@@ -2,11 +2,12 @@ import { readFileSync } from "fs";
|
|||||||
import { ApolloServer } from "@apollo/server";
|
import { ApolloServer } from "@apollo/server";
|
||||||
import { startStandaloneServer } from "@apollo/server/standalone";
|
import { startStandaloneServer } from "@apollo/server/standalone";
|
||||||
import { resolvers } from "./resolvers";
|
import { resolvers } from "./resolvers";
|
||||||
|
import { sharedMemory, SharedMemory } from "./sharedMemory";
|
||||||
|
|
||||||
const typeDefs = readFileSync("./schema.graphql", "utf8");
|
const typeDefs = readFileSync("./schema.graphql", "utf8");
|
||||||
|
|
||||||
interface ServerContext {
|
interface ServerContext {
|
||||||
|
sharedMemory: SharedMemory,
|
||||||
}
|
}
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
@@ -20,7 +21,9 @@ async function main() {
|
|||||||
port: 4000,
|
port: 4000,
|
||||||
},
|
},
|
||||||
context: async ({ req, res }) => {
|
context: async ({ req, res }) => {
|
||||||
return {}
|
return {
|
||||||
|
sharedMemory,
|
||||||
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1 +1,9 @@
|
|||||||
export const
|
import { System } from "./generated/graphql";
|
||||||
|
|
||||||
|
export interface SharedMemory {
|
||||||
|
systems: System[],
|
||||||
|
};
|
||||||
|
|
||||||
|
export const sharedMemory: SharedMemory = {
|
||||||
|
systems: [],
|
||||||
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user