Skip to content

Commit fc82a5f

Browse files
author
Rami Chowdhury
committed
Update README example
1 parent 38edf85 commit fc82a5f

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed

README.md

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -66,22 +66,26 @@ result = schema.execute(query)
6666
`graphene_pydantic` supports forward declarations and circular references, but you will need to call the `resolve_placeholders()` method to ensure the types are fully updated before you execute a GraphQL query. For instance:
6767

6868
``` python
69-
class FooModel(BaseModel):
70-
bar: 'BarModel'
71-
72-
class BarModel(BaseModel):
73-
foo: FooModel
74-
75-
class Foo(PydanticObjectType):
76-
class Meta:
77-
model = FooModel
78-
79-
class Bar(PydanticObjectType):
80-
class Meta:
81-
model = BarModel
69+
class NodeModel(BaseModel):
70+
id: int
71+
name: str
72+
labels: 'LabelsModel'
73+
74+
class LabelsModel(BaseModel):
75+
node: NodeModel
76+
labels: typing.List[str]
77+
78+
class Node(PydanticObjectType):
79+
class Meta:
80+
model = NodeModel
81+
82+
class Labels(PydanticObjectType):
83+
class Meta:
84+
model = LabelsModel
85+
8286

83-
Foo.resolve_placeholders() # <-- this line ensures it's resolvable in GraphQL
84-
Bar.resolve_placeholders()
87+
Node.resolve_placeholders() # make the `labels` field work
88+
Labels.resolve_placeholders() # make the `node` field work
8589
```
8690

8791
### Full Examples

0 commit comments

Comments
 (0)