useQuery fix

This commit is contained in:
Riccardo
2021-01-04 18:48:05 +01:00
parent 61acbf02d8
commit 82055b4040
11 changed files with 405 additions and 381 deletions

View File

@@ -30,33 +30,33 @@ app.use('/graphql', graphqlHTTP({
}));
const server = new ApolloServer({
// typeDefs: fs.readFileSync(
// path.join(__dirname, 'schema.graphql'),
// 'utf8'
// ),
schema,
typeDefs: fs.readFileSync(
path.join(__dirname, 'schema.graphql'),
'utf8'
),
// schema,
cors: true,
playground: process.env.NODE_ENV === 'development' ? true : false,
// context: async ({ req }) => {
// // if (!db) {
// // try {
// // if (!dbClient.isConnected()) await dbClient.connect()
// // mongo = dbClient.db('Calendar') // database name
// // console.log(db);
// // } catch (e) {
// // console.log('--->error while connecting with graphql context (db)', e)
// // }
context: async ({ req }) => {
// if (!db) {
// try {
// if (!dbClient.isConnected()) await dbClient.connect()
// mongo = dbClient.db('Calendar') // database name
// console.log(db);
// } catch (e) {
// console.log('--->error while connecting with graphql context (db)', e)
// }
// return {
// ...req,
// mongoose,
// pubsub,
// userId:
// req && req.headers.authorization
// ? getUserId(req)
// : null
// }
// },
return {
...req,
mongoose,
pubsub,
// userId:
// req && req.headers.authorization
// ? getUserId(req)
// : null
}
},
// subscriptions: {
// onConnect: (connectionParams) => {
// if (connectionParams.authToken) {