updated codegen, added client query generation, etc.
This commit is contained in:
parent
864f37a652
commit
9518787206
17 changed files with 5244 additions and 445 deletions
|
|
@ -14,7 +14,7 @@ import { Query, Mutation, Subscription } from "./graphql/graphql";
|
|||
const __dirname = import.meta.dirname;
|
||||
const HOST = process.env.VITE_HOST || "localhost";
|
||||
const PORT = parseInt(process.env.VITE_PORT || "3000");
|
||||
const MOTD = `\n\n\n\x1b[35m-server is listening-\x1b[0m\n\nhttp://${HOST}:${PORT}\nhttp://localhost:${PORT}\n\n\n`;
|
||||
const MOTD = `\n\n\n\x1b[35m-server is listening at...-\x1b[0m\n\nhttp://${HOST}:${PORT}\nhttp://localhost:${PORT}\n\n\n`;
|
||||
|
||||
const app = express();
|
||||
const server = http.createServer(app);
|
||||
|
|
@ -30,7 +30,11 @@ const resolvers = {
|
|||
// Subscription,
|
||||
};
|
||||
|
||||
const apollo = new ApolloServer({
|
||||
interface IdentityContext {
|
||||
authScope?: String;
|
||||
}
|
||||
|
||||
const apollo = new ApolloServer<IdentityContext>({
|
||||
typeDefs,
|
||||
resolvers,
|
||||
plugins: [ApolloServerPluginDrainHttpServer({ httpServer: server })],
|
||||
|
|
@ -42,7 +46,16 @@ app.use(
|
|||
"/graphql",
|
||||
cors<cors.CorsRequest>(),
|
||||
express.json(),
|
||||
expressMiddleware(apollo),
|
||||
expressMiddleware(apollo, {
|
||||
context: async ({ req, res }) => {
|
||||
const token = req.headers.authorization || "";
|
||||
// const user = await getUser(token);
|
||||
|
||||
const user = "user";
|
||||
|
||||
return { user };
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
await new Promise<void>((resolve) =>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue