wgOpenSource / gqlclans

MIT License
1 stars 0 forks source link

Add accounts list method from Wargaming.net/Accounts section #25

Closed frsv closed 6 years ago

frsv commented 6 years ago

Add account info endpoint and merge data which this API provides with clan members info. Also add helper function which gives a dictionary of requested fields in resolvers. This function made it possible to decide, which fields are needed and make requests only for them. For example, if we make query like

query accounts(accountIds: ["12345"]) {
    nickname
    createdAt
}

we can determine that in our query there aren't fields which are specific only for clan info data, so we can do only one request to account/info

The code could seem tricky, but it solves the issue. The main moment is that graphene camelcases every field in nodes, but out API returns data with keys in snakecase, so we have to dance around it with snakecase() and camelcase() functions. In future we'll have a better architecture for load balancing and solving the problems how to load and combine data, I hope.

Also, because of members in clan info method have account_name field, which is completely the same as nickname in account info method I was forced to add workaround which add to result nickname field either account_name value or nickname value