Ivan Asmer 5 years ago
parent
commit
cbe800bbbf
1 changed files with 7 additions and 0 deletions
  1. 7 0
      index.js

+ 7 - 0
index.js

@@ -386,6 +386,13 @@ const anonResolvers = ['login', 'createUser'];
     }
 
     app.use('/graphql', express_graphql(async (req, res, gql) => { 
+        if (!gql.query){
+            return {
+                schema: schema,
+                rootValue: rootResolvers,
+                graphiql: true, 
+            }
+        }
         const operationMatch = gql.query.match(/\{\s*([a-zA-Z]+)\s*/)
         const operationName  = operationMatch[1]
         const authorization = req.headers.authorization