Skip to content

Instantly share code, notes, and snippets.

manager.add_types(self.user, self.photo)
manager.add_types(snake_case_fallback_resolvers)
return manager.get_schema()
@dataclass
class BoundaryGeneric:
def __init__(self, child_name, kwargs=None):
self.typename = child_name
if kwargs:
self.update_class(kwargs)
self.get_updated()
@self.user.resolve_references
def resolve_user_references(representations):
results = []
for req in representations:
kwargs = {
"id": req.get('id')
}
data = self.ds.getUser(**kwargs)[0]
@self.query.field("users")
def resolve_users(*_, **kwargs):
return self.ds.getUser(**kwargs)
manager = FederatedManager(
schema_sdl_file='schema/schema.graphql',
query=self.query,
)
query = QueryType()
user = FederatedObjectType("User")
directive @external on FIELD_DEFINITION
directive @requires(fields: _FieldSet!) on FIELD_DEFINITION
directive @provides(fields: _FieldSet!) on FIELD_DEFINITION
directive @key(fields: _FieldSet!) on OBJECT | INTERFACE
directive @extends on OBJECT
scalar _Any
union _Entity = User
type Photo {
id: ID!
url: String!
reviews: [Review]
}
type Query {
users(id: ID, first_name: String, last_name: String): [User]
photo(id: ID): [Photo]
review(id: ID): [Review]
type Query {
users(id: ID, first_name: String, last_name: String): [User]
}
"""
User
The `User` type
"""
type User @key(fields: "id"){
id: ID!
query{
users(first_name:"Han"){
id
first_name
last_name
photos{
id
url
reviews{
id