Skip to content

Commit b9109dc

Browse files
committed
Added Enum documentation
1 parent 82e989a commit b9109dc

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

docs/config.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ ga = "UA-12613282-7"
1414
"/docs/objecttypes/",
1515
"/docs/mutations/",
1616
"/docs/basic-types/",
17+
"/docs/enums/",
1718
"/docs/relay/",
1819
]
1920

docs/pages/docs/enums.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
title: Enums
3+
description: Walkthrough Enums
4+
---
5+
6+
# Enums
7+
8+
A `Enum` is a special `GraphQL` type that represents a set of symbolic names (members) bound to unique, constant values.
9+
10+
## Enum definition
11+
12+
You can create an `Enum` using classes:
13+
14+
```python
15+
import graphene
16+
17+
class Episode(graphene.Enum):
18+
NEWHOPE = 4
19+
EMPIRE = 5
20+
JEDI = 6
21+
```
22+
23+
But also using instances of Enum:
24+
25+
```python
26+
Episode = graphene.Enum('Episode', [('NEWHOPE', 4), ('EMPIRE', 5), ('JEDI', 6)])
27+
```
28+
29+
## Notes
30+
31+
Internally, `graphene.Enum` uses [`enum.Enum`](https://docs.python.org/3/library/enum.html) Python implementation if available, or a backport if not.
32+
33+
So you can use it in the same way as you would do with Python `enum.Enum`.

0 commit comments

Comments
 (0)