Last active
March 18, 2023 22:24
-
-
Save nietzscheson/9bf3527d5ffc6831f9a87600db549b82 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@strawberry.federation.type(keys=["id"], extend=True) | |
class UserType: | |
id: strawberry.ID = | |
@strawberry.federation.type(keys=["id"], description="User Type definition") | |
class ProductType: | |
id: strawberry.ID | |
name: str | |
@strawberry.field | |
def created_by(self) -> UserType: | |
return UserType(id=self.created_by) | |
###... | |
schema = strawberry.federation.Schema(query=Query, types=[UserType, ProductType], mutation=Mutation, enable_federation_2=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@strawberry.federation.type(keys=["id"]) | |
class UserType: | |
id: strawberry.ID | |
name: str | |
@classmethod | |
def resolve_reference(cls, id: strawberry.ID): | |
user = db.session.query(User, id) | |
return user | |
### ... | |
schema = strawberry.federation.Schema(query=Query, types=[UserType], mutation=Mutation, enable_federation_2=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment