我如何将石墨烯反序列化突变输入?

时间:2019-05-16 16:28:12

标签: graphene-python

我正在使用graphene-django==2.2.0。我如何将石墨烯反序列化一个突变输入?

最终目标是,当我开始使用id方法中的mutate_and_get_payload字段时,id字段将已经被DO_X函数解析< / p>

class Mutation(relay.ClientIDMutation):
    class Input:
        id = graphene.ID(required=True)
        foo = graphene.List(of_type=Bar)

    @classmethod
    def mutate_and_get_payload(cls, root, info, **input):
        input['foo']['id'] - should be formatted already DO_X


class CustomID(graphene.Scalar):
    # serialize = str
    # parse_value = str

    @staticmethod
    def serialize(ast):
        return DO_X(ast)

    @staticmethod
    def parse_value(ast):
        return DO_X(ast)

    @staticmethod
    def parse_literal(ast):
        return DO_X(ast)


class Bar(graphene.ObjectType):
    id = CustomID()
    other_field = graphene.String()

0 个答案:

没有答案