class ContactInput(graphene.InputObjectType): email = graphene.String() secondary_email = graphene.String() first_name = graphene.String() middle_name = graphene.String() last_name = graphene.String() mobile = graphene.String() salutation = graphene.Int() occupation = graphene.Int() skype = graphene.String() direct_line = graphene.String() voi = graphene.Boolean() beverage = graphene.String() is_active = graphene.Boolean() organisations = graphene.List(graphene.ID) referrer_id = graphene.ID() spouse_id = graphene.ID() mother_id = graphene.ID() father_id = graphene.ID() date_of_birth = graphene.String() date_of_death = graphene.String() place_of_birth = graphene.String() estimated_wealth = Decimal() preferred_first_name = graphene.String() location = graphene.InputField(LocationInput) postal_location = graphene.InputField(LocationInput) link_mails = graphene.Boolean()
class PostEditInput(graphene.InputObjectType): """Field paramter for post type to be edited""" post = graphene.InputField(BasePostEditPatchInput, required=True, description=_('Field for post to be modified')) patch = graphene.InputField(BasePostCreateMixin, description=_('Content to replace post'))
def create_input_field(field_name, field_type, required=False) -> gr.InputField: if not required: return gr.InputField(field_type, out_name=field_name) else: return gr.InputField(gr.NonNull(field_type), out_name=field_name)
class ProcessStepInput(NamedInput): description = graphene.String() process = graphene.InputField(ProcessInput) method_step = graphene.InputField(ProcessMethodStepInput) parent = graphene.InputField(lambda: ProcessStepInput) order = graphene.Int() properties = graphene.List(PropertyInput)
def Field(cls, *args, **kwargs): cls._meta.arguments['input']._meta.fields.update({ get_user_model().USERNAME_FIELD: graphene.InputField(graphene.String, required=True), 'password': graphene.InputField(graphene.String, required=True), }) return super().Field(*args, **kwargs)
def Field(cls, *args, **kwargs): if isinstance(cls._inputs, dict): for key in cls._inputs: cls._meta.arguments["input"]._meta.fields.update({ key: graphene.InputField(getattr(graphene, cls._inputs[key])) }) elif isinstance(cls._inputs, list): for key in cls._inputs: cls._meta.arguments["input"]._meta.fields.update( {key: graphene.InputField(graphene.String)}) if isinstance(cls._required_inputs, dict): for key in cls._required_inputs: cls._meta.arguments["input"]._meta.fields.update({ key: graphene.InputField(getattr(graphene, cls._required_inputs[key]), required=True) }) elif isinstance(cls._required_inputs, list): for key in cls._required_inputs: cls._meta.arguments["input"]._meta.fields.update( {key: graphene.InputField(graphene.String, required=True)}) return super().Field(*args, **kwargs)
class ClientInput(graphene.InputObjectType): id = graphene.ID() organisation = graphene.InputField(ClientOrganisationInput) contact = graphene.InputField(ClientContactInput) second_contact = graphene.InputField(ClientContactInput) office = graphene.InputField(IDField) is_active = graphene.Boolean()
class GetAggregateInput(graphene.InputObjectType): """ Input object type for getting an aggregates. """ data_type = graphene.InputField( AggregateEntityType, required=True, description='The entity type the data is aggregated from', ) filter_string = graphene.InputField( graphene.String, description='Filter term to use to filter query of the entities' ' to aggregate', ) data_columns = graphene.List( graphene.String, description='List of fields to collect statistics of') group_column = graphene.String(description='Field to group the data by') subgroup_column = graphene.String( description='Field to further group the resources inside groups by') text_columns = graphene.List( graphene.String, description='List of text columns which no statistics are' ' calculated for', ) sort_criteria = graphene.List( GetAggregateSortInput, description='List of criteria to sort the aggregate groups by', ) first_group = graphene.Int( description='Index of the first aggregate group to return') max_groups = graphene.Int( description='Maximum number of aggregate groups to return') mode = AggregateMode( description='Special aggregation mode like word counts')
class VoteFilter(graphene.InputObjectType): """The input object for filtered allVotes queries. The VoteFilter input type provided by the Graphcool server used in the front-end tutorial is quite a bit more complex than this, but this is all the tutorial itself needs. """ link = graphene.InputField(IdInput) user = graphene.InputField(IdInput)
class ProfileInput(graphene.InputObjectType): first_name = graphene.String(description="First name.") last_name = graphene.String(description="Last name.") nickname = graphene.String(description="Nickname.") image = graphene.String(description="Profile image.") language = Language(description="Language.") contact_method = ContactMethod(description="Contact method.") add_emails = graphene.List(CreateEmailInput, description="Add emails to profile.") update_emails = graphene.List(UpdateEmailInput, description="Update profile emails.") remove_emails = graphene.List(graphene.ID, description="Remove emails from profile.") add_phones = graphene.List(CreatePhoneInput, description="Add phone numbers to profile.") update_phones = graphene.List(UpdatePhoneInput, description="Update profile phone numbers.") remove_phones = graphene.List( graphene.ID, description="Remove phone numbers from profile.") add_addresses = graphene.List(CreateAddressInput, description="Add addresses to profile.") update_addresses = graphene.List(UpdateAddressInput, description="Update profile addresses.") remove_addresses = graphene.List( graphene.ID, description="Remove addresses from profile.") subscriptions = graphene.List(SubscriptionInputType) youth_profile = graphene.InputField(YouthProfileFields) sensitivedata = graphene.InputField(SensitiveDataFields)
class InvoiceMatterInput(graphene.InputObjectType): id = graphene.ID() client = graphene.InputField(IDFieldInput) matter = graphene.InputField(IDFieldInput) manager = graphene.InputField(IDFieldInput) description = graphene.String() budget = Currency()
def Field(cls, *args, **kwargs): cls._meta.arguments["input"]._meta.fields.update( {"password": graphene.InputField(graphene.String, required=True)}) for field in app_settings.LOGIN_ALLOWED_FIELDS: cls._meta.arguments["input"]._meta.fields.update( {field: graphene.InputField(graphene.String)}) return super(graphql_jwt.relay.JSONWebTokenMutation, cls).Field(*args, **kwargs)
class ThreadCreateInput(graphene.InputObjectType): """Input for new thread creation""" category = graphene.InputField(CategoryThreadInput, description=_('category thread should to'), required=True) thread = graphene.InputField(ThreadCreateBaseInput, description=_('new thread properties'), required=True)
class MaterialSpecificationInput(NamedInput): description = graphene.String() version = graphene.String() parent = graphene.InputField(lambda: MaterialSpecificationInput) attributes = graphene.List(AttributeInput) identifiers = graphene.List(IdentifierInput) properties = graphene.List(PropertyInput) supplier = graphene.InputField(OrganizationInput)
class PostCreateInput(graphene.InputObjectType): """Field parameter for new post type to be generated""" thread = graphene.InputField( ThreadInputMixin, required=True, description=_('Thread to which post is binded')) post = graphene.InputField( BasePostCreateMixin, required=True, description=_('Field that holds contents of new post'))
class ThreadEditInput(graphene.InputObjectType): """Input for thread modification""" thread = graphene.InputField( ThreadBaseInputMixin, description=_('property of thread to be edited'), required=True) patch = graphene.InputField( ThreadEditPatchInputMixin, description=_('new properties for thread'), )
class ProceduraVASCreateInput(InputObjectType): """ Class created to accept input data from the interactive graphql console. """ tipologia = graphene.String(required=True) piano = graphene.InputField(PianoUpdateInput, required=False) note = graphene.InputField(graphene.List(graphene.String), required=False) data_creazione = graphene.types.datetime.DateTime(required=False)
class TimeEntryInput(graphene.InputObjectType): description = graphene.String() client = graphene.InputField(IDField) staff_member = graphene.InputField(IDField) matter = graphene.InputField(IDField) units = graphene.Int() status = graphene.Int() date = graphene.String() gst_status = graphene.Int() rate = graphene.Float() record_type = graphene.Int() time = graphene.String()
class OrganisationInput(graphene.InputObjectType): name = graphene.String() main_line = graphene.String() website = graphene.String() industry_id = graphene.ID() group_status = graphene.Int() group_parent = graphene.InputField(IDField) business_search_words = graphene.String() contacts = graphene.List(graphene.ID) location = graphene.InputField(LocationInput) postal_location = graphene.InputField(LocationInput) link_mails = graphene.Boolean()
class UserInput(graphene.InputObjectType): email = graphene.String() second_email = graphene.String() first_name = graphene.String() last_name = graphene.String() rate = graphene.Float() is_active = graphene.Boolean() mobile = graphene.String() admission_date = graphene.String() salutation = graphene.Int() photo = graphene.String() location = graphene.InputField(LocationInput) postal_location = graphene.InputField(LocationInput)
class UserInput(graphene.InputObjectType): """ User attribute input for user creation and updating """ id = graphene.String() name = graphene.String() bio = graphene.String() email = graphene.String() password = graphene.String() profile_pic = graphene.String() # NOTE: will assume base64 encoded string metrics = graphene.InputField(UserMetricsInput) achievement = graphene.String() # achievement id art_to_add = graphene.String() # artwork id to add to portfolio art_to_remove = graphene.String() # artwork id to remove from portfolio group = graphene.String() # group id to add to user's groups settings = graphene.InputField(UserSettingsInput)
class ArtworkInput(graphene.InputObjectType): """ Artwork attribute input for artwork creation and updating """ id = graphene.ID() title = graphene.String() artist = graphene.String() description = graphene.String() pictures = graphene.List(graphene.String) found_by = graphene.String() # will be user id location = graphene.List(graphene.Float) # (longitude, latitude) metrics = graphene.InputField(ArtworkMetricsInput) num_ratings = graphene.Int() rating = graphene.Float() # assuming 1-100 at the moment comment = graphene.InputField(CommentInput) tags = graphene.List(graphene.String)
class PianoCreateInput(InputObjectType): """ Class created to accept input data from the interactive graphql console. """ ente = graphene.InputField(EnteCreateInput, required=True) tipologia = graphene.String(required=True) codice = graphene.String(required=False) url = graphene.String(required=False) data_creazione = graphene.types.datetime.DateTime(required=False) data_delibera = graphene.types.datetime.DateTime(required=False) descrizione = graphene.InputField(graphene.List(graphene.String), required=False) fase = graphene.InputField(FaseCreateInput, required=False)
class TestInput(graphene.InputObjectType): email = graphene.String() people = graphene.List(PersonalDataInput) numbers = graphene.List(graphene.Int) person = graphene.InputField(PersonalDataInput) @staticmethod def validate_email(email): if "@" not in email: raise InvalidEmailFormat return email.strip(" ") @staticmethod def validate_numbers(numbers): if len(numbers) < 2: raise LengthNotInRange(min=2) for n in numbers: if n < 0 or n > 9: raise NotInRange(min=0, max=9) return numbers @staticmethod def validate(inpt): if inpt.get("people") and inpt.get("email"): first_person_name_and_age = ( f"{inpt['people'][0]['the_name']}{inpt['people'][0]['the_age']}" ) if inpt["email"].split("@")[0] != first_person_name_and_age: raise NameAndAgeInEmail return inpt
class ProceduraAvvioCreateInput(InputObjectType): """ Class created to accept input data from the interactive graphql console. """ piano = graphene.InputField(PianoUpdateInput, required=False) data_creazione = graphene.types.datetime.DateTime(required=False)
class CategoryCreateInput(BaseCategoryInputMixin): """Input for a category create""" id = graphene.ID name = graphene.String() slug = graphene.String() description = graphene.String() parent = graphene.InputField(lambda: CategoryCreateInput)
def convert_input_class_type(type, cls, adapter, **kwargs): default_value = type.default(input=True) return graphene.InputField(cls, required=not type.nullable(input=True) and default_value is None, default_value=default_value, **kwargs)
class CommonInputFields: """Common input fields of mutations for creating and updating products""" note = graphene.String(description="Note about the product in MarkDown.", ) paths = graphene.List( graphene.String, description="Paths to the products. e.g., nersc:/go/to/my/product_v3", ) relations = graphene.InputField( graphene.List(RelationInputFields), description=("Relations to other products"), ) attributes = graphene.InputField( AttributesInputFields, description="Attributes", )
class PerformanceInput(graphene.InputObjectType): event = graphene.InputField(PerformanceEventInput, required=True) value = graphene.Int(required=True) set1 = graphene.Int() set2 = graphene.Int() set3 = graphene.Int() set4 = graphene.Int() set5 = graphene.Int()
class Input(graphene.types.base.BaseType): def __init_subclass__(cls, *args, **kwargs): # add Meta in a way that can be delattr()ed cls.Meta = { 'name': 'SignupUserInput' } super().__init_subclass__(**kwargs) name = graphene.String(required=True) auth_provider = graphene.InputField(AuthProviderSignupData, required=True)