feat: Implement authentication with JWT
This commit is contained in:

committed by
Ömer Faruk Aydın

parent
f883dd1287
commit
c935f3f691
@@ -1,18 +1,20 @@
|
||||
import { graphqlHTTP } from 'express-graphql';
|
||||
import graphQLSchema from '../graphql/graphql-schema'
|
||||
import graphQLSchema from '../graphql/graphql-schema';
|
||||
import logger from '../helpers/logger';
|
||||
import { applyMiddleware } from 'graphql-middleware';
|
||||
import authentication from '../helpers/authentication';
|
||||
|
||||
const graphQLInstance = graphqlHTTP({
|
||||
schema: graphQLSchema,
|
||||
schema: applyMiddleware(graphQLSchema, authentication),
|
||||
graphiql: true,
|
||||
customFormatErrorFn: (error) => {
|
||||
logger.error(error.path + ' : ' + error.message + '\n' + error.stack)
|
||||
logger.error(error.path + ' : ' + error.message + '\n' + error.stack);
|
||||
|
||||
return {
|
||||
message: error.message,
|
||||
locations: error.locations
|
||||
}
|
||||
}
|
||||
})
|
||||
locations: error.locations,
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
export default graphQLInstance;
|
||||
|
Reference in New Issue
Block a user