Ivan Asmer %!s(int64=5) %!d(string=hai) anos
pai
achega
cbe800bbbf
Modificáronse 1 ficheiros con 7 adicións e 0 borrados
  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) => { 
     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 operationMatch = gql.query.match(/\{\s*([a-zA-Z]+)\s*/)
         const operationName  = operationMatch[1]
         const operationName  = operationMatch[1]
         const authorization = req.headers.authorization 
         const authorization = req.headers.authorization