Skip to content

Commit c472bf4

Browse files
committed
add some clarifications to the custom Scalar type doc
1 parent 810549e commit c472bf4

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

docs/pages/docs/basic-types.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ If you want to create a DateTime Scalar Type just type:
3939

4040
```python
4141
import datetime
42+
from graphene.core.classtypes import Scalar
4243
from graphql.core.language import ast
4344

4445
class DateTime(Scalar):
@@ -58,6 +59,16 @@ class DateTime(Scalar):
5859
return datetime.datetime.strptime(value, "%Y-%m-%dT%H:%M:%S.%f")
5960
```
6061

62+
Unlike the other basic types, custom `Scalar` types should not be instantiated
63+
when used.
64+
65+
```python
66+
import graphene
67+
68+
class Post(graphene.ObjectType):
69+
created = graphene.Field(DateTime)
70+
```
71+
6172
## Mounting in ClassTypes
6273

6374
This types if are mounted in a `ObjectType`, `Interface` or `Mutation`,

0 commit comments

Comments
 (0)