Skip to content

Allow updating Operation name and args after its initialization #244

@pwyllcrusader

Description

@pwyllcrusader

🚀 Feature Request

Description

Allow updating Operation name and args after its initialization

operation = Operation(query)
operation.name = "newlyNamedQuery"
operation.args = {"some_arg": Arg(SomeKindScalar)}
operation.find_something(some_args=Variable("some_arg"))

In some cases (for automated tests) this allows to avoid code duplication while using pytest fixtures
*

Implementation details

just putting this piece of code into Operation class worked for me:

    @property
    def name(self):
        return self.__name
    
    @name.setter
    def name(self, value):
        self.__name = value

    @property
    def args(self):
        return self.__args
    
    @args.setter
    def args(self, variables_dict):
        variable_args = OrderedDict()
        for k, v in variables_dict.items():
            variable_args['$' + k] = v
        self.__args = ArgDict(variable_args)
        self.__args._set_container(self.__type.__schema__, self)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions