class Query(ObjectType): # this defines a Field `hello` in our Schema with a single Argument `name` hello = String(name=String(default_value="stranger")) test = String() goodbye = String() one_week_from = Date(required=True, date_input=Date(required=True)) one_hour_from = DateTime(required=True, datetime_input=DateTime(required=True)) one_minute_from = Time(required=True, time_input=Time(required=True)) # our Resolver method takes the GraphQL context (root, info) as well as # Argument (name) for the Field and returns data for the query Response def resolve_hello(root, info, name): return f'Hello {name}!' def resolve_test(root, info): return 'Testing...' def resolve_goodbye(root, info): return 'See ya!' def resolve_one_week_from(root, info, date_input): """ { oneWeekFrom(dateInput:"2020-10-10") } :param info: :param date_input: :return: """ assert type(date_input) == datetime.date return date_input + datetime.timedelta(weeks=1) def resolve_one_hour_from(root, info, datetime_input): """ { oneHourFrom(datetimeInput:"2006-01-02T15:04:05") } :param info: :param datetime_input: :return: """ assert type(datetime_input) == datetime.datetime return datetime_input + datetime.timedelta(hours=1) def resolve_one_minute_from(root, info, time_input): """ { oneHourFrom(timeInput: "15:04:05") } :param info: :param time_input: :return: """ assert type(time_input) == datetime.time tmp_time_input = datetime.datetime.combine(datetime.date(1, 1, 1), time_input) return (tmp_time_input + datetime.timedelta(minutes=1)).time() me = Field(Person) def resolve_me(parent, info): # returns an object that represents a Person return get_human(name="Luke Skywalker")
def convert_time_to_string(field, registry=None, required=None, field_many_to_many_extras=None, field_foreign_key_extras=None): return Time(description=field.help_text, required=is_required(field, required))
def convert_time_to_string(field, registry=None, input_flag=None): if input_flag == "order_by": return OrderEnum(description=field.help_text or field.verbose_name, ) if input_flag == "where": return TimeFilter(description=field.help_text or field.verbose_name, ) return Time( description=field.help_text or field.verbose_name, required=is_required(field) and input_flag == "create", )
class Arguments: course_id = ID(name='id') course_type = CourseTypeEnum() academic_level = AcademicLevelEnum() title = String() description = String() instructor_id = ID(name='instructor') hourly_tuition = Decimal() total_tuition = Decimal() course_category_id = ID(name='courseCategory') # Logistical information room = String() day_of_week = DayOfWeekEnum() start_date = DateTime() end_date = DateTime() start_time = Time() end_time = Time() max_capacity = Int() is_confirmed = Boolean()
def convert_time_to_string(field, registry=None): return Time(description=field.help_text, required=not field.null)
def convert_form_field_to_time(field): return Time(description=get_form_field_description(field), required=field.required)
def convert_time_to_string(field, registry=None): return Time(description=get_django_field_description(field), required=not field.null)
def convert_form_field_to_time(field): return Time(description=field.help_text, required=field.required)
class CourseAvailabilityInput(graphene.InputObjectType): day_of_week = DayOfWeekEnum() start_time = Time() end_time = Time()