mirror of
https://github.com/graphql-python/graphene.git
synced 2024-11-11 12:16:58 +03:00
Added Enum documentation
This commit is contained in:
parent
82e989a7b3
commit
b9109dc00f
|
@ -14,6 +14,7 @@ ga = "UA-12613282-7"
|
|||
"/docs/objecttypes/",
|
||||
"/docs/mutations/",
|
||||
"/docs/basic-types/",
|
||||
"/docs/enums/",
|
||||
"/docs/relay/",
|
||||
]
|
||||
|
||||
|
|
33
docs/pages/docs/enums.md
Normal file
33
docs/pages/docs/enums.md
Normal file
|
@ -0,0 +1,33 @@
|
|||
---
|
||||
title: Enums
|
||||
description: Walkthrough Enums
|
||||
---
|
||||
|
||||
# Enums
|
||||
|
||||
A `Enum` is a special `GraphQL` type that represents a set of symbolic names (members) bound to unique, constant values.
|
||||
|
||||
## Enum definition
|
||||
|
||||
You can create an `Enum` using classes:
|
||||
|
||||
```python
|
||||
import graphene
|
||||
|
||||
class Episode(graphene.Enum):
|
||||
NEWHOPE = 4
|
||||
EMPIRE = 5
|
||||
JEDI = 6
|
||||
```
|
||||
|
||||
But also using instances of Enum:
|
||||
|
||||
```python
|
||||
Episode = graphene.Enum('Episode', [('NEWHOPE', 4), ('EMPIRE', 5), ('JEDI', 6)])
|
||||
```
|
||||
|
||||
## Notes
|
||||
|
||||
Internally, `graphene.Enum` uses [`enum.Enum`](https://docs.python.org/3/library/enum.html) Python implementation if available, or a backport if not.
|
||||
|
||||
So you can use it in the same way as you would do with Python `enum.Enum`.
|
Loading…
Reference in New Issue
Block a user