You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Use GraphQL to query country-related data, free of charge and without restrictions. The data is the same as restcountries.eu with extra emoji's for flags because who doesn't like emoji's?
You can also select, paginate, filter, search and order any entity, the options are endless.
Once you have your desired query you can fetch the data like any other GraphQL endpoint but you probably want to use something like appolo client.
fetch('https://countries-274616.ew.r.appspot.com',{method: 'POST',headers: {'Content-Type': 'application/json'},body: JSON.stringify({query: ` query { CallingCode { name countries { name } } }`}),}).then(res=>res.json()).then(res=>console.log(res.data));
How it works
The data from restcountries.eu is scraped with a JS script and inserted into a Neo4j graph database. Afterwards the GraphQL schema is automagically infered by the awesome neo4j-graphql-js package. We add some custom cypher queries to the schema to make the shortest path and distance data possible. Finally an Apollo server is used to create the GraphQL endpoint and playground.
Self hosting
It's quite straightforward to host the API yourself, unfortunately I can't share a read only user to the Neo4j database since I don't have a Neo4j enterprise license so you will need your own Neo4j graph database
Populate the Neo4j graph database, run npm run dataScraping. When this command is done, you will get an infered schema file in the graphql repo, you can use this to optionally change the main schema.graphql file in the same repo