Merge pull request #623 from jkimbo/scalar-documentation

[Docs] Scalar documentation
This commit is contained in:
Syrus Akbary 2017-12-10 12:54:54 -08:00 committed by GitHub
commit 5036d164b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,20 +1,83 @@
Scalars
=======
All Scalar types accept the following arguments. All are optional:
``name``: *string*
Override the name of the Field.
``description``: *string*
A description of the type to show in the GraphiQL browser.
``required``: *boolean*
If ``True``, the server will enforce a value for this field. See `NonNull <./list-and-nonnull.html#nonnull>`_. Default is ``False``.
``deprecation_reason``: *string*
Provide a deprecation reason for the Field.
``default_value``: *any*
Provide a default value for the Field.
Base scalars
------------
Graphene defines the following base Scalar Types:
- ``graphene.String``
- ``graphene.Int``
- ``graphene.Float``
- ``graphene.Boolean``
- ``graphene.ID``
``graphene.String``
Represents textual data, represented as UTF-8
character sequences. The String type is most often used by GraphQL to
represent free-form human-readable text.
``graphene.Int``
Represents non-fractional signed whole numeric
values. Int can represent values between `-(2^53 - 1)` and `2^53 - 1` since
represented in JSON as double-precision floating point numbers specified
by `IEEE 754 <http://en.wikipedia.org/wiki/IEEE_floating_point>`_.
``graphene.Float``
Represents signed double-precision fractional
values as specified by
`IEEE 754 <http://en.wikipedia.org/wiki/IEEE_floating_point>`_.
``graphene.Boolean``
Represents `true` or `false`.
``graphene.ID``
Represents a unique identifier, often used to
refetch an object or as key for a cache. The ID type appears in a JSON
response as a String; however, it is not intended to be human-readable.
When expected as an input type, any string (such as `"4"`) or integer
(such as `4`) input value will be accepted as an ID.
Graphene also provides custom scalars for Dates, Times, and JSON:
- ``graphene.types.datetime.Date``
- ``graphene.types.datetime.DateTime``
- ``graphene.types.datetime.Time``
- ``graphene.types.json.JSONString``
``graphene.types.datetime.Date``
Represents a Date value as specified by `iso8601 <https://en.wikipedia.org/wiki/ISO_8601>`_.
``graphene.types.datetime.DateTime``
Represents a DateTime value as specified by `iso8601 <https://en.wikipedia.org/wiki/ISO_8601>`_.
``graphene.types.datetime.Time``
Represents a Time value as specified by `iso8601 <https://en.wikipedia.org/wiki/ISO_8601>`_.
``graphene.types.json.JSONString``
Represents a JSON string.
Custom scalars