def resolve_profile(self, info, **kwargs): """GraphQL resolver for a single profile.""" table = get_table_resource() vault = user.Profile(table) if kwargs.get("userId"): search = vault.find_by_id(kwargs.get("userId")) if len(search.get("Items")) > 0: resp = search["Items"][0]["profile"] else: resp = json.dumps({}) return resp
def resolve_profiles(self, info, **kwargs): """GraphQL resolver for the profiles attribute.""" table = get_table_resource() vault = user.Profile(table) profiles = [] if kwargs.get("primaryEmail"): search = vault.find_by_email(kwargs.get("primaryEmail")) if len(search.get("Items")) > 0: for profile in search.get("Items"): profiles.append(json.loads()) else: for vault_profile in vault.all: profiles.append(json.loads(vault_profile.get("profile")))
xray_recorder.configure( service="{}_profile_retrieval_serivce".format(cis_environment)) # Instrument the Flask application XRayMiddleware(app, xray_recorder) if config("initialize_vault", namespace="person_api", default="false") == "true": logger.debug( "Initializing vault and pre-seeding it, this will take some time...") initialize_vault() seed() logger.debug("Vault is seeded and ready to go!") authorization_middleware = AuthorizationMiddleware() dynamodb_table = get_table_resource() dynamodb_client = get_dynamodb_client() transactions = config("transactions", namespace="cis", default="false") def load_dirty_json(dirty_json): regex_replace = [ (r"([ \{,:\[])(u)?'([^']+)'", r'\1"\3"'), (r" False([, \}\]])", r" false\1"), (r" True([, \}\]])", r" true\1"), ] for r, s in regex_replace: dirty_json = re.sub(r, s, dirty_json) clean_json = json.loads(dirty_json) return clean_json