Having problem setting up hook for Feathersjs + Apollo v2. Main reason needing it is for authorization.
src/services/graphql/graphql.service.js:65
service.hooks(hooks);
^
TypeError: Cannot read property 'hooks' of undefined
Following is my codes for setting up Apollo v2 in Feathersjs service. Since it does not carry a model, I'm not sure what's the correct way to set up the hook.
const { ApolloServer, gql } = require('apollo-server-express');
const hooks = require('./graphql.hooks');
module.exports = function (app) {
const typeDefs = gql`
type Query {
hello: String
}
`;
const resolvers = {
Query: {
hello: () => 'hello world'
}
};
const server = new ApolloServer({
typeDefs: typeDefs,
resolvers: resolvers,
context: ({req, res}) => ({
provider: req.feathers.provider,
headers: req.feathers.headers,
token: req.headers['auth-token']
}),
playground: {
endpoint: 'http://localhost:3030/graphql',
settings: {
'editor.theme': 'light'
}
}
});
server.applyMiddleware({ app });
// app.use('/graphql', createService);
const service = app.service('graphql');
service.hooks(hooks);
};