This is more of a question than a issue.
Suppose the following example:
class Sale(ObjectType):
pass
class SaleItem(ObjectType):
sale = Field(Sale)
How can I proceed to add a new field on Sale that references SaleItem, like:
class Sale(ObjectType):
items = List(SaleItem)
@romaia you can lazily reference other types by using a lambda function like this:
class Sale(ObjectType):
items = List(lambda: SaleItem)
class SaleItem(ObjectType):
sale = Field(Sale)
You can also specify a full import path as a string (like Django):
# This file is api/definitions/sale.py
class Sale(ObjectType):
items = List('api.definitions.sale.SaleItem')
class SaleItem(ObjectType):
sale = Field(Sale)
@jkimbo Thanks so much. I came from JavaScript and completely forgot that arrow functions are just lambda functions 馃槢
You're welcome @mikebobadilla . Glad I could help!
Most helpful comment
@romaia you can lazily reference other types by using a lambda function like this:
You can also specify a full import path as a string (like Django):