Skip to content

Instantly share code, notes, and snippets.

@nietzscheson
Last active March 18, 2023 22:24
Show Gist options
  • Save nietzscheson/9bf3527d5ffc6831f9a87600db549b82 to your computer and use it in GitHub Desktop.
Save nietzscheson/9bf3527d5ffc6831f9a87600db549b82 to your computer and use it in GitHub Desktop.
@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)
@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