async def resolve_notify(self, info, id, text): if id == '': id = info.context['user'].id fields = get_projection(info, True) user = await info.context['request'].app.mongo.trader.users.find_one({'_id': ObjectId(id)}, fields) if user['subscription']: send_web_push(user['subscription'], text) return 'Success' else: return 'No subscription'
def get_user_projection_and_mongo(info): if 'request' in info.context: id = info.context['request'].user.display_name else: id = info.context['user']['_id'] fields = get_projection(info, True) if 'request' in info.context: client = info.context['request'].app.mongo else: client = info.context['client'] return id, fields, client
async def resolve_wallet_types(self, info): fields = get_projection(info, True) result = [] async for document in info.context['request'].app.mongo.trader.wallet_types.find({}, fields): result.append(document) return result
async def resolve_coin_gecko(self, info): fields = get_projection(info, True) coin_gecko = await info.context['request'].app.mongo.trader.coin_gecko.find_one({}, fields) return coin_gecko