wgOpenSource / gqlclans

MIT License
1 stars 0 forks source link

New code structure. Moved graphene clases to modules, split resolvers and models #22

Open frsv opened 6 years ago

frsv commented 6 years ago

Now gqlclans package has following structure:

[node_name]
    __init__.py
    models.py
    resolvers.py
    mutations.py
__init__.py
schema.py

To discuss

frsv commented 6 years ago

Current problems:

  1. It's still unclear where to store resolvers – as functions or as class methods
  2. Cross-imports: made hack here https://github.com/wgOpenSource/gqlclans/pull/22/files#diff-36ab087d880f0b7e3a8330a46d99960b

Pros:

  1. Clean and pythonic-way structure
  2. Easy to read and add new nodes
erm0l0v commented 6 years ago
  1. Cross-imports:

Looks like we can use this hack instead import hack)

def resolve_members(root, info):
    cls = info.return_type.of_type.graphene_type
    return map(lambda member: cls(
        name=member['account_name'],
        account_id=member['account_id'],
        role=member['role'],
        clanId=root.clan_id,
    ), root.members)