class SchemaCreator: query = QueryType() model = FederatedObjectType("Model") def __init__(self): self.ds = DataStorage() def getSchema(self): manager = FederatedManager( schema_sdl_file='schema/schema.graphql', query=self.query, ) @self.query.field("models") def resolve_models(*_, **kwargs): return self.ds.getModel(**kwargs) @self.model.resolve_references def resolve_model_references(representations): results = [] for req in representations: kwargs = {"id": req.get('id')} data = self.ds.getModel(**kwargs)[0] results.append(Model(**data)) return results manager.add_types(self.model) manager.add_types(snake_case_fallback_resolvers) return manager.get_schema()
class SchemaCreator: query = QueryType() user = FederatedObjectType("User") photo = FederatedObjectType("Photo") def __init__(self): self.ds = DataStorage() def getSchema(self): manager = FederatedManager( schema_sdl_file="schema/schema.graphql", query=self.query, ) @self.query.field("posts") def resolve_posts(*_, **kwargs): return self.ds.getPost(**kwargs) @self.user.resolve_reference def resolve_user(representation): user_id = representation.get("id") return User(id=user_id) @self.user.field("photos") def resolve_user_photos(obj, info): kwargs = {"user_id": obj.id} return self.ds.getPhoto(**kwargs) manager.add_types(self.user, self.photo) manager.add_types(snake_case_fallback_resolvers) return manager.get_schema()
class SchemaCreator: query = QueryType() model = FederatedObjectType("Model") medicalImage = FederatedObjectType("MedicalImage") def __init__(self): self.ds = DataStorage() def getSchema(self): manager = FederatedManager( schema_sdl_file='schema/schema.graphql', query=self.query, ) @self.query.field("medicalImage") def resolve_medical_image(*_, **kwargs): return self.ds.getMedicalImage(**kwargs) @self.model.resolve_reference def resolve_model(representation): user_id = representation.get('id') return Model(id=user_id) @self.model.field("medicalImages") def resolve_model_images(obj, info): kwargs = {"user_id": obj.id} return self.ds.getMedicalImage(**kwargs) manager.add_types(self.model, self.medicalImage) manager.add_types(snake_case_fallback_resolvers) return manager.get_schema()
class SchemaCreator: query = QueryType() photo = FederatedObjectType("Photo") review = FederatedObjectType("Review") user = FederatedObjectType("User") def __init__(self): self.ds = DataStorage() def getSchema(self): manager = FederatedManager( schema_sdl_file='schema/schema.graphql', query=self.query, ) @self.query.field("review") def resolve_review(*_, **kwargs): return self.ds.getReview(**kwargs) @self.photo.resolve_reference def resolve_photo(representation): photo_id = representation.get('id') return Photo(id=photo_id) @self.photo.field("reviews") def resolve_photo_reviews(obj, info): kwargs = {"photo_id": obj.id} return self.ds.getReview(**kwargs) @self.review.field("reviewer") def resolve_reviewer(obj, info): user_id = obj["user_id"] return User(id=user_id) manager.add_types(self.photo, self.review) manager.add_types(snake_case_fallback_resolvers) return manager.get_schema()
class SchemaCreator: data = DataStorage() query = QueryType() account = FederatedObjectType("Account") bundle = FederatedObjectType("Bundle") patient = FederatedObjectType("Patient") text = FederatedObjectType("Narrative") human_name = ScalarType("HumanName") def __init__(self): self.ds = DataStorage() def getSchema(self): manager = FederatedManager( schema_sdl_file='schema/fhir_schema_4_0_0.graphql', query=self.query, ) @self.human_name.serializer def serialize_datetime(value): return HumanName(value) @self.query.field("Patient") def resolve_patient(obj, info, **kwargs): return Patient(obj, info=self.data.getPatient(**kwargs)[0]) @self.query.field("Account") def resolve_account(*_, **kwargs): return Account(**kwargs) @self.query.field("ActivityDefinition") def resolve_account(*_, **kwargs): return Account(**kwargs) @self.query.field("AccountList") def resolve_account_list(obj, info): alist = AccountList(obj, info) return [alist,] @self.account.resolve_references def resolve_accounts(obj, info): return AccountList(name="test") @self.patient.resolve_reference def resolve_patient(obj, info): return Patient(obj, info) manager.add_types(self.account, self.bundle, self.patient, self.text) manager.add_types(bundle_enum_schema) manager.add_types(snake_case_fallback_resolvers, fallback_resolvers) return manager.get_schema()
def __init__(self): self.ds = DataStorage()