diff --git a/PetMonitoringSystemBackend/schema.py b/PetMonitoringSystemBackend/schema.py new file mode 100644 index 0000000..3f43c12 --- /dev/null +++ b/PetMonitoringSystemBackend/schema.py @@ -0,0 +1,14 @@ +import graphene + +from api import schema + + +class Query(schema.Query, graphene.ObjectType): + pass + + +class Mutation(schema.Mutation, graphene.ObjectType): + pass + + +schema = graphene.Schema(query=Query, mutation=Mutation) diff --git a/api/schema/RecordType.py b/api/schema/RecordType.py new file mode 100644 index 0000000..9562088 --- /dev/null +++ b/api/schema/RecordType.py @@ -0,0 +1,29 @@ +import graphene +from graphene_django.types import DjangoObjectType +from api.models import RecordType + + +class RecordTypeQL(DjangoObjectType): + class Meta: + model = RecordType + + +class RecordTypeDTO(graphene.InputObjectType): + type = graphene.String() + + +class CreateRecordType(graphene.Mutation): + class Arguments: + record_type_data = RecordTypeDTO() + + success = graphene.Boolean() + record_type = graphene.Field(RecordTypeQL) + + def mutate(self, info, record_type_data): + record_type = RecordType( + type=record_type_data.type + ) + record_type.save() + return CreateRecordType(record_type=record_type, success=True) + +