Skip to content
Snippets Groups Projects
Verified Commit cbff13fa authored by Mark's avatar Mark
Browse files

Add create user mutation

parent d0e0b48d
No related branches found
No related tags found
No related merge requests found
......@@ -12,6 +12,19 @@ class User(SQLAlchemyObjectType):
exclude_fields = ("password")
interfaces = (relay.Node, )
class UserMutation(graphene.Mutation):
class Arguments:
username = graphene.String(required=True)
password = graphene.String(required=True)
email = graphene.String(required=True)
user = graphene.Field(User)
def mutate(self, info, username, password, email):
user = user_datastore.create_user(username=username, email=email, password=password)
user_datastore.commit()
return UserMutation(user=user)
class Application(SQLAlchemyObjectType):
class Meta:
model = ApplicationModel
......@@ -32,4 +45,8 @@ class Query(graphene.ObjectType):
query = User.get_query(info)
return query.filter(UserModel.username == username).first()
schema = graphene.Schema(query=Query)
class Mutation(graphene.ObjectType):
create_user = UserMutation.Field()
schema = graphene.Schema(query=Query, types=[User, Role, Application], mutation=Mutation)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment