Last active
March 23, 2020 15:36
-
-
Save kluu1/f5bebf478d96865ab825bb0753d00d9a to your computer and use it in GitHub Desktop.
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
| import Nomics from 'nomics' | |
| const nomics = new Nomics({ | |
| apiKey: process.env.API_KEY | |
| }) | |
| const resolvers = { | |
| Query: { | |
| getCoins: async (_, args) => { | |
| // fetches all coins from nomics | |
| const coins = await nomics.currenciesTicker() | |
| // let's only return the top 30 | |
| return coins.slice(0, 30) | |
| }, | |
| getCoinDetails: async (_, args) => { | |
| const { coinid, interval } = args | |
| // fetch coin from nomics for specified interval | |
| const fetchCoinDetails = await nomics.currenciesTicker({ | |
| ids: [`${coinid}`.toUpperCase()], | |
| interval: [`${interval}`] | |
| }) | |
| return fetchCoinDetails[0][`${interval}`] | |
| } | |
| } | |
| } | |
| export default resolvers |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment