def mutate(self, info, **kwargs): from_name = kwargs.pop('from_name') to_name = kwargs.pop('to_name') relationship_type = kwargs.pop('relationship_type') repository = PersonRelations(info.context.graph_db) success = repository.add_relation(from_name, to_name, RelationshipType[relationship_type]) return AddRelationship(success=success)
def resolve_people_with_parents(self, info): repository = PersonRelations(info.context.graph_db) peoples = repository.find_people() output = [] for person in peoples: output.append( PeopleWithRelations( person_name=person.name ) ) return output
def mutate(self, info, name, birthdate, gender): person_input = {'name': name, 'birthdate': birthdate, 'gender': gender} repository = PersonRelations(info.context.graph_db) person = repository.update_or_create(person_input) return CreatePerson(person=person, success=True)
def mutate(self, info, person_input): input_data = input_to_dictionary(person_input) repository = PersonRelations(info.context.graph_db) person = repository.update_or_create(input_data) return BasePersonMutation(updated_person=person, success=True)
def resolve_grandparents(self, info, name): repository = PersonRelations(info.context.graph_db) check_name(repository, name) return list_to_schema(repository.find_grandparents(name))
def resolve_person(self, info, name): repository = PersonRelations(info.context.graph_db) person = check_name(repository, name) return PersonSchema(**person.as_dict())
def resolve_people(self, info, **kwargs): repository = PersonRelations(info.context.graph_db) return repository.find_people()
def resolve_married_with(self, info, **kwargs): repository = PersonRelations(info.context.graph_db) check_name(repository, self.person_name) return list_to_schema(repository.find_partner(self.person_name))