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