I was just chatting with the always inspiring Max today about GraphQL.I’ve never really used GraphQL in production but I am pretty excited about the flexibility it brings for clients to query data from a server. GraphQL provides a easily understandable description of the data an API provides and gives the client the possibility to query exactly the data it needs in one single request.
Currently I am not building any APIs but requesting data from Ethereum smart contracts, IPFS, etc. And one of the problems in my opinion is querying data from the different sources which adds quite some complexity and leads to loads of HTTP requests to get all the data.
For example: we store user profiles in a mapping:
mapping(address => string) public profiles;
They key is the user’s account address and the value is an IPFS hash containing detailed profile data.
To retrieve all profiles (including the data from IPFS) in our dAPP (client side JS) we would need to somehow iterate over the the mapping (which is already hard enough) and then request the profile object from IPFS.
Quite some code manage the fetching of some rather simple data and I actually don’t like that UI developers have to deal with that.
So the question arose if it is possible to create a GraphQL wrapper for smart contracts, IPFS objects, etc.?
Using the smart contract’s ABI and some custom resolvers this should be possible. The same wrapper API could make it easier for different clients and tools be built on top of that.
Now one could say we don’t want the additional server component, but as it is just loading data from the networks and prepares it for the UI I think that’s not a problem and just a useful addition to the dApp architecture.
The frontend and this GraphQL server component could still be deployed wherever and no central installation is required.
What do you think? did anyone try GraphQL in that context already?