Beispiel #1
0
class UserSignup(Mutation):
    email = fields.CharField()
    name = fields.CharField()

    def validate_no_existing_user(self):
        """Ensure no user already exists with this email. """
        if self.email in existing_users:
            raise ValidationError("email_exists")

    def validate_email(self):
        if "aol.com" in self.email:
            raise ValidationError("invalid_email")

    def validate_name(self):
        parts = self.name.split()
        if len(parts) < 2:
            raise ValidationError("need_full_name",
                                  "Please enter a full name.")

    def foo_function(self):
        return True

    def execute(self):
        return self.email
Beispiel #2
0
class SimpleMutationWithDefault(mutations.Mutation):
    email = fields.CharField(required=True)
    favorite_band = fields.CharField(required=False, default=_band)

    def execute(self):
        return self.favorite_band
Beispiel #3
0
class SimpleMutation(mutations.Mutation):
    email = fields.CharField(required=True)
    send_welcome_email = fields.BooleanField(required=False, default=False)

    def execute(self):
        return "".join([_yes, _email])
Beispiel #4
0
class ErrantMutation(mutations.Mutation):
    email = fields.CharField(required=True)

    def execute(self):
        temp = self.this_field_does_not_exist
        return "123"