This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Query: { | |
| templates: requiresLogin((parent, args, { user }) => { | |
| return service.fetchForUser(user.uuid) | |
| }), | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const requiresLogin = resolver => (parent, args, context, info) => { | |
| if (context.user && context.user.role === 'MEMBER') { | |
| return resolver(parent, args, context, info) | |
| } else { | |
| throw new AuthenticationError('Unauthorized') | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Query: { | |
| templates: (parent, args, { user }) => { | |
| if (user && user.role === 'MEMBER') { | |
| return service.fetchForUser(user.uuid) | |
| } else { | |
| throw new AuthenticationError('No Access!') | |
| } | |
| }, | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const { AuthenticationError } = require('apollo-server-express') | |
| const apollo = new ApolloServer({ | |
| ...schema, | |
| context: ({ req }) => { | |
| const { user } = req | |
| if (!user || user.role !== 'MEMBER') { | |
| throw new AuthenticationError('No Access!') | |
| } else { | |
| return { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const apollo = new ApolloServer({ | |
| ...schema, | |
| context: ({ req }) => ({ | |
| user: req.user, | |
| }), | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| app.use(passport.initialize()) | |
| app.use(passport.session()) | |
| const apollo = new ApolloServer(schema) | |
| apollo.applyMiddleware({ app }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <root> | |
| <child> | |
| <grandchild> | |
| Some text | |
| </grandchild> | |
| </child> | |
| </root> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function testFunction() { | |
| console.log('just log me1!'); | |
| return 32; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <root> | |
| <child> | |
| <grandchild> | |
| Some text | |
| </grandchild> | |
| </child> | |
| </root> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function testFunction() { | |
| console.log('just log me!'); | |
| return 32; | |
| } |