Fakultas Ilmu Komputer UI

Commit 3b25d162 authored by addffa's avatar addffa
Browse files

[GREEN] implementasi delete datasource mutation

parent 503ec723
Pipeline #51246 passed with stage
in 10 minutes and 10 seconds
......@@ -2,9 +2,15 @@ import graphene
from graphene_django.forms.mutation import DjangoModelFormMutation
from .forms import MustahikForm, DataSourceForm, DataSourceWargaForm, DataSourceInstitusiForm, DataSourcePekerjaForm
from .models import Mustahik
from .types import MustahikType, DataSourceInstitusiType, DataSourcePekerjaType, DataSourceWargaType, DataSourceType
from .forms import (
MustahikForm, DataSourceForm, DataSourceWargaForm,
DataSourceInstitusiForm, DataSourcePekerjaForm
)
from .models import Mustahik, DataSource
from .types import (
MustahikType, DataSourceInstitusiType,
DataSourcePekerjaType, DataSourceWargaType, DataSourceType
)
class MustahikMutation(DjangoModelFormMutation):
......@@ -31,24 +37,39 @@ class DeleteMustahik(graphene.Mutation):
deleted = True
return DeleteMustahik(deleted=deleted, id_mustahik=id, name=name, no_ktp=no_ktp)
class DataSourceMutation(DjangoModelFormMutation):
dataSource = graphene.Field(DataSourceType)
class Meta:
form_class = DataSourceForm
class DeleteDataSource(graphene.Mutation):
class Arguments:
id = graphene.ID()
deleted = graphene.Boolean()
def mutate(self, info, id):
DataSource.objects.get(pk=id).delete()
return DeleteDataSource(deleted=True)
class DataSourceWargaMutation(DjangoModelFormMutation):
dataSourceWarga = graphene.Field(DataSourceWargaType)
class Meta:
form_class = DataSourceWargaForm
class DataSourceInstitusiMutation(DjangoModelFormMutation):
dataSourceInstitusi = graphene.Field(DataSourceInstitusiType)
class Meta:
form_class = DataSourceInstitusiForm
class DataSourcePekerjaMutation(DjangoModelFormMutation):
dataSourcePekerja = graphene.Field(DataSourcePekerjaType)
......
......@@ -5,7 +5,7 @@ from graphene_django import DjangoObjectType
from .mustahik.mutations import (
MustahikMutation, DeleteMustahik, DataSourceMutation,
DataSourceWargaMutation, DataSourceInstitusiMutation,
DataSourcePekerjaMutation
DataSourcePekerjaMutation, DeleteDataSource
)
from .mustahik.query import MustahikQuery
......@@ -24,10 +24,11 @@ class Query(MustahikQuery, graphene.ObjectType):
class Mutation(graphene.ObjectType):
mustahik_mutation = MustahikMutation.Field()
delete_mustahik = DeleteMustahik.Field()
dataSource_mutation = DataSourceMutation.Field()
dataSourceWarga_mutation = DataSourceWargaMutation.Field()
dataSourceInstitusi_mutation = DataSourceInstitusiMutation.Field()
dataSourcePekerja_mutation = DataSourcePekerjaMutation.Field()
data_source_mutation = DataSourceMutation.Field()
data_source_warga_mutation = DataSourceWargaMutation.Field()
data_source_institusi_mutation = DataSourceInstitusiMutation.Field()
data_source_pekerja_mutation = DataSourcePekerjaMutation.Field()
delete_data_source = DeleteDataSource.Field()
schema = graphene.Schema(query=Query, mutation=Mutation)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment