Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
ba7f77ed
Commit
ba7f77ed
authored
Sep 06, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
be5ab339
13227500
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
0 deletions
+45
-0
doc/development/api_graphql_styleguide.md
doc/development/api_graphql_styleguide.md
+45
-0
No files found.
doc/development/api_graphql_styleguide.md
View file @
ba7f77ed
...
...
@@ -191,6 +191,51 @@ end
policies at once. The fields for these will all have be non-nullable
booleans with a default description.
## Enums
GitLab GraphQL enums are defined in
`app/graphql/types`
. When defining new enums, the
following rules apply:
-
Values must be uppercase.
-
Class names must end with the string
`Enum`
.
-
The
`graphql_name`
must not contain the string
`Enum`
.
For example:
```
ruby
module
Types
class
TrafficLightStateEnum
<
BaseEnum
graphql_name
'TrafficLightState'
description
'State of a traffic light'
value
'RED'
,
description:
'Drivers must stop'
value
'YELLOW'
,
description:
'Drivers must stop when it is safe to'
value
'GREEN'
,
description:
'Drivers can start or keep driving'
end
end
```
If the enum will be used for a class property in Ruby that is not an uppercase string,
you can provide a
`value:`
option that will adapt the uppercase value.
In the following example:
-
GraphQL inputs of
`OPENED`
will be converted to
`'opened'`
.
-
Ruby values of
`'opened'`
will be converted to
`"OPENED"`
in GraphQL responses.
```
ruby
module
Types
class
EpicStateEnum
<
BaseEnum
graphql_name
'EpicState'
description
'State of a GitLab epic'
value
'OPENED'
,
value:
'opened'
,
description:
'An open Epic'
value
'CLOSED'
,
value:
'closed'
,
description:
'An closed Epic'
end
end
```
## Authorization
Authorizations can be applied to both types and fields using the same
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment