I noticed that one of the examples shows two different ways of creating a List (lines 16 & 17 here):
class Character(graphene.Interface):
id = graphene.ID()
name = graphene.String()
friends = graphene.List(lambda: Character)
appears_in = graphene.List(Episode)
The documentation shows only without a lambda:
class Character(graphene.ObjectType):
appears_in = graphene.List(graphene.String)
Are these equivalent? If not when would you use one form or the other?
Thanks!
Usually lambdas are used when there is a dependency that only can be resolved lazily.
(for example, a self-reference to the field parent type).
Otherwise, using the non-lambda form is the recommended approach :)
Most helpful comment
Usually lambdas are used when there is a dependency that only can be resolved lazily.
(for example, a self-reference to the field parent type).
Otherwise, using the non-lambda form is the recommended approach :)