graphene
graphene copied to clipboard
Create Either Argument decorator
Adds a decorator for handling situations when a query expects different arguments, but can only work with one. For instance:
A query named userByAttr can retrieve a user by their email or username, but not both. In this case, we define the query as follows:
from graphene.utils.decorators import either
@either(["username", "email"])
def resolve_user_by_attr(root, info, username=None, email=None):
...
If both arguments were passed, the query will raise TooManyArgs.
If no expected argument was passed, the query will raise TooFewArgs