Closed freeseamew closed 3 years ago
There is an Apollo Server v3 example, using Koa:
It's linked in the readme “Usage” section.
Your question is really a usage question about Apollo Server; particularly what their v3 API for Express is. Please raise usage questions about Apollo with the Apollo community.
I'm using meter and apolo.
I uploaded apollo-server-3 and looked at the document. (https://www.apollographql.com/docs/apollo-server/data/file-uploads/)
I saw that they told me to upload the file using graphql-upload
.
Currently, I have set up and used meteorJs and apollo as follows.
I'm asking how to add a graphql-upload
setting to this part.
const server = new ApolloServer({
playground: true,
schema,
plugins: [
...
],
context: async({req}) => ({
user: await getUser(req.headers.authorization)
})
});
await server.start();
server.applyMiddleware({
app: WebApp.connectHandlers,
cors: true,
path: '/graphql',
});
I don't use Meteor, so can't give you any advice about it. Once you figure it out, feel free to leave a follow-up comment here with the answer in case it helps other Meteor users.
The conclusion was solved by loading express as follows.
I hope it will help someone.
...
(async function(){
...
const server = new ApolloServer({
playground: true,
schema,
plugins: [
...
],
context: async({req}) => ({
user: await getUser(req.headers.authorization) ;
}),
});
await server.start();
const app = express(); // This is important!
app.use(graphqlUploadExpress()); // This is important!
WebApp.connectHandlers.use('/graphql', app); // This is important!
WebApp.connectHandlers.use("/graphql", (req, res, next) => {
if (req.method === "GET") {
console.log('Test!!!!!!');
res.end()
}
if(req.method ==="POST") {
console.log('@@@@')
console.log(`req: ${JSON.stringify(req.body) }`);
}
next();
});
server.applyMiddleware({
app,
cors: true,
path: '/graphql',
});
})();
As far as I know, file upload has also changed in apollo server 3. May I know how to set the next code in meter?