mirror of
https://github.com/graphql-python/graphene.git
synced 2025-02-02 20:54:16 +03:00
add some clarifications to the custom Scalar type doc
This commit is contained in:
parent
810549e999
commit
c472bf455e
|
@ -39,6 +39,7 @@ If you want to create a DateTime Scalar Type just type:
|
||||||
|
|
||||||
```python
|
```python
|
||||||
import datetime
|
import datetime
|
||||||
|
from graphene.core.classtypes import Scalar
|
||||||
from graphql.core.language import ast
|
from graphql.core.language import ast
|
||||||
|
|
||||||
class DateTime(Scalar):
|
class DateTime(Scalar):
|
||||||
|
@ -58,6 +59,16 @@ class DateTime(Scalar):
|
||||||
return datetime.datetime.strptime(value, "%Y-%m-%dT%H:%M:%S.%f")
|
return datetime.datetime.strptime(value, "%Y-%m-%dT%H:%M:%S.%f")
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Unlike the other basic types, custom `Scalar` types should not be instantiated
|
||||||
|
when used.
|
||||||
|
|
||||||
|
```python
|
||||||
|
import graphene
|
||||||
|
|
||||||
|
class Post(graphene.ObjectType):
|
||||||
|
created = graphene.Field(DateTime)
|
||||||
|
```
|
||||||
|
|
||||||
## Mounting in ClassTypes
|
## Mounting in ClassTypes
|
||||||
|
|
||||||
This types if are mounted in a `ObjectType`, `Interface` or `Mutation`,
|
This types if are mounted in a `ObjectType`, `Interface` or `Mutation`,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user