From c472bf455e247fe71fe76e6acd806f2021cb405e Mon Sep 17 00:00:00 2001 From: Aron Jones Date: Thu, 4 Feb 2016 12:04:14 -0500 Subject: [PATCH 1/2] add some clarifications to the custom Scalar type doc --- docs/pages/docs/basic-types.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/docs/pages/docs/basic-types.md b/docs/pages/docs/basic-types.md index 2cec041e..8a30365c 100644 --- a/docs/pages/docs/basic-types.md +++ b/docs/pages/docs/basic-types.md @@ -39,6 +39,7 @@ If you want to create a DateTime Scalar Type just type: ```python import datetime +from graphene.core.classtypes import Scalar from graphql.core.language import ast class DateTime(Scalar): @@ -58,6 +59,16 @@ class DateTime(Scalar): 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 This types if are mounted in a `ObjectType`, `Interface` or `Mutation`, From d16155ea17ecc242193c457bea10d4c5ea60fcd5 Mon Sep 17 00:00:00 2001 From: Aron Jones Date: Thu, 4 Feb 2016 16:54:19 -0500 Subject: [PATCH 2/2] remove custom Scalar usage example since it's now consistent with other types --- docs/pages/docs/basic-types.md | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/docs/pages/docs/basic-types.md b/docs/pages/docs/basic-types.md index 8a30365c..d63867e0 100644 --- a/docs/pages/docs/basic-types.md +++ b/docs/pages/docs/basic-types.md @@ -59,16 +59,6 @@ class DateTime(Scalar): 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 This types if are mounted in a `ObjectType`, `Interface` or `Mutation`,