Skip to content

Instantly share code, notes, and snippets.

@kluu1
Last active March 23, 2020 15:36
Show Gist options
  • Select an option

  • Save kluu1/f5bebf478d96865ab825bb0753d00d9a to your computer and use it in GitHub Desktop.

Select an option

Save kluu1/f5bebf478d96865ab825bb0753d00d9a to your computer and use it in GitHub Desktop.
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