Commit 501c3453 authored by GitLab Bot's avatar GitLab Bot

Automatic merge of gitlab-org/gitlab-ce master

parents 8b752167 d9a761ed
...@@ -45,6 +45,31 @@ class GitlabSchema < GraphQL::Schema ...@@ -45,6 +45,31 @@ class GitlabSchema < GraphQL::Schema
super(query_str, **kwargs) super(query_str, **kwargs)
end end
def id_from_object(object)
unless object.respond_to?(:to_global_id)
# This is an error in our schema and needs to be solved. So raise a
# more meaningfull error message
raise "#{object} does not implement `to_global_id`. "\
"Include `GlobalID::Identification` into `#{object.class}"
end
object.to_global_id
end
def object_from_id(global_id)
gid = GlobalID.parse(global_id)
unless gid
raise Gitlab::Graphql::Errors::ArgumentError, "#{global_id} is not a valid GitLab id."
end
if gid.model_class < ApplicationRecord
Gitlab::Graphql::Loaders::BatchModelLoader.new(gid.model_class, gid.model_id).find
else
gid.find
end
end
private private
def max_query_complexity(ctx) def max_query_complexity(ctx)
......
...@@ -10,7 +10,7 @@ module Mutations ...@@ -10,7 +10,7 @@ module Mutations
required: true, required: true,
description: "The project the merge request to mutate is in" description: "The project the merge request to mutate is in"
argument :iid, GraphQL::ID_TYPE, argument :iid, GraphQL::STRING_TYPE,
required: true, required: true,
description: "The iid of the merge request to mutate" description: "The iid of the merge request to mutate"
......
...@@ -2,11 +2,11 @@ ...@@ -2,11 +2,11 @@
module Resolvers module Resolvers
class IssuesResolver < BaseResolver class IssuesResolver < BaseResolver
argument :iid, GraphQL::ID_TYPE, argument :iid, GraphQL::STRING_TYPE,
required: false, required: false,
description: 'The IID of the issue, e.g., "1"' description: 'The IID of the issue, e.g., "1"'
argument :iids, [GraphQL::ID_TYPE], argument :iids, [GraphQL::STRING_TYPE],
required: false, required: false,
description: 'The list of IIDs of issues, e.g., [1, 2]' description: 'The list of IIDs of issues, e.g., [1, 2]'
argument :state, Types::IssuableStateEnum, argument :state, Types::IssuableStateEnum,
......
...@@ -2,11 +2,11 @@ ...@@ -2,11 +2,11 @@
module Resolvers module Resolvers
class MergeRequestsResolver < BaseResolver class MergeRequestsResolver < BaseResolver
argument :iid, GraphQL::ID_TYPE, argument :iid, GraphQL::STRING_TYPE,
required: false, required: false,
description: 'The IID of the merge request, e.g., "1"' description: 'The IID of the merge request, e.g., "1"'
argument :iids, [GraphQL::ID_TYPE], argument :iids, [GraphQL::STRING_TYPE],
required: false, required: false,
description: 'The list of IIDs of issues, e.g., [1, 2]' description: 'The list of IIDs of issues, e.g., [1, 2]'
......
...@@ -6,5 +6,10 @@ module Types ...@@ -6,5 +6,10 @@ module Types
prepend Gitlab::Graphql::ExposePermissions prepend Gitlab::Graphql::ExposePermissions
field_class Types::BaseField field_class Types::BaseField
# All graphql fields exposing an id, should expose a global id.
def id
GitlabSchema.id_from_object(object)
end
end end
end end
...@@ -10,7 +10,7 @@ module Types ...@@ -10,7 +10,7 @@ module Types
expose_permissions Types::PermissionTypes::Ci::Pipeline expose_permissions Types::PermissionTypes::Ci::Pipeline
field :id, GraphQL::ID_TYPE, null: false field :id, GraphQL::ID_TYPE, null: false
field :iid, GraphQL::ID_TYPE, null: false field :iid, GraphQL::STRING_TYPE, null: false
field :sha, GraphQL::STRING_TYPE, null: false field :sha, GraphQL::STRING_TYPE, null: false
field :before_sha, GraphQL::STRING_TYPE, null: true field :before_sha, GraphQL::STRING_TYPE, null: true
......
...@@ -11,7 +11,7 @@ module Types ...@@ -11,7 +11,7 @@ module Types
present_using MergeRequestPresenter present_using MergeRequestPresenter
field :id, GraphQL::ID_TYPE, null: false field :id, GraphQL::ID_TYPE, null: false
field :iid, GraphQL::ID_TYPE, null: false field :iid, GraphQL::STRING_TYPE, null: false
field :title, GraphQL::STRING_TYPE, null: false field :title, GraphQL::STRING_TYPE, null: false
field :description, GraphQL::STRING_TYPE, null: true field :description, GraphQL::STRING_TYPE, null: true
field :state, MergeRequestStateEnum, null: false field :state, MergeRequestStateEnum, null: false
......
---
title: Use global IDs when exposing GraphQL resources
merge_request: 29080
author:
type: added
...@@ -73,10 +73,10 @@ Complete the following installation steps in order. A link at the end of each ...@@ -73,10 +73,10 @@ Complete the following installation steps in order. A link at the end of each
section will bring you back to the Scalable Architecture Examples section so section will bring you back to the Scalable Architecture Examples section so
you can continue with the next step. you can continue with the next step.
1. [PostgreSQL](./database.md#postgresql-in-a-scaled-environment) 1. [PostgreSQL](database.md#postgresql-in-a-scaled-environment)
1. [Redis](./redis.md#redis-in-a-scaled-environment) 1. [Redis](redis.md#redis-in-a-scaled-environment)
1. [Gitaly](./gitaly.md) (recommended) or [NFS](./nfs.md) 1. [Gitaly](gitaly.md) (recommended) or [NFS](nfs.md)
1. [GitLab application nodes](./gitlab.md) 1. [GitLab application nodes](gitlab.md)
### Full Scaling ### Full Scaling
......
...@@ -17,9 +17,9 @@ If you use a cloud-managed service, or provide your own PostgreSQL: ...@@ -17,9 +17,9 @@ If you use a cloud-managed service, or provide your own PostgreSQL:
## PostgreSQL in a Scaled Environment ## PostgreSQL in a Scaled Environment
This section is relevant for [Scaled Architecture](./README.md#scalable-architecture-examples) This section is relevant for [Scaled Architecture](README.md#scalable-architecture-examples)
environments including [Basic Scaling](./README.md#basic-scaling) and environments including [Basic Scaling](README.md#basic-scaling) and
[Full Scaling](./README.md#full-scaling). [Full Scaling](README.md#full-scaling).
### Provide your own PostgreSQL instance **[CORE ONLY]** ### Provide your own PostgreSQL instance **[CORE ONLY]**
...@@ -87,14 +87,14 @@ Advanced configuration options are supported and can be added if ...@@ -87,14 +87,14 @@ Advanced configuration options are supported and can be added if
needed. needed.
Continue configuration of other components by going Continue configuration of other components by going
[back to Scaled Architectures](./README.md#scalable-architecture-examples) [back to Scaled Architectures](README.md#scalable-architecture-examples)
## PostgreSQL with High Availability ## PostgreSQL with High Availability
This section is relevant for [High Availability Architecture](./README.md#high-availability-architecture-examples) This section is relevant for [High Availability Architecture](README.md#high-availability-architecture-examples)
environments including [Horizontal](./README.md#horizontal), environments including [Horizontal](README.md#horizontal),
[Hybrid](./README.md#hybrid), and [Hybrid](README.md#hybrid), and
[Fully Distributed](./README.md#fully-distributed). [Fully Distributed](README.md#fully-distributed).
### Provide your own PostgreSQL instance **[CORE ONLY]** ### Provide your own PostgreSQL instance **[CORE ONLY]**
......
...@@ -7,8 +7,8 @@ should consider using Gitaly on a separate node. ...@@ -7,8 +7,8 @@ should consider using Gitaly on a separate node.
See the [Gitaly HA Epic](https://gitlab.com/groups/gitlab-org/-/epics/289) to See the [Gitaly HA Epic](https://gitlab.com/groups/gitlab-org/-/epics/289) to
track plans and progress toward high availability support. track plans and progress toward high availability support.
This document is relevant for [Scaled Architecture](./README.md#scalable-architecture-examples) This document is relevant for [Scaled Architecture](README.md#scalable-architecture-examples)
environments and [High Availability Architecture](./README.md#high-availability-architecture-examples). environments and [High Availability Architecture](README.md#high-availability-architecture-examples).
## Running Gitaly on its own server ## Running Gitaly on its own server
...@@ -17,5 +17,5 @@ in Gitaly documentation. ...@@ -17,5 +17,5 @@ in Gitaly documentation.
Continue configuration of other components by going back to: Continue configuration of other components by going back to:
- [Scaled Architectures](./README.md#scalable-architecture-examples) - [Scaled Architectures](README.md#scalable-architecture-examples)
- [High Availability Architectures](./README.md#high-availability-architecture-examples) - [High Availability Architectures](README.md#high-availability-architecture-examples)
...@@ -16,9 +16,9 @@ These will be necessary when configuring the GitLab application servers later. ...@@ -16,9 +16,9 @@ These will be necessary when configuring the GitLab application servers later.
## Redis in a Scaled Environment ## Redis in a Scaled Environment
This section is relevant for [Scaled Architecture](./README.md#scalable-architecture-examples) This section is relevant for [Scaled Architecture](README.md#scalable-architecture-examples)
environments including [Basic Scaling](./README.md#basic-scaling) and environments including [Basic Scaling](README.md#basic-scaling) and
[Full Scaling](./README.md#full-scaling). [Full Scaling](README.md#full-scaling).
### Provide your own Redis instance **[CORE ONLY]** ### Provide your own Redis instance **[CORE ONLY]**
...@@ -34,7 +34,7 @@ In this configuration Redis is not highly available, and represents a single ...@@ -34,7 +34,7 @@ In this configuration Redis is not highly available, and represents a single
point of failure. However, in a scaled environment the objective is to allow point of failure. However, in a scaled environment the objective is to allow
the environment to handle more users or to increase throughput. Redis itself the environment to handle more users or to increase throughput. Redis itself
is generally stable and can handle many requests so it is an acceptable is generally stable and can handle many requests so it is an acceptable
trade off to have only a single instance. See [Scaling and High Availability](./README.md) trade off to have only a single instance. See [Scaling and High Availability](README.md)
for an overview of GitLab scaling and high availability options. for an overview of GitLab scaling and high availability options.
The steps below are the minimum necessary to configure a Redis server with The steps below are the minimum necessary to configure a Redis server with
...@@ -79,14 +79,14 @@ Advanced configuration options are supported and can be added if ...@@ -79,14 +79,14 @@ Advanced configuration options are supported and can be added if
needed. needed.
Continue configuration of other components by going Continue configuration of other components by going
[back to Scaled Architectures](./README.md#scalable-architecture-examples) [back to Scaled Architectures](README.md#scalable-architecture-examples)
## Redis with High Availability ## Redis with High Availability
This section is relevant for [High Availability Architecture](./README.md#high-availability-architecture-examples) This section is relevant for [High Availability Architecture](README.md#high-availability-architecture-examples)
environments including [Horizontal](./README.md#horizontal), environments including [Horizontal](README.md#horizontal),
[Hybrid](./README.md#hybrid), and [Hybrid](README.md#hybrid), and
[Fully Distributed](./README.md#fully-distributed). [Fully Distributed](README.md#fully-distributed).
### Provide your own Redis instance **[CORE ONLY]** ### Provide your own Redis instance **[CORE ONLY]**
......
...@@ -62,7 +62,7 @@ files and add the full paths of the alternative repository storage paths. In ...@@ -62,7 +62,7 @@ files and add the full paths of the alternative repository storage paths. In
the example below, we add two more mountpoints that are named `nfs` and `cephfs` the example below, we add two more mountpoints that are named `nfs` and `cephfs`
respectively. respectively.
NOTE: **Note:** This example uses NFS and CephFS. We do not recommend using EFS for storage as it may impact GitLab's performance. See the [relevant documentation](./high_availability/nfs.md#avoid-using-awss-elastic-file-system-efs) for more details. NOTE: **Note:** This example uses NFS and CephFS. We do not recommend using EFS for storage as it may impact GitLab's performance. See the [relevant documentation](high_availability/nfs.md#avoid-using-awss-elastic-file-system-efs) for more details.
**For installations from source** **For installations from source**
......
--- ---
comments: false comments: false
description: "Learn how to use GitLab CI/CD, the GitLab built-in Continuous Integration, Continuous Deployment, and Continuous Delivery toolset to build, test, and deploy your application." description: "Learn how to use GitLab CI/CD, the GitLab built-in Continuous Integration, Continuous Deployment, and Continuous Delivery toolset to build, test, and deploy your application."
type: index
--- ---
# GitLab CI/CD # GitLab CI/CD
......
---
type: reference
---
# Environments and deployments # Environments and deployments
> Introduced in GitLab 8.9. > Introduced in GitLab 8.9.
...@@ -667,9 +671,24 @@ fetch = +refs/environments/*:refs/remotes/origin/environments/* ...@@ -667,9 +671,24 @@ fetch = +refs/environments/*:refs/remotes/origin/environments/*
### Scoping environments with specs **[PREMIUM]** ### Scoping environments with specs **[PREMIUM]**
Some GitLab [Enterprise Edition](https://about.gitlab.com/pricing/) features can > [Introduced](https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/2112) in [GitLab Premium](https://about.gitlab.com/pricing/) 9.4.
behave differently for each environment. For example, you can
[create a secret variable to be injected only into a production environment](variables/README.md#limiting-environment-scopes-of-environment-variables-premium). You can limit the environment scope of a variable by
defining which environments it can be available for.
Wildcards can be used, and the default environment scope is `*`, which means
any jobs will have this variable, not matter if an environment is defined or
not.
For example, if the environment scope is `production`, then only the jobs
having the environment `production` defined would have this specific variable.
Wildcards (`*`) can be used along with the environment name, therefore if the
environment scope is `review/*` then any jobs with environment names starting
with `review/` would have that particular variable.
Some GitLab features can behave differently for each environment.
For example, you can
[create a secret variable to be injected only into a production environment](variables/README.md#limiting-environment-scopes-of-environment-variables-premium). **[PREMIUM]**
In most cases, these features use the _environment specs_ mechanism, which offers In most cases, these features use the _environment specs_ mechanism, which offers
an efficient way to implement scoping within each environment group. an efficient way to implement scoping within each environment group.
...@@ -693,7 +712,7 @@ Each environment can be matched with the following environment spec: ...@@ -693,7 +712,7 @@ Each environment can be matched with the following environment spec:
As you can see, you can use specific matching for selecting a particular environment, As you can see, you can use specific matching for selecting a particular environment,
and also use wildcard matching (`*`) for selecting a particular environment group, and also use wildcard matching (`*`) for selecting a particular environment group,
such as [Review apps](review_apps/index.md) (`review/*`). such as [Review Apps](review_apps/index.md) (`review/*`).
NOTE: **Note:** NOTE: **Note:**
The most _specific_ spec takes precedence over the other wildcard matching. The most _specific_ spec takes precedence over the other wildcard matching.
...@@ -712,3 +731,15 @@ Below are some links you may find interesting: ...@@ -712,3 +731,15 @@ Below are some links you may find interesting:
- [A blog post on Deployments & Environments](https://about.gitlab.com/2016/08/26/ci-deployment-and-environments/) - [A blog post on Deployments & Environments](https://about.gitlab.com/2016/08/26/ci-deployment-and-environments/)
- [Review Apps - Use dynamic environments to deploy your code for every branch](review_apps/index.md) - [Review Apps - Use dynamic environments to deploy your code for every branch](review_apps/index.md)
- [Deploy Boards for your applications running on Kubernetes](https://docs.gitlab.com/ee/user/project/deploy_boards.html) **[PREMIUM]** - [Deploy Boards for your applications running on Kubernetes](https://docs.gitlab.com/ee/user/project/deploy_boards.html) **[PREMIUM]**
<!-- ## Troubleshooting
Include any troubleshooting steps that you can foresee. If you know beforehand what issues
one might have when setting this up, or when something is changed, or on upgrading, it's
important to describe those, too. Think of things that may go wrong and include them here.
This is important to minimize requests for support, and to avoid doc comments with
questions that you know someone might ask.
Each scenario can be a third-level heading, e.g. `### Getting error message X`.
If you have none to add when creating a doc, leave this section in place
but commented out to help encourage others to add to it in the future. -->
--- ---
description: "An overview of Continuous Integration, Continuous Delivery, and Continuous Deployment, as well as an introduction to GitLab CI/CD." description: "An overview of Continuous Integration, Continuous Delivery, and Continuous Deployment, as well as an introduction to GitLab CI/CD."
type: concepts
--- ---
# Introduction to CI/CD with GitLab # Introduction to CI/CD with GitLab
......
--- ---
table_display_block: true table_display_block: true
type: reference
--- ---
# GitLab CI/CD environment variables # GitLab CI/CD environment variables
...@@ -388,21 +389,9 @@ Once you set them, they will be available for all subsequent pipelines. ...@@ -388,21 +389,9 @@ Once you set them, they will be available for all subsequent pipelines.
### Limiting environment scopes of environment variables **[PREMIUM]** ### Limiting environment scopes of environment variables **[PREMIUM]**
> [Introduced][ee-2112] in [GitLab Premium](https://about.gitlab.com/pricing/) 9.4.
You can limit the environment scope of a variable by You can limit the environment scope of a variable by
[defining which environments][envs] it can be available for. [defining which environments][envs] it can be available for.
Wildcards can be used, and the default environment scope is `*` which means
any jobs will have this variable, not matter if an environment is defined or
not.
For example, if the environment scope is `production`, then only the jobs
having the environment `production` defined would have this specific variable.
Wildcards (`*`) can be used along with the environment name, therefore if the
environment scope is `review/*` then any jobs with environment names starting
with `review/` would have that particular variable.
To learn more about about scoping environments, see [Scoping environments with specs](../environments.md#scoping-environments-with-specs-premium). To learn more about about scoping environments, see [Scoping environments with specs](../environments.md#scoping-environments-with-specs-premium).
### Deployment environment variables ### Deployment environment variables
...@@ -716,7 +705,6 @@ MIIFQzCCBCugAwIBAgIRAL/ElDjuf15xwja1ZnCocWAwDQYJKoZIhvcNAQELBQAw' ...@@ -716,7 +705,6 @@ MIIFQzCCBCugAwIBAgIRAL/ElDjuf15xwja1ZnCocWAwDQYJKoZIhvcNAQELBQAw'
... ...
``` ```
[ee-2112]: https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/2112
[ce-13784]: https://gitlab.com/gitlab-org/gitlab-ce/issues/13784 "Simple protection of CI variables" [ce-13784]: https://gitlab.com/gitlab-org/gitlab-ce/issues/13784 "Simple protection of CI variables"
[envs]: ../environments.md [envs]: ../environments.md
[protected branches]: ../../user/project/protected_branches.md [protected branches]: ../../user/project/protected_branches.md
......
---
type: reference
---
# Deprecated GitLab CI/CD variables # Deprecated GitLab CI/CD variables
Read through this document to learn what predefined variables
were deprecated and their new references.
## GitLab 9.0 renamed variables ## GitLab 9.0 renamed variables
To follow conventions of naming across GitLab, and to further move away from the To follow conventions of naming across GitLab, and to further move away from the
......
---
type: reference
---
# Predefined environment variables reference # Predefined environment variables reference
For an introduction on this subject, read through the For an introduction on this subject, read through the
......
---
type: reference
---
# Where variables can be used # Where variables can be used
As it's described in the [CI/CD variables](README.md) docs, you can As it's described in the [CI/CD variables](README.md) docs, you can
......
---
type: reference
---
# GitLab CI/CD Pipeline Configuration Reference # GitLab CI/CD Pipeline Configuration Reference
GitLab CI/CD [pipelines](../pipelines.md) are configured using a YAML file called `.gitlab-ci.yml` within each project. GitLab CI/CD [pipelines](../pipelines.md) are configured using a YAML file called `.gitlab-ci.yml` within each project.
...@@ -2787,6 +2791,18 @@ using Git 2.10 or newer: ...@@ -2787,6 +2791,18 @@ using Git 2.10 or newer:
git push -o ci.skip git push -o ci.skip
``` ```
<!-- ## Troubleshooting
Include any troubleshooting steps that you can foresee. If you know beforehand what issues
one might have when setting this up, or when something is changed, or on upgrading, it's
important to describe those, too. Think of things that may go wrong and include them here.
This is important to minimize requests for support, and to avoid doc comments with
questions that you know someone might ask.
Each scenario can be a third-level heading, e.g. `### Getting error message X`.
If you have none to add when creating a doc, leave this section in place
but commented out to help encourage others to add to it in the future. -->
[ce-6323]: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/6323 [ce-6323]: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/6323
[ce-6669]: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/6669 [ce-6669]: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/6669
[ce-7983]: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/7983 [ce-7983]: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/7983
......
...@@ -32,6 +32,21 @@ a new presenter specifically for GraphQL. ...@@ -32,6 +32,21 @@ a new presenter specifically for GraphQL.
The presenter is initialized using the object resolved by a field, and The presenter is initialized using the object resolved by a field, and
the context. the context.
### Exposing Global ids
When exposing an `id` field on a type, we will by default try to
expose a global id by calling `to_global_id` on the resource being
rendered.
To override this behaviour, you can implement an `id` method on the
type for which you are exposing an id. Please make sure that when
exposing a `GraphQL::ID_TYPE` using a custom method that it is
globally unique.
The records that are exposing a `full_path` as an `ID_TYPE` are one of
these exceptions. Since the full path is a unique identifier for a
`Project` or `Namespace`.
### Connection Types ### Connection Types
GraphQL uses [cursor based GraphQL uses [cursor based
...@@ -79,14 +94,14 @@ look like this: ...@@ -79,14 +94,14 @@ look like this:
{ {
"cursor": "Nzc=", "cursor": "Nzc=",
"node": { "node": {
"id": "77", "id": "gid://gitlab/Pipeline/77",
"status": "FAILED" "status": "FAILED"
} }
}, },
{ {
"cursor": "Njc=", "cursor": "Njc=",
"node": { "node": {
"id": "67", "id": "gid://gitlab/Pipeline/67",
"status": "FAILED" "status": "FAILED"
} }
} }
...@@ -330,7 +345,7 @@ argument :project_path, GraphQL::ID_TYPE, ...@@ -330,7 +345,7 @@ argument :project_path, GraphQL::ID_TYPE,
required: true, required: true,
description: "The project the merge request to mutate is in" description: "The project the merge request to mutate is in"
argument :iid, GraphQL::ID_TYPE, argument :iid, GraphQL::STRING_TYPE,
required: true, required: true,
description: "The iid of the merge request to mutate" description: "The iid of the merge request to mutate"
......
...@@ -56,7 +56,7 @@ bundle exec rails db RAILS_ENV=development ...@@ -56,7 +56,7 @@ bundle exec rails db RAILS_ENV=development
### `ActiveRecord::PendingMigrationError` with Spring ### `ActiveRecord::PendingMigrationError` with Spring
When running specs with the [Spring preloader](./rake_tasks.md#speed-up-tests-rake-tasks-and-migrations), When running specs with the [Spring preloader](rake_tasks.md#speed-up-tests-rake-tasks-and-migrations),
the test database can get into a corrupted state. Trying to run the migration or the test database can get into a corrupted state. Trying to run the migration or
dropping/resetting the test database has no effect. dropping/resetting the test database has no effect.
......
...@@ -906,7 +906,7 @@ import bundle from 'ee/protected_branches/protected_branches_bundle.js'; ...@@ -906,7 +906,7 @@ import bundle from 'ee/protected_branches/protected_branches_bundle.js';
import bundle from 'ee_else_ce/protected_branches/protected_branches_bundle.js'; import bundle from 'ee_else_ce/protected_branches/protected_branches_bundle.js';
``` ```
See the frontend guide [performance section](./fe_guide/performance.md) for See the frontend guide [performance section](fe_guide/performance.md) for
information on managing page-specific javascript within EE. information on managing page-specific javascript within EE.
......
...@@ -234,7 +234,7 @@ One should apply to be a Vue.js expert by opening an MR when the Merge Request's ...@@ -234,7 +234,7 @@ One should apply to be a Vue.js expert by opening an MR when the Merge Request's
- Deep understanding of Vue and Vuex reactivy - Deep understanding of Vue and Vuex reactivy
- Vue and Vuex code are structured according to both official and our guidelines - Vue and Vuex code are structured according to both official and our guidelines
- Full understanding of testing a Vue and Vuex application - Full understanding of testing a Vue and Vuex application
- Vuex code follows the [documented pattern](./vuex.md#actions-pattern-request-and-receive-namespaces) - Vuex code follows the [documented pattern](vuex.md#actions-pattern-request-and-receive-namespaces)
- Knowledge about the existing Vue and Vuex applications and existing reusable components - Knowledge about the existing Vue and Vuex applications and existing reusable components
[vue-docs]: http://vuejs.org/guide/index.html [vue-docs]: http://vuejs.org/guide/index.html
......
...@@ -212,7 +212,7 @@ Namespaces should be PascalCase. ...@@ -212,7 +212,7 @@ Namespaces should be PascalCase.
``` ```
Note: The namespace should be removed from the translation. See the [translation Note: The namespace should be removed from the translation. See the [translation
guidelines for more details](./translation.md#namespaced-strings). guidelines for more details](translation.md#namespaced-strings).
### Dates / times ### Dates / times
......
...@@ -1027,7 +1027,7 @@ A link can be constructed relative to the current wiki page using `./<page>`, ...@@ -1027,7 +1027,7 @@ A link can be constructed relative to the current wiki page using `./<page>`,
it would link to `<your_wiki>/documentation/related`: it would link to `<your_wiki>/documentation/related`:
```markdown ```markdown
[Link to Related Page](./related) [Link to Related Page](related)
``` ```
- If this snippet was placed on a page at `<your_wiki>/documentation/related/content`, - If this snippet was placed on a page at `<your_wiki>/documentation/related/content`,
...@@ -1041,7 +1041,7 @@ A link can be constructed relative to the current wiki page using `./<page>`, ...@@ -1041,7 +1041,7 @@ A link can be constructed relative to the current wiki page using `./<page>`,
it would link to `<your_wiki>/documentation/related.md`: it would link to `<your_wiki>/documentation/related.md`:
```markdown ```markdown
[Link to Related Page](./related.md) [Link to Related Page](related.md)
``` ```
- If this snippet was placed on a page at `<your_wiki>/documentation/related/content`, - If this snippet was placed on a page at `<your_wiki>/documentation/related/content`,
......
...@@ -86,7 +86,7 @@ pre-filled with the text you entered in the template(s). ...@@ -86,7 +86,7 @@ pre-filled with the text you entered in the template(s).
We make use of Description Templates for Issues and Merge Requests within the GitLab Community Edition project. Please refer to the [`.gitlab` folder][gitlab-ce-templates] for some examples. We make use of Description Templates for Issues and Merge Requests within the GitLab Community Edition project. Please refer to the [`.gitlab` folder][gitlab-ce-templates] for some examples.
> **Tip:** > **Tip:**
It is possible to use [quick actions](./quick_actions.md) within description templates to quickly add labels, assignees, and milestones. The quick actions will only be executed if the user submitting the Issue or Merge Request has the permissions perform the relevant actions. It is possible to use [quick actions](quick_actions.md) within description templates to quickly add labels, assignees, and milestones. The quick actions will only be executed if the user submitting the Issue or Merge Request has the permissions perform the relevant actions.
Here is an example for a Bug report template: Here is an example for a Bug report template:
......
...@@ -12,7 +12,7 @@ module Gitlab ...@@ -12,7 +12,7 @@ module Gitlab
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
def find def find
BatchLoader.for({ model: model_class, id: model_id }).batch do |loader_info, loader| BatchLoader.for({ model: model_class, id: model_id.to_i }).batch do |loader_info, loader|
per_model = loader_info.group_by { |info| info[:model] } per_model = loader_info.group_by { |info| info[:model] }
per_model.each do |model, info| per_model.each do |model, info|
ids = info.map { |i| i[:id] } ids = info.map { |i| i[:id] }
......
...@@ -282,7 +282,7 @@ describe 'Gitlab::Graphql::Authorization' do ...@@ -282,7 +282,7 @@ describe 'Gitlab::Graphql::Authorization' do
issue_ids = issue_edges.map { |issue_edge| issue_edge['node']&.fetch('id') } issue_ids = issue_edges.map { |issue_edge| issue_edge['node']&.fetch('id') }
expect(issue_edges.size).to eq(visible_issues.size) expect(issue_edges.size).to eq(visible_issues.size)
expect(issue_ids).to eq(visible_issues.map { |i| i.id.to_s }) expect(issue_ids).to eq(visible_issues.map { |i| i.to_global_id.to_s })
end end
it 'does not check access on fields that will not be rendered' do it 'does not check access on fields that will not be rendered' do
......
...@@ -107,6 +107,64 @@ describe GitlabSchema do ...@@ -107,6 +107,64 @@ describe GitlabSchema do
end end
end end
describe '.id_from_object' do
it 'returns a global id' do
expect(described_class.id_from_object(build(:project, id: 1))).to be_a(GlobalID)
end
it "raises a meaningful error if a global id couldn't be generated" do
expect { described_class.id_from_object(build(:commit)) }
.to raise_error(RuntimeError, /include `GlobalID::Identification` into/i)
end
end
describe '.object_from_id' do
context 'for subclasses of `ApplicationRecord`' do
it 'returns the correct record' do
user = create(:user)
result = described_class.object_from_id(user.to_global_id.to_s)
expect(result.__sync).to eq(user)
end
it 'batchloads the queries' do
user1 = create(:user)
user2 = create(:user)
expect do
[described_class.object_from_id(user1.to_global_id),
described_class.object_from_id(user2.to_global_id)].map(&:__sync)
end.not_to exceed_query_limit(1)
end
end
context 'for other classes' do
# We cannot use an anonymous class here as `GlobalID` expects `.name` not
# to return `nil`
class TestGlobalId
include GlobalID::Identification
attr_accessor :id
def initialize(id)
@id = id
end
end
it 'falls back to a regular find' do
result = TestGlobalId.new(123)
expect(TestGlobalId).to receive(:find).with("123").and_return(result)
expect(described_class.object_from_id(result.to_global_id)).to eq(result)
end
end
it 'raises the correct error on invalid input' do
expect { described_class.object_from_id("bogus id") }.to raise_error(Gitlab::Graphql::Errors::ArgumentError)
end
end
def field_instrumenters def field_instrumenters
described_class.instrumenters[:field] + described_class.instrumenters[:field_after_built_ins] described_class.instrumenters[:field] + described_class.instrumenters[:field_after_built_ins]
end end
......
...@@ -3,7 +3,7 @@ require 'spec_helper' ...@@ -3,7 +3,7 @@ require 'spec_helper'
describe 'GitlabSchema configurations' do describe 'GitlabSchema configurations' do
include GraphqlHelpers include GraphqlHelpers
let(:project) { create(:project) } set(:project) { create(:project) }
shared_examples 'imposing query limits' do shared_examples 'imposing query limits' do
describe '#max_complexity' do describe '#max_complexity' do
...@@ -136,4 +136,15 @@ describe 'GitlabSchema configurations' do ...@@ -136,4 +136,15 @@ describe 'GitlabSchema configurations' do
post_graphql(query, current_user: nil) post_graphql(query, current_user: nil)
end end
end end
context "global id's" do
it 'uses GlobalID to expose ids' do
post_graphql(graphql_query_for('project', { 'fullPath' => project.full_path }, %w(id)),
current_user: project.owner)
parsed_id = GlobalID.parse(graphql_data['project']['id'])
expect(parsed_id).to eq(project.to_global_id)
end
end
end end
...@@ -56,7 +56,7 @@ describe 'getting group information' do ...@@ -56,7 +56,7 @@ describe 'getting group information' do
post_graphql(group_query(group1), current_user: user1) post_graphql(group_query(group1), current_user: user1)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(200)
expect(graphql_data['group']['id']).to eq(group1.id.to_s) expect(graphql_data['group']['id']).to eq(group1.to_global_id.to_s)
expect(graphql_data['group']['name']).to eq(group1.name) expect(graphql_data['group']['name']).to eq(group1.name)
expect(graphql_data['group']['path']).to eq(group1.path) expect(graphql_data['group']['path']).to eq(group1.path)
expect(graphql_data['group']['description']).to eq(group1.description) expect(graphql_data['group']['description']).to eq(group1.description)
......
...@@ -11,7 +11,7 @@ describe 'Setting WIP status of a merge request' do ...@@ -11,7 +11,7 @@ describe 'Setting WIP status of a merge request' do
let(:mutation) do let(:mutation) do
variables = { variables = {
project_path: project.full_path, project_path: project.full_path,
iid: merge_request.iid iid: merge_request.iid.to_s
} }
graphql_mutation(:merge_request_set_wip, variables.merge(input)) graphql_mutation(:merge_request_set_wip, variables.merge(input))
end end
......
...@@ -60,7 +60,7 @@ describe 'getting projects', :nested_groups do ...@@ -60,7 +60,7 @@ describe 'getting projects', :nested_groups do
expect(graphql_data['namespace']['projects']['edges'].size).to eq(1) expect(graphql_data['namespace']['projects']['edges'].size).to eq(1)
project = graphql_data['namespace']['projects']['edges'][0]['node'] project = graphql_data['namespace']['projects']['edges'][0]['node']
expect(project['id']).to eq(public_project.id.to_s) expect(project['id']).to eq(public_project.to_global_id.to_s)
end end
end end
end end
......
...@@ -698,10 +698,10 @@ ...@@ -698,10 +698,10 @@
resolved "https://registry.yarnpkg.com/@gitlab/svgs/-/svgs-1.63.0.tgz#9dd544026d203e4ce6efed72b05db68f710c4d49" resolved "https://registry.yarnpkg.com/@gitlab/svgs/-/svgs-1.63.0.tgz#9dd544026d203e4ce6efed72b05db68f710c4d49"
integrity sha512-YztrReFTg31B7v5wtUC5j15KHNcMebtW+kACytEU42XomMaIwk4USIbygqWlq0VRHA2VHJrHApfJHIjxiCCQcA== integrity sha512-YztrReFTg31B7v5wtUC5j15KHNcMebtW+kACytEU42XomMaIwk4USIbygqWlq0VRHA2VHJrHApfJHIjxiCCQcA==
"@gitlab/ui@^3.10.3": "@gitlab/ui@^3.11.0":
version "3.10.3" version "3.11.0"
resolved "https://registry.yarnpkg.com/@gitlab/ui/-/ui-3.10.3.tgz#dba2ddc726e203ab341d870cea2fe634f583c08d" resolved "https://registry.yarnpkg.com/@gitlab/ui/-/ui-3.11.0.tgz#7bba82c893f47abbfe7995281dc0ce95290dcc4e"
integrity sha512-Y48DKhOSC+Yw0X8PN+TyR8gITAq6jVHbiTsw+eZkCacs367L1u6w82lr7ba/Bl+4W6DhDWT34VCG0hYbGVrUJw== integrity sha512-55Qxyj2wZILznZJUTUxY1SUuw028IgmP6ZyLd5XF3xk91HWSyq5/zrlr/qRTFGL1cABhxoBLScmXsnOc2CIO0w==
dependencies: dependencies:
"@babel/standalone" "^7.0.0" "@babel/standalone" "^7.0.0"
"@gitlab/vue-toasted" "^1.2.1" "@gitlab/vue-toasted" "^1.2.1"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment