Commit 02ede8d8 authored by Brett Walker's avatar Brett Walker

Convert old graphql types to newer types

in prep for interpreter
parent c306cca2
......@@ -104,28 +104,6 @@ Graphql/OldTypes:
- 'app/graphql/types/container_repository_type.rb'
- 'app/graphql/types/countable_connection_type.rb'
- 'app/graphql/types/custom_emoji_type.rb'
- 'app/graphql/types/query_complexity_type.rb'
- 'app/graphql/types/release_asset_link_shared_input_arguments.rb'
- 'app/graphql/types/release_asset_link_type.rb'
- 'app/graphql/types/release_assets_type.rb'
- 'app/graphql/types/release_links_type.rb'
- 'app/graphql/types/release_source_type.rb'
- 'app/graphql/types/release_type.rb'
- 'app/graphql/types/repository/blob_type.rb'
- 'app/graphql/types/repository_type.rb'
- 'app/graphql/types/resolvable_interface.rb'
- 'app/graphql/types/snippet_type.rb'
- 'app/graphql/types/snippets/blob_action_input_type.rb'
- 'app/graphql/types/snippets/blob_type.rb'
- 'app/graphql/types/task_completion_status.rb'
- 'app/graphql/types/terraform/state_type.rb'
- 'app/graphql/types/terraform/state_version_type.rb'
- 'app/graphql/types/timelog_type.rb'
- 'app/graphql/types/todo_type.rb'
- 'app/graphql/types/tree/blob_type.rb'
- 'app/graphql/types/tree/entry_type.rb'
- 'app/graphql/types/tree/tree_entry_type.rb'
- 'app/graphql/types/user_status_type.rb'
- 'ee/app/graphql/ee/mutations/ci/ci_cd_settings_update.rb'
- 'ee/app/graphql/ee/resolvers/issues_resolver.rb'
- 'ee/app/graphql/ee/resolvers/namespace_projects_resolver.rb'
......
......@@ -9,7 +9,7 @@ module Types
alias_method :query, :object
field :limit, GraphQL::INT_TYPE,
field :limit, GraphQL::Types::Int,
null: true,
method: :max_complexity,
see: {
......@@ -18,7 +18,7 @@ module Types
},
description: 'GraphQL query complexity limit.'
field :score, GraphQL::INT_TYPE,
field :score, GraphQL::Types::Int,
null: true,
description: 'GraphQL query complexity score.'
......
......@@ -5,15 +5,15 @@ module Types
extend ActiveSupport::Concern
included do
argument :name, GraphQL::STRING_TYPE,
argument :name, GraphQL::Types::String,
required: true,
description: 'Name of the asset link.'
argument :url, GraphQL::STRING_TYPE,
argument :url, GraphQL::Types::String,
required: true,
description: 'URL of the asset link.'
argument :direct_asset_path, GraphQL::STRING_TYPE,
argument :direct_asset_path, GraphQL::Types::String,
required: false, as: :filepath,
description: 'Relative path for a direct asset link.'
......
......@@ -7,20 +7,20 @@ module Types
authorize :read_release
field :id, GraphQL::ID_TYPE, null: false,
field :id, GraphQL::Types::ID, null: false,
description: 'ID of the link.'
field :name, GraphQL::STRING_TYPE, null: true,
field :name, GraphQL::Types::String, null: true,
description: 'Name of the link.'
field :url, GraphQL::STRING_TYPE, null: true,
field :url, GraphQL::Types::String, null: true,
description: 'URL of the link.'
field :link_type, Types::ReleaseAssetLinkTypeEnum, null: true,
description: 'Type of the link: `other`, `runbook`, `image`, `package`; defaults to `other`.'
field :external, GraphQL::BOOLEAN_TYPE, null: true, method: :external?,
field :external, GraphQL::Types::Boolean, null: true, method: :external?,
description: 'Indicates the link points to an external resource.'
field :direct_asset_url, GraphQL::STRING_TYPE, null: true,
field :direct_asset_url, GraphQL::Types::String, null: true,
description: 'Direct asset URL of the link.'
field :direct_asset_path, GraphQL::STRING_TYPE, null: true, method: :filepath,
field :direct_asset_path, GraphQL::Types::String, null: true, method: :filepath,
description: 'Relative path for the direct asset link.'
def direct_asset_url
......
......@@ -11,7 +11,7 @@ module Types
present_using ReleasePresenter
field :count, GraphQL::INT_TYPE, null: true, method: :assets_count,
field :count, GraphQL::Types::Int, null: true, method: :assets_count,
description: 'Number of assets of the release.'
field :links, Types::ReleaseAssetLinkType.connection_type, null: true, method: :sorted_links,
description: 'Asset links of the release.'
......
......@@ -10,20 +10,20 @@ module Types
present_using ReleasePresenter
field :self_url, GraphQL::STRING_TYPE, null: true,
field :self_url, GraphQL::Types::String, null: true,
description: 'HTTP URL of the release.'
field :edit_url, GraphQL::STRING_TYPE, null: true,
field :edit_url, GraphQL::Types::String, null: true,
description: "HTTP URL of the release's edit page.",
authorize: :update_release
field :opened_merge_requests_url, GraphQL::STRING_TYPE, null: true,
field :opened_merge_requests_url, GraphQL::Types::String, null: true,
description: 'HTTP URL of the merge request page, filtered by this release and `state=open`.'
field :merged_merge_requests_url, GraphQL::STRING_TYPE, null: true,
field :merged_merge_requests_url, GraphQL::Types::String, null: true,
description: 'HTTP URL of the merge request page , filtered by this release and `state=merged`.'
field :closed_merge_requests_url, GraphQL::STRING_TYPE, null: true,
field :closed_merge_requests_url, GraphQL::Types::String, null: true,
description: 'HTTP URL of the merge request page , filtered by this release and `state=closed`.'
field :opened_issues_url, GraphQL::STRING_TYPE, null: true,
field :opened_issues_url, GraphQL::Types::String, null: true,
description: 'HTTP URL of the issues page, filtered by this release and `state=open`.'
field :closed_issues_url, GraphQL::STRING_TYPE, null: true,
field :closed_issues_url, GraphQL::Types::String, null: true,
description: 'HTTP URL of the issues page, filtered by this release and `state=closed`.'
end
end
......@@ -7,9 +7,9 @@ module Types
authorize :download_code
field :format, GraphQL::STRING_TYPE, null: true,
field :format, GraphQL::Types::String, null: true,
description: 'Format of the source.'
field :url, GraphQL::STRING_TYPE, null: true,
field :url, GraphQL::Types::String, null: true,
description: 'Download URL of the source.'
end
end
......@@ -13,22 +13,22 @@ module Types
present_using ReleasePresenter
field :tag_name, GraphQL::STRING_TYPE, null: true, method: :tag,
field :tag_name, GraphQL::Types::String, null: true, method: :tag,
description: 'Name of the tag associated with the release.',
authorize: :download_code
field :tag_path, GraphQL::STRING_TYPE, null: true,
field :tag_path, GraphQL::Types::String, null: true,
description: 'Relative web path to the tag associated with the release.',
authorize: :download_code
field :description, GraphQL::STRING_TYPE, null: true,
field :description, GraphQL::Types::String, null: true,
description: 'Description (also known as "release notes") of the release.'
markdown_field :description_html, null: true
field :name, GraphQL::STRING_TYPE, null: true,
field :name, GraphQL::Types::String, null: true,
description: 'Name of the release.'
field :created_at, Types::TimeType, null: true,
description: 'Timestamp of when the release was created.'
field :released_at, Types::TimeType, null: true,
description: 'Timestamp of when the release was released.'
field :upcoming_release, GraphQL::BOOLEAN_TYPE, null: true, method: :upcoming_release?,
field :upcoming_release, GraphQL::Types::Boolean, null: true, method: :upcoming_release?,
description: 'Indicates the release is an upcoming release.'
field :assets, Types::ReleaseAssetsType, null: true, method: :itself,
description: 'Assets of the release.'
......
......@@ -8,67 +8,67 @@ module Types
graphql_name 'RepositoryBlob'
field :id, GraphQL::ID_TYPE, null: false,
field :id, GraphQL::Types::ID, null: false,
description: 'ID of the blob.'
field :oid, GraphQL::STRING_TYPE, null: false, method: :id,
field :oid, GraphQL::Types::String, null: false, method: :id,
description: 'OID of the blob.'
field :path, GraphQL::STRING_TYPE, null: false,
field :path, GraphQL::Types::String, null: false,
description: 'Path of the blob.'
field :name, GraphQL::STRING_TYPE,
field :name, GraphQL::Types::String,
description: 'Blob name.',
null: true
field :mode, type: GraphQL::STRING_TYPE,
field :mode, type: GraphQL::Types::String,
description: 'Blob mode.',
null: true
field :lfs_oid, GraphQL::STRING_TYPE, null: true,
field :lfs_oid, GraphQL::Types::String, null: true,
calls_gitaly: true,
description: 'LFS OID of the blob.'
field :web_path, GraphQL::STRING_TYPE, null: true,
field :web_path, GraphQL::Types::String, null: true,
description: 'Web path of the blob.'
field :ide_edit_path, GraphQL::STRING_TYPE, null: true,
field :ide_edit_path, GraphQL::Types::String, null: true,
description: 'Web path to edit this blob in the Web IDE.'
field :fork_and_edit_path, GraphQL::STRING_TYPE, null: true,
field :fork_and_edit_path, GraphQL::Types::String, null: true,
description: 'Web path to edit this blob using a forked project.'
field :ide_fork_and_edit_path, GraphQL::STRING_TYPE, null: true,
field :ide_fork_and_edit_path, GraphQL::Types::String, null: true,
description: 'Web path to edit this blob in the Web IDE using a forked project.'
field :size, GraphQL::INT_TYPE, null: true,
field :size, GraphQL::Types::Int, null: true,
description: 'Size (in bytes) of the blob.'
field :raw_size, GraphQL::INT_TYPE, null: true,
field :raw_size, GraphQL::Types::Int, null: true,
description: 'Size (in bytes) of the blob, or the blob target if stored externally.'
field :raw_blob, GraphQL::STRING_TYPE, null: true, method: :data,
field :raw_blob, GraphQL::Types::String, null: true, method: :data,
description: 'The raw content of the blob.'
field :raw_text_blob, GraphQL::STRING_TYPE, null: true, method: :text_only_data,
field :raw_text_blob, GraphQL::Types::String, null: true, method: :text_only_data,
description: 'The raw content of the blob, if the blob is text data.'
field :stored_externally, GraphQL::BOOLEAN_TYPE, null: true, method: :stored_externally?,
field :stored_externally, GraphQL::Types::Boolean, null: true, method: :stored_externally?,
description: "Whether the blob's content is stored externally (for instance, in LFS)."
field :edit_blob_path, GraphQL::STRING_TYPE, null: true,
field :edit_blob_path, GraphQL::Types::String, null: true,
description: 'Web path to edit the blob in the old-style editor.'
field :raw_path, GraphQL::STRING_TYPE, null: true,
field :raw_path, GraphQL::Types::String, null: true,
description: 'Web path to download the raw blob.'
field :external_storage_url, GraphQL::STRING_TYPE, null: true,
field :external_storage_url, GraphQL::Types::String, null: true,
description: 'Web path to download the raw blob via external storage, if enabled.'
field :replace_path, GraphQL::STRING_TYPE, null: true,
field :replace_path, GraphQL::Types::String, null: true,
description: 'Web path to replace the blob content.'
field :file_type, GraphQL::STRING_TYPE, null: true,
field :file_type, GraphQL::Types::String, null: true,
description: 'The expected format of the blob based on the extension.'
field :simple_viewer, type: Types::BlobViewerType,
......@@ -79,12 +79,12 @@ module Types
description: 'Blob content rich viewer.',
null: true
field :plain_data, GraphQL::STRING_TYPE,
field :plain_data, GraphQL::Types::String,
description: 'Blob plain highlighted data.',
null: true,
calls_gitaly: true
field :can_modify_blob, GraphQL::BOOLEAN_TYPE, null: true, method: :can_modify_blob?,
field :can_modify_blob, GraphQL::Types::Boolean, null: true, method: :can_modify_blob?,
calls_gitaly: true,
description: 'Whether the current user can modify the blob.'
......
......@@ -6,20 +6,20 @@ module Types
authorize :download_code
field :root_ref, GraphQL::STRING_TYPE, null: true, calls_gitaly: true,
field :root_ref, GraphQL::Types::String, null: true, calls_gitaly: true,
description: 'Default branch of the repository.'
field :empty, GraphQL::BOOLEAN_TYPE, null: false, method: :empty?, calls_gitaly: true,
field :empty, GraphQL::Types::Boolean, null: false, method: :empty?, calls_gitaly: true,
description: 'Indicates repository has no visible content.'
field :exists, GraphQL::BOOLEAN_TYPE, null: false, method: :exists?, calls_gitaly: true,
field :exists, GraphQL::Types::Boolean, null: false, method: :exists?, calls_gitaly: true,
description: 'Indicates a corresponding Git repository exists on disk.'
field :tree, Types::Tree::TreeType, null: true, resolver: Resolvers::TreeResolver, calls_gitaly: true,
description: 'Tree of the repository.'
field :blobs, Types::Repository::BlobType.connection_type, null: true, resolver: Resolvers::BlobsResolver, calls_gitaly: true,
description: 'Blobs contained within the repository'
field :branch_names, [GraphQL::STRING_TYPE], null: true, calls_gitaly: true,
field :branch_names, [GraphQL::Types::String], null: true, calls_gitaly: true,
complexity: 170, description: 'Names of branches available in this repository that match the search pattern.',
resolver: Resolvers::RepositoryBranchNamesResolver
field :disk_path, GraphQL::STRING_TYPE,
field :disk_path, GraphQL::Types::String,
description: 'Shows a disk path of the repository.',
null: true,
authorize: :read_storage_disk_path
......
......@@ -16,10 +16,10 @@ module Types
Gitlab::Graphql::Loaders::BatchModelLoader.new(User, object.resolved_by_id).find
end
field :resolved, GraphQL::BOOLEAN_TYPE, null: false,
field :resolved, GraphQL::Types::Boolean, null: false,
description: 'Indicates if the object is resolved.',
method: :resolved?
field :resolvable, GraphQL::BOOLEAN_TYPE, null: false,
field :resolvable, GraphQL::Types::Boolean, null: false,
description: 'Indicates if the object can be resolved.',
method: :resolvable?
field :resolved_at, Types::TimeType, null: true,
......
......@@ -17,7 +17,7 @@ module Types
description: 'ID of the snippet.',
null: false
field :title, GraphQL::STRING_TYPE,
field :title, GraphQL::Types::String,
description: 'Title of the snippet.',
null: false
......@@ -33,11 +33,11 @@ module Types
description: 'The owner of the snippet.',
null: true
field :file_name, GraphQL::STRING_TYPE,
field :file_name, GraphQL::Types::String,
description: 'File Name of the snippet.',
null: true
field :description, GraphQL::STRING_TYPE,
field :description, GraphQL::Types::String,
description: 'Description of the snippet.',
null: true
......@@ -53,11 +53,11 @@ module Types
description: 'Timestamp this snippet was updated.',
null: false
field :web_url, type: GraphQL::STRING_TYPE,
field :web_url, type: GraphQL::Types::String,
description: 'Web URL of the snippet.',
null: false
field :raw_url, type: GraphQL::STRING_TYPE,
field :raw_url, type: GraphQL::Types::String,
description: 'Raw URL of the snippet.',
null: false
......@@ -67,12 +67,12 @@ module Types
null: true,
resolver: Resolvers::Snippets::BlobsResolver
field :ssh_url_to_repo, type: GraphQL::STRING_TYPE,
field :ssh_url_to_repo, type: GraphQL::Types::String,
description: 'SSH URL to the snippet repository.',
calls_gitaly: true,
null: true
field :http_url_to_repo, type: GraphQL::STRING_TYPE,
field :http_url_to_repo, type: GraphQL::Types::String,
description: 'HTTP URL to the snippet repository.',
calls_gitaly: true,
null: true
......
......@@ -10,15 +10,15 @@ module Types
description: 'Type of input action.',
required: true
argument :previous_path, GraphQL::STRING_TYPE,
argument :previous_path, GraphQL::Types::String,
description: 'Previous path of the snippet file.',
required: false
argument :file_path, GraphQL::STRING_TYPE,
argument :file_path, GraphQL::Types::String,
description: 'Path of the snippet file.',
required: true
argument :content, GraphQL::STRING_TYPE,
argument :content, GraphQL::Types::String,
description: 'Snippet file content.',
required: false
end
......
......@@ -8,36 +8,36 @@ module Types
description 'Represents the snippet blob'
present_using SnippetBlobPresenter
field :rich_data, GraphQL::STRING_TYPE,
field :rich_data, GraphQL::Types::String,
description: 'Blob highlighted data.',
null: true
field :plain_data, GraphQL::STRING_TYPE,
field :plain_data, GraphQL::Types::String,
description: 'Blob plain highlighted data.',
null: true
field :raw_plain_data, GraphQL::STRING_TYPE,
field :raw_plain_data, GraphQL::Types::String,
description: 'The raw content of the blob, if the blob is text data.',
null: true
field :raw_path, GraphQL::STRING_TYPE,
field :raw_path, GraphQL::Types::String,
description: 'Blob raw content endpoint path.',
null: false
field :size, GraphQL::INT_TYPE,
field :size, GraphQL::Types::Int,
description: 'Blob size.',
null: false
field :binary, GraphQL::BOOLEAN_TYPE,
field :binary, GraphQL::Types::Boolean,
description: 'Shows whether the blob is binary.',
method: :binary?,
null: false
field :name, GraphQL::STRING_TYPE,
field :name, GraphQL::Types::String,
description: 'Blob name.',
null: true
field :path, GraphQL::STRING_TYPE,
field :path, GraphQL::Types::String,
description: 'Blob path.',
null: true
......@@ -49,15 +49,15 @@ module Types
description: 'Blob content rich viewer.',
null: true
field :mode, type: GraphQL::STRING_TYPE,
field :mode, type: GraphQL::Types::String,
description: 'Blob mode.',
null: true
field :external_storage, type: GraphQL::STRING_TYPE,
field :external_storage, type: GraphQL::Types::String,
description: 'Blob external storage.',
null: true
field :rendered_as_text, type: GraphQL::BOOLEAN_TYPE,
field :rendered_as_text, type: GraphQL::Types::Boolean,
description: 'Shows whether the blob is rendered as text.',
method: :rendered_as_text?,
null: false
......
......@@ -8,9 +8,9 @@ module Types
graphql_name 'TaskCompletionStatus'
description 'Completion status of tasks'
field :count, GraphQL::INT_TYPE, null: false,
field :count, GraphQL::Types::Int, null: false,
description: 'Number of total tasks.'
field :completed_count, GraphQL::INT_TYPE, null: false,
field :completed_count, GraphQL::Types::Int, null: false,
description: 'Number of completed tasks.'
end
# rubocop: enable Graphql/AuthorizeTypes
......
......@@ -9,11 +9,11 @@ module Types
connection_type_class(Types::CountableConnectionType)
field :id, GraphQL::ID_TYPE,
field :id, GraphQL::Types::ID,
null: false,
description: 'ID of the Terraform state.'
field :name, GraphQL::STRING_TYPE,
field :name, GraphQL::Types::String,
null: false,
description: 'Name of the Terraform state.'
......
......@@ -9,7 +9,7 @@ module Types
authorize :read_terraform_state
field :id, GraphQL::ID_TYPE,
field :id, GraphQL::Types::ID,
null: false,
description: 'ID of the Terraform state version.'
......@@ -17,7 +17,7 @@ module Types
null: true,
description: 'The user that created this version.'
field :download_path, GraphQL::STRING_TYPE,
field :download_path, GraphQL::Types::String,
null: true,
description: "URL for downloading the version's JSON file."
......@@ -25,7 +25,7 @@ module Types
null: true,
description: 'The job that created this version.'
field :serial, GraphQL::INT_TYPE,
field :serial, GraphQL::Types::Int,
null: true,
description: 'Serial number of the version.',
method: :version
......
......@@ -12,7 +12,7 @@ module Types
description: 'Timestamp of when the time tracked was spent at.'
field :time_spent,
GraphQL::INT_TYPE,
GraphQL::Types::Int,
null: false,
description: 'The time spent displayed in seconds.'
......
......@@ -9,7 +9,7 @@ module Types
authorize :read_todo
field :id, GraphQL::ID_TYPE,
field :id, GraphQL::Types::ID,
description: 'ID of the to-do item.',
null: false
......@@ -35,7 +35,7 @@ module Types
description: 'Target type of the to-do item.',
null: false
field :body, GraphQL::STRING_TYPE,
field :body, GraphQL::Types::String,
description: 'Body of the to-do item.',
null: false,
calls_gitaly: true # TODO This is only true when `target_type` is `Commit`. See https://gitlab.com/gitlab-org/gitlab/issues/34757#note_234752665
......
......@@ -10,14 +10,14 @@ module Types
graphql_name 'Blob'
field :web_url, GraphQL::STRING_TYPE, null: true,
field :web_url, GraphQL::Types::String, null: true,
description: 'Web URL of the blob.'
field :web_path, GraphQL::STRING_TYPE, null: true,
field :web_path, GraphQL::Types::String, null: true,
description: 'Web path of the blob.'
field :lfs_oid, GraphQL::STRING_TYPE, null: true,
field :lfs_oid, GraphQL::Types::String, null: true,
calls_gitaly: true,
description: 'LFS ID of the blob.'
field :mode, GraphQL::STRING_TYPE, null: true,
field :mode, GraphQL::Types::String, null: true,
description: 'Blob mode in numeric format.'
def lfs_oid
......
......@@ -4,17 +4,17 @@ module Types
module EntryType
include Types::BaseInterface
field :id, GraphQL::ID_TYPE, null: false,
field :id, GraphQL::Types::ID, null: false,
description: 'ID of the entry.'
field :sha, GraphQL::STRING_TYPE, null: false,
field :sha, GraphQL::Types::String, null: false,
description: 'Last commit SHA for the entry.', method: :id
field :name, GraphQL::STRING_TYPE, null: false,
field :name, GraphQL::Types::String, null: false,
description: 'Name of the entry.'
field :type, Tree::TypeEnum, null: false,
description: 'Type of tree entry.'
field :path, GraphQL::STRING_TYPE, null: false,
field :path, GraphQL::Types::String, null: false,
description: 'Path of the entry.'
field :flat_path, GraphQL::STRING_TYPE, null: false,
field :flat_path, GraphQL::Types::String, null: false,
description: 'Flat path of the entry.'
end
end
......
......@@ -8,9 +8,9 @@ module Types
graphql_name 'Submodule'
field :web_url, type: GraphQL::STRING_TYPE, null: true,
field :web_url, type: GraphQL::Types::String, null: true,
description: 'Web URL for the sub-module.'
field :tree_url, type: GraphQL::STRING_TYPE, null: true,
field :tree_url, type: GraphQL::Types::String, null: true,
description: 'Tree URL for the sub-module.'
end
# rubocop: enable Graphql/AuthorizeTypes
......
......@@ -11,9 +11,9 @@ module Types
graphql_name 'TreeEntry'
description 'Represents a directory'
field :web_url, GraphQL::STRING_TYPE, null: true,
field :web_url, GraphQL::Types::String, null: true,
description: 'Web URL for the tree entry (directory).'
field :web_path, GraphQL::STRING_TYPE, null: true,
field :web_path, GraphQL::Types::String, null: true,
description: 'Web path for the tree entry (directory).'
end
# rubocop: enable Graphql/AuthorizeTypes
......
......@@ -14,20 +14,20 @@ module Types
method: :itself
field :id,
type: GraphQL::ID_TYPE,
type: GraphQL::Types::ID,
null: false,
description: 'ID of the user.'
field :bot,
type: GraphQL::BOOLEAN_TYPE,
type: GraphQL::Types::Boolean,
null: false,
description: 'Indicates if the user is a bot.',
method: :bot?
field :username,
type: GraphQL::STRING_TYPE,
type: GraphQL::Types::String,
null: false,
description: 'Username of the user. Unique within this instance of GitLab.'
field :name,
type: GraphQL::STRING_TYPE,
type: GraphQL::Types::String,
null: false,
description: 'Human-readable name of the user.'
field :state,
......@@ -35,24 +35,24 @@ module Types
null: false,
description: 'State of the user.'
field :email,
type: GraphQL::STRING_TYPE,
type: GraphQL::Types::String,
null: true,
description: 'User email.', method: :public_email,
deprecated: { reason: :renamed, replacement: 'User.publicEmail', milestone: '13.7' }
field :public_email,
type: GraphQL::STRING_TYPE,
type: GraphQL::Types::String,
null: true,
description: "User's public email."
field :avatar_url,
type: GraphQL::STRING_TYPE,
type: GraphQL::Types::String,
null: true,
description: "URL of the user's avatar."
field :web_url,
type: GraphQL::STRING_TYPE,
type: GraphQL::Types::String,
null: false,
description: 'Web URL of the user.'
field :web_path,
type: GraphQL::STRING_TYPE,
type: GraphQL::Types::String,
null: false,
description: 'Web path of the user.'
field :todos,
......@@ -70,7 +70,7 @@ module Types
null: true,
description: 'User status.'
field :location,
type: ::GraphQL::STRING_TYPE,
type: ::GraphQL::Types::String,
null: true,
description: 'The location of the user.'
field :project_memberships,
......
......@@ -13,14 +13,14 @@ module Types
authorize :read_merge_request
field :can_merge,
type: ::GraphQL::BOOLEAN_TYPE,
type: ::GraphQL::Types::Boolean,
null: false,
calls_gitaly: true,
method: :can_merge?,
description: 'Whether this user can merge this merge request.'
field :can_update,
type: ::GraphQL::BOOLEAN_TYPE,
type: ::GraphQL::Types::Boolean,
null: false,
method: :can_update?,
description: 'Whether this user can update this merge request.'
......@@ -31,13 +31,13 @@ module Types
description: 'The state of the review by this user.'
field :reviewed,
type: ::GraphQL::BOOLEAN_TYPE,
type: ::GraphQL::Types::Boolean,
null: false,
method: :reviewed?,
description: 'Whether this user has provided a review for this merge request.'
field :approved,
type: ::GraphQL::BOOLEAN_TYPE,
type: ::GraphQL::Types::Boolean,
null: false,
method: :approved?,
description: 'Whether this user has approved this merge request.'
......
......@@ -7,9 +7,9 @@ module Types
markdown_field :message_html, null: true,
description: 'HTML of the user status message'
field :message, GraphQL::STRING_TYPE, null: true,
field :message, GraphQL::Types::String, null: true,
description: 'User status message.'
field :emoji, GraphQL::STRING_TYPE, null: true,
field :emoji, GraphQL::Types::String, null: true,
description: 'String representation of emoji.'
field :availability, Types::AvailabilityEnum, null: false,
description: 'User availability status.'
......
......@@ -133,20 +133,24 @@ For example, `app/graphql/types/issue_type.rb`:
```ruby
graphql_name 'Issue'
field :iid, GraphQL::ID_TYPE, null: true
field :title, GraphQL::STRING_TYPE, null: true
field :iid, GraphQL::Types::ID, null: true
field :title, GraphQL::Types::String, null: true
# we also have a method here that we've defined, that extends `field`
markdown_field :title_html, null: true
field :description, GraphQL::STRING_TYPE, null: true
field :description, GraphQL::Types::String, null: true
markdown_field :description_html, null: true
```
We give each type a name (in this case `Issue`).
The `iid`, `title` and `description` are _scalar_ GraphQL types.
`iid` is a `GraphQL::ID_TYPE`, a special string type that signifies a unique ID.
`title` and `description` are regular `GraphQL::STRING_TYPE` types.
`iid` is a `GraphQL::Types::ID`, a special string type that signifies a unique ID.
`title` and `description` are regular `GraphQL::Types::String` types.
Note that the old scalar types `GraphQL:ID`, `GraphQL::INT_TYPE`, `GraphQL::STRING_TYPE`,
and `GraphQL:BOOLEAN_TYPE` are no longer allowed. Please use `GraphQL::Types::ID`,
`GraphQL::Types::Int`, `GraphQL::Types::String`, and `GraphQL::Types::Boolean`.
When exposing a model through the GraphQL API, we do so by creating a
new type in `app/graphql/types`. You can also declare custom GraphQL data types
......@@ -225,7 +229,7 @@ Using an example from
[`Types::Notes::DiscussionType`](https://gitlab.com/gitlab-org/gitlab/-/blob/3c95bd9/app/graphql/types/notes/discussion_type.rb#L24-26):
```ruby
field :reply_id, GraphQL::ID_TYPE
field :reply_id, GraphQL::Types::ID
def reply_id
::Gitlab::GlobalId.build(object, id: object.reply_id)
......@@ -402,7 +406,7 @@ class BranchResolver < BaseResolver
type ::Types::BranchType, null: true
calls_gitaly!
argument name: ::GraphQL::STRING_TYPE, required: true
argument name: ::GraphQL::Types::String, required: true
def resolve(name:)
object.branch(name)
......@@ -499,7 +503,7 @@ everyone.
Example:
```ruby
field :test_field, type: GraphQL::STRING_TYPE,
field :test_field, type: GraphQL::Types::String,
null: true,
description: 'Some test field.',
feature_flag: :my_feature_flag
......@@ -523,7 +527,7 @@ When applying a feature flag to toggle the value of a field, the
Example:
```ruby
field :foo, GraphQL::STRING_TYPE,
field :foo, GraphQL::Types::String,
null: true,
description: 'Some test field. Will always return `null`' \
'if `my_feature_flag` feature flag is disabled.'
......@@ -553,7 +557,7 @@ The value of the property is a `Hash` of:
Example:
```ruby
field :token, GraphQL::STRING_TYPE, null: true,
field :token, GraphQL::Types::String, null: true,
deprecated: { reason: 'Login via token has been removed', milestone: '10.0' },
description: 'Token for login.'
```
......@@ -795,15 +799,15 @@ We can use GraphQL types like this:
```ruby
module Types
class ChartType < BaseObject
field :title, GraphQL::STRING_TYPE, null: true, description: 'Title of the chart.'
field :title, GraphQL::Types::String, null: true, description: 'Title of the chart.'
field :data, [Types::ChartDatumType], null: true, description: 'Data of the chart.'
end
end
module Types
class ChartDatumType < BaseObject
field :x, GraphQL::INT_TYPE, null: true, description: 'X-axis value of the chart datum.'
field :y, GraphQL::INT_TYPE, null: true, description: 'Y-axis value of the chart datum.'
field :x, GraphQL::Types::Int, null: true, description: 'X-axis value of the chart datum.'
field :y, GraphQL::Types::Int, null: true, description: 'Y-axis value of the chart datum.'
end
end
```
......@@ -817,7 +821,7 @@ A description of a field or argument is given using the `description:`
keyword. For example:
```ruby
field :id, GraphQL::ID_TYPE, description: 'ID of the resource.'
field :id, GraphQL::Types::ID, description: 'ID of the resource.'
```
Descriptions of fields and arguments are viewable to users through:
......@@ -834,7 +838,7 @@ descriptions:
`'Labels of the issue'` (issue being the resource).
- Use `"{x} of the {y}"` where possible. Example: `'Title of the issue'`.
Do not start descriptions with `The`.
- Descriptions of `GraphQL::BOOLEAN_TYPE` fields should answer the question: "What does
- Descriptions of `GraphQL::Types::Boolean` fields should answer the question: "What does
this field do?". Example: `'Indicates project has a Git repository'`.
- Always include the word `"timestamp"` when describing an argument or
field of type `Types::TimeType`. This lets the reader know that the
......@@ -844,8 +848,8 @@ descriptions:
Example:
```ruby
field :id, GraphQL::ID_TYPE, description: 'ID of the issue.'
field :confidential, GraphQL::BOOLEAN_TYPE, description: 'Indicates the issue is confidential.'
field :id, GraphQL::Types::ID, description: 'ID of the issue.'
field :confidential, GraphQL::Types::Boolean, description: 'Indicates the issue is confidential.'
field :closed_at, Types::TimeType, description: 'Timestamp of when the issue was closed.'
```
......@@ -861,7 +865,7 @@ passing it the type, and field name to copy the description of.
Example:
```ruby
argument :title, GraphQL::STRING_TYPE,
argument :title, GraphQL::Types::String,
required: false,
description: copy_field_description(Types::MergeRequestType, :title)
```
......@@ -874,7 +878,7 @@ provide a `see` property on fields. For example:
```ruby
field :genus,
type: GraphQL::STRING_TYPE,
type: GraphQL::Types::String,
null: true,
description: 'A taxonomic genus.'
see: { 'Wikipedia page on genera' => 'https://wikipedia.org/wiki/Genus' }
......@@ -923,7 +927,7 @@ class PostResolver < BaseResolver
authorize :read_blog
description 'Blog posts, optionally filtered by name'
argument :name, [::GraphQL::STRING_TYPE], required: false, as: :slug
argument :name, [::GraphQL::Types::String], required: false, as: :slug
alias_method :blog, :object
......@@ -1015,10 +1019,10 @@ class JobsResolver < BaseResolver
type JobType.connection_type, null: true
authorize :read_pipeline
argument :name, [::GraphQL::STRING_TYPE], required: false
argument :name, [::GraphQL::Types::String], required: false
when_single do
argument :name, ::GraphQL::STRING_TYPE, required: true
argument :name, ::GraphQL::Types::String, required: true
end
def resolve(**args)
......@@ -1039,13 +1043,13 @@ class JobsResolver < BaseResolver
type JobType.connection_type, null: true
authorize :read_pipeline
argument :name, [::GraphQL::STRING_TYPE], required: false
argument :name, [::GraphQL::Types::String], required: false
argument :id, [::Types::GlobalIDType[::Job]],
required: false,
prepare: ->(ids, ctx) { ids.map(&:model_id) }
when_single do
argument :name, ::GraphQL::STRING_TYPE, required: false
argument :name, ::GraphQL::Types::String, required: false
argument :id, ::Types::GlobalIDType[::Job],
required: false
prepare: ->(id, ctx) { id.model_id }
......@@ -1357,7 +1361,7 @@ Arguments for a mutation are defined using `argument`.
Example:
```ruby
argument :my_arg, GraphQL::STRING_TYPE,
argument :my_arg, GraphQL::Types::String,
required: true,
description: "A description of the argument."
```
......@@ -1382,16 +1386,16 @@ defines these arguments (some
[through inheritance](https://gitlab.com/gitlab-org/gitlab/-/blob/master/app/graphql/mutations/merge_requests/base.rb)):
```ruby
argument :project_path, GraphQL::ID_TYPE,
argument :project_path, GraphQL::Types::ID,
required: true,
description: "The project the merge request to mutate is in."
argument :iid, GraphQL::STRING_TYPE,
argument :iid, GraphQL::Types::String,
required: true,
description: "The IID of the merge request to mutate."
argument :draft,
GraphQL::BOOLEAN_TYPE,
GraphQL::Types::Boolean,
required: false,
description: <<~DESC
Whether or not to set the merge request as a draft.
......
......@@ -480,7 +480,7 @@ module EE
prepended do
argument :name,
GraphQL::STRING_TYPE,
GraphQL::Types::String,
required: false,
description: 'Tanuki name'
end
......
......@@ -142,7 +142,7 @@ to view the `secretName` field:
```ruby
module Types
class ProjectType < BaseObject
field :secret_name, ::GraphQL::STRING_TYPE, null: true, authorize: :owner_access
field :secret_name, ::GraphQL::Types::String, null: true, authorize: :owner_access
end
end
```
......@@ -179,7 +179,7 @@ as an array instead of as a single value:
```ruby
module Types
class MyType < BaseObject
field :hidden_field, ::GraphQL::INT_TYPE,
field :hidden_field, ::GraphQL::Types::Int,
null: true,
authorize: [:owner_access, :another_ability]
end
......
......@@ -29,7 +29,7 @@ For example, to load a `User` by `username`, we can add batching as follows:
```ruby
class UserResolver < BaseResolver
type UserType, null: true
argument :username, ::GraphQL::STRING_TYPE, required: true
argument :username, ::GraphQL::Types::String, required: true
def resolve(**args)
BatchLoader::GraphQL.for(username).batch do |usernames, loader|
......
......@@ -3,7 +3,7 @@
require 'spec_helper'
RSpec.describe ::Types::RangeInputType do
let(:of_integer) { ::GraphQL::INT_TYPE }
let(:of_integer) { ::GraphQL::Types::Int }
context 'parameterized on Integer' do
let(:type) { described_class[of_integer] }
......@@ -32,12 +32,12 @@ RSpec.describe ::Types::RangeInputType do
expect(instance).to be_a_kind_of(described_class)
expect(instance).to be_a_kind_of(described_class[of_integer])
expect(instance).not_to be_a_kind_of(described_class[GraphQL::ID_TYPE])
expect(instance).not_to be_a_kind_of(described_class[GraphQL::Types::ID])
end
it 'follows expected subtyping relationships for classes' do
expect(described_class[of_integer]).to be < described_class
expect(described_class[of_integer]).not_to be < described_class[GraphQL::ID_TYPE]
expect(described_class[of_integer]).not_to be < described_class[GraphQL::Types::ID]
expect(described_class[of_integer]).not_to be < described_class[of_integer, false]
end
end
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