import graphene
from graphene import relay
from graphene_sqlalchemy import SQLAlchemyObjectType

from app.models.todos import Todo as TodoModel
from app.cruds.todos import insert_todo

#-------------------------
# Query
#-------------------------
class Todo(SQLAlchemyObjectType):
    class Meta:
        model = TodoModel
        interface = (relay.Node, )

class TodoConnections(relay.Connection):
    class Meta:
        node = Todo

#-------------------------
# Mutation
#-------------------------
class InsertTodo(relay.ClientIDMutation):
    class Input:
        user_id = graphene.Int(required=True)
        title = graphene.String(required=True)
        description = graphene.String(required=True)
        deadline = graphene.DateTime(required=True)
    
    todo = graphene.Field(Todo)

    @classmethod
    def mutate_and_get_payload(cls, root, info, user_id, title, description, deadline):
        todo = insert_todo(user_id, title, description, deadline)
        return InsertTodo(todo)
942d1ed098bfd8dc0bf857816356b101341050b1
<mask token>


class InsertTodo(relay.ClientIDMutation):


    class Input:
        user_id = graphene.Int(required=True)
        title = graphene.String(required=True)
        description = graphene.String(required=True)
        deadline = graphene.DateTime(required=True)
    <mask token>

    @classmethod
    def mutate_and_get_payload(cls, root, info, user_id, title, description,
        deadline):
        todo = insert_todo(user_id, title, description, deadline)
        return InsertTodo(todo)

<mask token>


class TodoConnections(relay.Connection):


    class Meta:
        node = Todo


class InsertTodo(relay.ClientIDMutation):


    class Input:
        user_id = graphene.Int(required=True)
        title = graphene.String(required=True)
        description = graphene.String(required=True)
        deadline = graphene.DateTime(required=True)
    todo = graphene.Field(Todo)

    @classmethod
    def mutate_and_get_payload(cls, root, info, user_id, title, description,
        deadline):
        todo = insert_todo(user_id, title, description, deadline)
        return InsertTodo(todo)

<mask token>


class Todo(SQLAlchemyObjectType):


    class Meta:
        model = TodoModel
        interface = relay.Node,


class TodoConnections(relay.Connection):


    class Meta:
        node = Todo


class InsertTodo(relay.ClientIDMutation):


    class Input:
        user_id = graphene.Int(required=True)
        title = graphene.String(required=True)
        description = graphene.String(required=True)
        deadline = graphene.DateTime(required=True)
    todo = graphene.Field(Todo)

    @classmethod
    def mutate_and_get_payload(cls, root, info, user_id, title, description,
        deadline):
        todo = insert_todo(user_id, title, description, deadline)
        return InsertTodo(todo)

import graphene
from graphene import relay
from graphene_sqlalchemy import SQLAlchemyObjectType
from app.models.todos import Todo as TodoModel
from app.cruds.todos import insert_todo


class Todo(SQLAlchemyObjectType):


    class Meta:
        model = TodoModel
        interface = relay.Node,


class TodoConnections(relay.Connection):


    class Meta:
        node = Todo


class InsertTodo(relay.ClientIDMutation):


    class Input:
        user_id = graphene.Int(required=True)
        title = graphene.String(required=True)
        description = graphene.String(required=True)
        deadline = graphene.DateTime(required=True)
    todo = graphene.Field(Todo)

    @classmethod
    def mutate_and_get_payload(cls, root, info, user_id, title, description,
        deadline):
        todo = insert_todo(user_id, title, description, deadline)
        return InsertTodo(todo)

import graphene
from graphene import relay
from graphene_sqlalchemy import SQLAlchemyObjectType

from app.models.todos import Todo as TodoModel
from app.cruds.todos import insert_todo

#-------------------------
# Query
#-------------------------
class Todo(SQLAlchemyObjectType):
    class Meta:
        model = TodoModel
        interface = (relay.Node, )

class TodoConnections(relay.Connection):
    class Meta:
        node = Todo

#-------------------------
# Mutation
#-------------------------
class InsertTodo(relay.ClientIDMutation):
    class Input:
        user_id = graphene.Int(required=True)
        title = graphene.String(required=True)
        description = graphene.String(required=True)
        deadline = graphene.DateTime(required=True)
    
    todo = graphene.Field(Todo)

    @classmethod
    def mutate_and_get_payload(cls, root, info, user_id, title, description, deadline):
        todo = insert_todo(user_id, title, description, deadline)
        return InsertTodo(todo)