You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+18Lines changed: 18 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -110,6 +110,24 @@ result = schema.execute(mutation)
110
110
print(result.data['createPerson']['firstName'])
111
111
```
112
112
113
+
### Custom resolve functions
114
+
115
+
Since `PydanticObjectType` inherits from `graphene.ObjectType` you can add custom resolve functions as explained [here](https://docs.graphene-python.org/en/stable/api/#object-types). For instance:
116
+
117
+
```python
118
+
classPerson(PydanticObjectType):
119
+
classMeta:
120
+
model = PersonModel
121
+
# exclude specified fields
122
+
exclude_fields = ("id",)
123
+
124
+
full_name = graphene.String()
125
+
126
+
defresolve_full_name(self, info, **kwargs):
127
+
returnself.first_name +''+self.last_name
128
+
```
129
+
130
+
113
131
### Forward declarations and circular references
114
132
115
133
`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:
0 commit comments