From 25d53486bebc0b245ccf91c83ee366ba79653387 Mon Sep 17 00:00:00 2001 From: Thomas Randolph Date: Thu, 9 Jul 2020 15:23:23 -0600 Subject: [PATCH 1/2] Add file mode to repository blobs --- .../repository/queries/getFiles.query.graphql | 1 + app/graphql/types/tree/blob_type.rb | 2 ++ doc/api/graphql/reference/gitlab_schema.graphql | 5 +++++ doc/api/graphql/reference/gitlab_schema.json | 14 ++++++++++++++ doc/api/graphql/reference/index.md | 1 + spec/graphql/types/tree/blob_type_spec.rb | 2 +- 6 files changed, 24 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/repository/queries/getFiles.query.graphql b/app/assets/javascripts/repository/queries/getFiles.query.graphql index 2aaf5066b4ac07..feb89df04925f5 100644 --- a/app/assets/javascripts/repository/queries/getFiles.query.graphql +++ b/app/assets/javascripts/repository/queries/getFiles.query.graphql @@ -45,6 +45,7 @@ query getFiles( edges { node { ...TreeEntry + mode webUrl lfsOid } diff --git a/app/graphql/types/tree/blob_type.rb b/app/graphql/types/tree/blob_type.rb index 22349203519c6a..36cae756a0d2ac 100644 --- a/app/graphql/types/tree/blob_type.rb +++ b/app/graphql/types/tree/blob_type.rb @@ -17,6 +17,8 @@ class BlobType < BaseObject resolve: -> (blob, args, ctx) do Gitlab::Graphql::Loaders::BatchLfsOidLoader.new(blob.repository, blob.id).find end + field :mode, GraphQL::STRING_TYPE, null: true, + description: 'Blob mode in numeric format' # rubocop: enable Graphql/AuthorizeTypes end end diff --git a/doc/api/graphql/reference/gitlab_schema.graphql b/doc/api/graphql/reference/gitlab_schema.graphql index 087559f204c0c8..644d9f8f7f2951 100644 --- a/doc/api/graphql/reference/gitlab_schema.graphql +++ b/doc/api/graphql/reference/gitlab_schema.graphql @@ -793,6 +793,11 @@ type Blob implements Entry { """ lfsOid: String + """ + Blob mode in numeric format + """ + mode: String + """ Name of the entry """ diff --git a/doc/api/graphql/reference/gitlab_schema.json b/doc/api/graphql/reference/gitlab_schema.json index 6c0c81852a4feb..8213604ed9956d 100644 --- a/doc/api/graphql/reference/gitlab_schema.json +++ b/doc/api/graphql/reference/gitlab_schema.json @@ -2056,6 +2056,20 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "mode", + "description": "Blob mode in numeric format", + "args": [ + + ], + "type": { + "kind": "SCALAR", + "name": "String", + "ofType": null + }, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "name", "description": "Name of the entry", diff --git a/doc/api/graphql/reference/index.md b/doc/api/graphql/reference/index.md index 4327c13d775fc4..66e96148d44109 100644 --- a/doc/api/graphql/reference/index.md +++ b/doc/api/graphql/reference/index.md @@ -160,6 +160,7 @@ Autogenerated return type of AwardEmojiToggle | `flatPath` | String! | Flat path of the entry | | `id` | ID! | ID of the entry | | `lfsOid` | String | LFS ID of the blob | +| `mode` | String | Blob mode in numeric format | | `name` | String! | Name of the entry | | `path` | String! | Path of the entry | | `sha` | String! | Last commit sha for the entry | diff --git a/spec/graphql/types/tree/blob_type_spec.rb b/spec/graphql/types/tree/blob_type_spec.rb index 2c9089de3dd157..73d61d4860cfe5 100644 --- a/spec/graphql/types/tree/blob_type_spec.rb +++ b/spec/graphql/types/tree/blob_type_spec.rb @@ -5,5 +5,5 @@ RSpec.describe Types::Tree::BlobType do specify { expect(described_class.graphql_name).to eq('Blob') } - specify { expect(described_class).to have_graphql_fields(:id, :sha, :name, :type, :path, :flat_path, :web_url, :lfs_oid) } + specify { expect(described_class).to have_graphql_fields(:id, :sha, :name, :type, :path, :flat_path, :web_url, :lfs_oid, :mode) } end -- GitLab From 95e080ddb3c7867c8c5de511c22bcc5a71e11e85 Mon Sep 17 00:00:00 2001 From: Thomas Randolph Date: Mon, 13 Jul 2020 14:10:41 -0600 Subject: [PATCH 2/2] Add changelog for newly exposed GQL value --- changelogs/unreleased/symlink-icon-graphql-file-mode.yml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 changelogs/unreleased/symlink-icon-graphql-file-mode.yml diff --git a/changelogs/unreleased/symlink-icon-graphql-file-mode.yml b/changelogs/unreleased/symlink-icon-graphql-file-mode.yml new file mode 100644 index 00000000000000..b84fb22c24b071 --- /dev/null +++ b/changelogs/unreleased/symlink-icon-graphql-file-mode.yml @@ -0,0 +1,5 @@ +--- +title: Expose blob mode in GraphQL for repository files +merge_request: 36488 +author: +type: other -- GitLab