Created
August 1, 2020 19:24
-
-
Save shrirambalakrishnan/ff74403019e0cf5df5a3330cf7eea608 to your computer and use it in GitHub Desktop.
This file contains 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 resolvers = { | |
UserType: { | |
posts: (parent, _, ctx) => { | |
return ctx.postsLoader.load(parent.id); | |
} | |
}, | |
Query: { | |
users: async () => { | |
try { | |
return await User.findAll() | |
} catch (e) { | |
console.log(e) | |
} | |
}, | |
}, | |
}; | |
const server = new ApolloServer({ | |
typeDefs, | |
resolvers, | |
context: async ({req}) => { | |
return { | |
postsLoader: postsLoader | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment