I am trying to implement GraphQL but always get the error of Expected iterable. As I understand there can be an error with the types, but i tried everything and don't know what to do
that's what my API returns
{
"data": [
{
"id": "bitcoin",
"rank": "1",
"symbol": "BTC",
"name": "Bitcoin",
"supply": "17193925.0000000000000000",
"maxSupply": "21000000.0000000000000000",
"marketCapUsd": "119150835874.4699281625807300",
"volumeUsd24Hr": "2927959461.1750323310959460",
"priceUsd": "6929.8217756835584756",
"changePercent24Hr": "-0.8101417214350335",
"vwap24Hr": "7175.0663247679233209"
},
......
]
}
and here is my code
const coinType = new GraphQLObjectType({
name: 'Coin',
fields: () => ({
id: { type: GraphQLString },
name: { type: GraphQLString },
})
});
// Root Query
const RootQuery = new GraphQLObjectType({
name: 'RootQueryType',
fields: () => ({
coin: {
type: new GraphQLList(launchType),
resolve(parent, args) {
return axios
.get('https://api.coincap.io/v2/assets')
.then(res => res.data);
}
},
})
});
module.exports = new GraphQLSchema({
query: RootQuery
});