feat: Implement authentication with JWT

This commit is contained in:
Faruk AYDIN
2022-03-05 19:58:52 +03:00
committed by Ömer Faruk Aydın
parent f883dd1287
commit c935f3f691
9 changed files with 199 additions and 31 deletions

View File

@@ -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;