Great job! I hope core team bold this out, this is huge good news!
GraphQL interface for Core and Horizon databases
Worth noting I also have test and pub Horizon instances running.
@tyvdh I had this same idea today (building a GraphQL layer on top of the ledger). I hadn't thought of using postgraphql, though.
If you're willing to open the project up to receive contributions, I'd be happy to be part of it!
If not, it'd be great to keep in touch anyway, since I plan to put together a UI that allows the blockchain to be visualised as a graph structure.
codesmithtech Awesome! Definitely planning on opening this up and will be looking for help.
- Edited
Got a simple Docker image set up for exposing a PostgreSQL database to a GraphQL endpoint via PostGraphile.
https://github.com/TinyAnvil/postgraphile-docker
https://hub.docker.com/r/tyvdh/postgraphile
Next up a docker compose to tie it all together.
And here we are!
A fully functional docker-compose set to run the https://github.com/stellar/docker-stellar-core-horizon in concert with https://github.com/TinyAnvil/postgraphile-docker.
https://github.com/TinyAnvil/glysh-docker.
Now I just need to write a detailed tutorial and maybe record a video walk through.
Medium article laying out how to get everything running on your own servers.
https://medium.com/@tyvdh/building-stellar-apps-36303d0e6f45
For those who want kick start example
1. Open https://core.gly.sh/graphiql
2. Fill this and run
{
allAccountdata {
totalCount
nodes {
id
}
}
}
3. Smile! ?
Recorded a three series of tutorials expanding on that Medium article.
Stellar PostgreSQL to GraphQL: Lesson 1
Stellar PostgreSQL to GraphQL: Lesson 2
Stellar PostgreSQL to GraphQL: Lesson 3
Can we have some examples on how to use this?
- Edited
query {
allHistoryOperations(first: 1, filter: { details: { equalTo: "{ selling_asset_code: \"USD\" }" } }) {
nodes {
transactionId
details
type
}
}
}
tyvdh
I'm trying that query in your https://horizon-test.gly.sh/graphiql and it doesn't work correctly (no data). What I'm missing here?
Thank you.
Edit: actually, filtering by details doesn't seem to work as expected.
jfuentes I'm using this plugin for the filtering https://github.com/mattbretl/postgraphile-plugin-connection-filter. I have a pending request to see how to filter by a nested JSON key. I wasn't able to get it to work either.
dzham Wrote a little reply to the Medium post with some examples.
https://medium.com/@tyvdh/fair-enough-6da46b0734aa
- Edited
Hey Tyler this is absolutely beautiful! Forgive my ignorance about GraphQL but where can we get a list of all entities/fields in order to build some queries? This stuff is amazing!
* facepalm * Top/right there is a Docs link
Torkus Best place is just to explore the "Docs" -> "Query" on the graphiql page itself.
And then too for some inspiration you can read https://medium.com/@tyvdh/fair-enough-6da46b0734aa
- Edited
Thanks, I'm in love!
Hey quick question, can we submit queries using plain http POST? Is there any API endpoint for that? I played with the web UI which is cool but I'd like to make a query once in a while from a program to check for trustlines which is something StellarSDKs lack and it is in urgent need the more tokens get created. Someday when I grow up I'll get my own node and your posts are perfect guides for that but for now I'd be more than happy to hit your service once a day while I get used to server stuff.
* To expand, I saw the links to https://api-test.gly.sh and https://api.gly.sh but do they get graphiql queries in the post body so we get the same responses as the web UI? The ones I tried are just proxies to horizon responses which is not what I want.