from graphene import ObjectType, String from rescape_graphene import type_modify_fields # These will some day be used by the LocationType instead of the blockname field # It allows us to put street names in different languages like OSM does and have other properties # such as street suffix location_street_data_fields = dict(name=dict(type=String), ) LocationStreetDataType = type('LocationStreetSopDataType', (ObjectType, ), type_modify_fields(location_street_data_fields))
from graphene.types.generic import GenericScalar from rescape_graphene import type_modify_fields from graphene import ObjectType location_data_fields = dict(example=dict( type=GenericScalar, graphene_type=GenericScalar, )) LocationDataType = type('LocationDataType', (ObjectType, ), type_modify_fields(location_data_fields))
# Params used to limit what locations are available to the Region # We don't add filter fields at this level. The filter fields start at search_location.data, search_location.geojson, # etc. We don't want a search_location.dataContains field as part of the SearchLocationType class # The sample user search data fields for rescape-region. This must be overridden in applications # that use rescape-region user_search_location_data_fields = dict( searchLocation=dict( type=SearchLocationType, graphene_type=SearchLocationType, fields=search_location_fields, # References the model class type_modifier=lambda *type_and_args: Field( *type_and_args, resolver=model_resolver_for_dict_field(SearchLocation))), # Indicates if this SearchLocation is active for the user activity=dict( type=ActivityDataType, graphene_type=ActivityDataType, fields=activity_data_fields, type_modifier=lambda *type_and_args: Field( *type_and_args, resolver=resolver_for_dict_field), )) UserSearchLocationDataType = type( 'UserSearchLocationDataType', (ObjectType, ), type_modify_fields(user_search_location_data_fields), )
from graphene import ObjectType, Field from rescape_graphene import resolver_for_dict_field, type_modify_fields # Params used to limit what locations are available to the Region from rescape_region.schema_models.mapbox.mapbox_data_schema import MapboxDataType, mapbox_data_fields from rescape_region.schema_models.scope.location.location_params_data_schema import location_params_data_fields, LocationParamsDataType region_data_fields = dict( # This is a singular object with a params field used to resolve locations locations=dict(type=LocationParamsDataType, graphene_type=LocationParamsDataType, fields=location_params_data_fields, type_modifier=lambda *type_and_args: Field( *type_and_args, resolver=resolver_for_dict_field)), # The default mapbox settings for the region mapbox=dict( type=MapboxDataType, graphene_type=MapboxDataType, fields=mapbox_data_fields, type_modifier=lambda *type_and_args: Field( *type_and_args, resolver=resolver_for_dict_field), ), ) RegionDataType = type('RegionDataType', (ObjectType, ), type_modify_fields(region_data_fields))
from graphene import ObjectType, String from rescape_graphene import type_modify_fields # TODO right now every location just has one jurisdiction object that corresponds # to the original location jurisdiction properties. # In the future this will look more like OSM or Google's jurisdictions, where # a locaiton has a list of them starting at country and working down to more specific levels jurisdiction_data_fields = dict(country=dict(type=String), state=dict(type=String), city=dict(type=String), county=dict(type=String), borough=dict(type=String), district=dict(type=String), neighborhood=dict(type=String)) JurisdictionDataType = type('JurisdictionDataType', (ObjectType, ), type_modify_fields(jurisdiction_data_fields))
from graphene import ObjectType, Field from rescape_graphene import resolver_for_dict_field, type_modify_fields from rescape_region.schema_models.mapbox.mapbox_data_schema import MapboxDataType, mapbox_data_fields from rescape_region.schema_models.scope.location.location_params_data_schema import LocationParamsDataType, location_params_data_fields project_data_fields = dict( # This is a singular object with a params field used to resolve locations locations=dict(type=LocationParamsDataType, graphene_type=LocationParamsDataType, fields=location_params_data_fields, type_modifier=lambda *type_and_args: Field( *type_and_args, resolver=resolver_for_dict_field)), # The default mapbox settings for the region mapbox=dict(type=MapboxDataType, graphene_type=MapboxDataType, fields=mapbox_data_fields, type_modifier=lambda *type_and_args: Field( *type_and_args, resolver=resolver_for_dict_field))) ProjectDataType = type('ProjectDataType', (ObjectType, ), type_modify_fields(project_data_fields))
longitude=dict(type=Float), zoom=dict(type=Int), # Overrides latitude, longitude, and zoom to support more complex types extent=dict( type=FeatureCollectionDataType, graphene_type=FeatureCollectionDataType, fields=feature_collection_data_type_fields, type_modifier=lambda *type_and_args: Field(*type_and_args, resolver=resolver_for_dict_field), ) ) # Viewport settings within Mapbox ViewportDataType = type( 'MapboxViewportDataType', (ObjectType,), type_modify_fields(viewport_data_fields) ) viewport_data_fields = dict( hoveredColor=dict(type=String), highlightedColor=dict(type=String), mapboxStyleUrl=dict(type=String) ) # Style settings within Mapbox StyleDataType = type( 'MapboxStyleDataType', (ObjectType,), type_modify_fields(style_data_fields) )
from graphene.types.generic import GenericScalar from rescape_graphene import type_modify_fields from graphene import ObjectType location_params_data_fields = dict(params=dict( type=GenericScalar, graphene_type=GenericScalar, ), ) # References a get_location_schema()['model_class'] LocationParamsDataType = type('LocationParamsDataType', (ObjectType, ), type_modify_fields(location_params_data_fields))
from graphene import ObjectType, Float, Field, Int, String from rescape_graphene import resolver_for_dict_field, \ type_modify_fields settings_viewport_data_fields = dict(latitude=dict(type=Float), longitude=dict(type=Float), zoom=dict(type=Int)) # Viewport settings within Mapbox SettingsViewportDataType = type( 'SettingsViewportDataType', (ObjectType, ), type_modify_fields(settings_viewport_data_fields)) settings_mapbox_data_fields = dict(viewport=dict( type=SettingsViewportDataType, graphene_type=SettingsViewportDataType, fields=settings_viewport_data_fields, type_modifier=lambda *type_and_args: Field( *type_and_args, resolver=resolver_for_dict_field), )) # Mapbox settings for the User's use of a particular Region SettingsMapboxDataType = type('SettingsMapboxDataType', (ObjectType, ), type_modify_fields(settings_mapbox_data_fields)) settings_api_data_field = dict( protocol=dict(type=String), host=dict(type=String), port=dict(type=String), path=dict(type=String), )
def UserRegionDataType(class_config): return type('UserRegionDataType', (ObjectType, ), type_modify_fields(user_region_data_fields(class_config)))
def UserGlobalDataType(class_config): return type('UserGlobalDataType', (ObjectType, ), type_modify_fields(user_global_data_fields(class_config)))
def UserStateDataType(class_config): return type('UserStateDataType', (ObjectType, ), type_modify_fields(user_state_data_fields(class_config)))
def UserProjectDataType(class_config): return type('UserProjectDataType', (ObjectType, ), type_modify_fields(user_project_data_fields(class_config)))
from graphene import ObjectType, Float, List, Field, Int, Boolean from rescape_graphene import resolver_for_dict_field, \ resolver_for_dict_list, model_resolver_for_dict_field, type_modify_fields, FeatureCollectionDataType from rescape_graphene.schema_models.geojson.types.feature_collection import feature_collection_data_type_fields from rescape_python_helpers import ramda as R from rescape_region.schema_models.mapbox.mapbox_data_schema import MapboxDataType, mapbox_data_fields activity_data_fields = dict(isActive=dict(type=Boolean)) ActivityDataType = type('ActivityDataType', (ObjectType, ), type_modify_fields(activity_data_fields)) def user_global_data_fields(class_config): return dict( # The mapbox state for the user's Global settings mapbox=dict( type=MapboxDataType, graphene_type=MapboxDataType, fields=mapbox_data_fields, type_modifier=lambda *type_and_args: Field( *type_and_args, resolver=resolver_for_dict_field), )) # References the Global instance, dictating settings imposed on or chosen by a user globally # to which they have some level of access. This also adds settings like mapbox that are particular to the User's use # of the Region but that the Region itself doesn't care about def UserGlobalDataType(class_config): return type('UserGlobalDataType', (ObjectType, ),