threefoldtech / tfchain_graphql

Graphql for TFchain
Apache License 2.0
2 stars 3 forks source link

Fix: Switch to restcountries v3 API and use common country name #158

Closed sameh-farouk closed 4 months ago

sameh-farouk commented 5 months ago

What's changed:

Related Issues:

Description:

This is a temporary, easy workaround fix for the issue https://github.com/threefoldtech/tfchain_graphql/issues/148.

However, although it should resolve the mismatch for the reported countries, it is important to note that this fix may not work for all countries as the process of joining data from different APIs based on country names is not reliable.

To elaborate, in our squid processor, we fetch cities from the repository available at https://raw.githubusercontent.com/shivammathur/countrycity/master/data/geo.json and countries from the https://restcountries.com/ API. We then join these data based on the country name. Similarly, in the Gridproxy, we fetch node data from the chain and county data from GraphQL and join it based on the country name.

This process is not always accurate as there are often alternative spellings for country names. Hence, unless you are using the same data source, it's not guaranteed to find a match.

To properly resolve this issue, I suggest using the same API or a more unique identifier such as country code. However, this would require changes in different services.