This repository was archived by the owner on Feb 10, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -118,6 +118,7 @@ config/graphql.php
118
118
#### Advanced Usage
119
119
- [ Query variables] ( docs/advanced.md#query-variables )
120
120
- [ Query nested resource] ( docs/advanced.md#query-nested-resource )
121
+ - [ Enums] ( docs/advanced.md#enums )
121
122
- [ Interfaces] ( docs/advanced.md#interfaces )
122
123
- [ Custom field] ( docs/advanced.md#custom-field )
123
124
- [ Eager loading relationships] ( docs/advanced.md#eager-loading-relationships )
Original file line number Diff line number Diff line change 2
2
3
3
- [ Query variables] ( #query-variables )
4
4
- [ Query nested resource] ( #query-nested-resource )
5
+ - [ Enums] ( #enums )
5
6
- [ Interfaces] ( #interfaces )
6
7
- [ Custom field] ( #custom-field )
7
8
- [ Eager loading relationships] ( #eager-loading-relationships )
@@ -73,6 +74,34 @@ public function resolvePostsField($root, $args)
73
74
}
74
75
```
75
76
77
+ ### Enums
78
+
79
+ Enumeration types are a special kind of scalar that is restricted to a particular set of allowed values.
80
+ Read more about Enums [ here] ( http://graphql.org/learn/schema/#enumeration-types )
81
+
82
+ ``` php
83
+ <?php
84
+ // app/GraphQL/Enums/EpisodeEnum.php
85
+ namespace App\GraphQL\Enums;
86
+
87
+ use Folklore\GraphQL\Support\Type as GraphQLType;
88
+
89
+ class EpisodeEnum extends GraphQLType {
90
+ protected $enumObject = true;
91
+
92
+ protected $attributes = [
93
+ 'name' => 'Episode',
94
+ 'description' => 'The types of demographic elements',
95
+ 'values' => [
96
+ 'NEWHOPE' => 'NEWHOPE',
97
+ 'EMPIRE' => 'EMPIRE',
98
+ 'JEDI' => 'JEDI',
99
+ ],
100
+ ];
101
+ }
102
+
103
+ ```
104
+
76
105
### Interfaces
77
106
78
107
You can use interfaces to abstract a set of fields. Read more about interfaces [ here] ( http://graphql.org/learn/schema/#interfaces ) .
You can’t perform that action at this time.
0 commit comments