Skip to content
This repository was archived by the owner on Feb 10, 2019. It is now read-only.

Commit b754d65

Browse files
committed
- Adds documentation for Enums
1 parent e4a42bf commit b754d65

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

Readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ config/graphql.php
118118
#### Advanced Usage
119119
- [Query variables](docs/advanced.md#query-variables)
120120
- [Query nested resource](docs/advanced.md#query-nested-resource)
121+
- [Enums](docs/advanced.md#enums)
121122
- [Interfaces](docs/advanced.md#interfaces)
122123
- [Custom field](docs/advanced.md#custom-field)
123124
- [Eager loading relationships](docs/advanced.md#eager-loading-relationships)

docs/advanced.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
- [Query variables](#query-variables)
44
- [Query nested resource](#query-nested-resource)
5+
- [Enums](#enums)
56
- [Interfaces](#interfaces)
67
- [Custom field](#custom-field)
78
- [Eager loading relationships](#eager-loading-relationships)
@@ -73,6 +74,34 @@ public function resolvePostsField($root, $args)
7374
}
7475
```
7576

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+
76105
### Interfaces
77106

78107
You can use interfaces to abstract a set of fields. Read more about interfaces [here](http://graphql.org/learn/schema/#interfaces).

0 commit comments

Comments
 (0)