-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
|
||
|