diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-04 03:08:37 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-04 03:08:37 +0000 |
commit | 7ec2694360b4d4bd9a4b00ef5166a77c854d9d4f (patch) | |
tree | 6f3c9a688625b5c4dc1bae11be1fc8a4af388b23 /doc/development/api_graphql_styleguide.md | |
parent | 27a18afc7dba4e09a5ec78e5c251c31216d7792a (diff) | |
download | gitlab-ce-7ec2694360b4d4bd9a4b00ef5166a77c854d9d4f.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'doc/development/api_graphql_styleguide.md')
-rw-r--r-- | doc/development/api_graphql_styleguide.md | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/doc/development/api_graphql_styleguide.md b/doc/development/api_graphql_styleguide.md index 9ff5603e8a4..e367fc67107 100644 --- a/doc/development/api_graphql_styleguide.md +++ b/doc/development/api_graphql_styleguide.md @@ -226,6 +226,33 @@ end policies at once. The fields for these will all have be non-nullable booleans with a default description. +## Feature flags + +Features controlled by feature flags often provide GraphQL functionality. When a feature +is enabled or disabled by a feature flag, the related GraphQL functionality should also +be enabled or disabled. + +Fields can be put behind a feature flag so they can conditionally return the value for +the field depending on if the feature has been enabled or not. + +GraphQL feature flags use the common +[GitLab feature flag](../development/feature_flags.md) system, and can be added to a +field using the `feature_key` property. + +For example: + +```ruby +field :test_field, type: GraphQL::STRING_TYPE, + null: false, + description: 'Some test field', + feature_key: :some_feature_key +``` + +In the above example, the `test_field` field will only be returned if +the `some_feature_key` feature flag is enabled. + +If the feature flag is not enabled, an error will be returned saying the field does not exist. + ## Enums GitLab GraphQL enums are defined in `app/graphql/types`. When defining new enums, the |