Skip to content

Expose workspace_variables in graphQL API

MR: Add new query API to expose workspace variables... (!176617 - merged)

Description

We have a workspaces_variables table in the database which stores variables that get injected into the workspace at the time of creation.

Variables that get injected into a workspace are either static_variables such as:

  • GL_EDITOR_EXTENSIONS_GALLERY_SERVICE_URL

  • GL_EDITOR_EXTENSIONS_GALLERY_ITEM_URL

  • ... See ee/lib/remote_development/workspace_operations/create/workspace_variables.rb for complete list

OR

user_provided_variables which can be added by the user with the Add variable option while creating a new workspace.

With this issue we want to introduce the workspaces_variables in the graphQL API to setup a foundation for future work including:

  • Third-party integrations or user automations/scripting/reporting
  • Facilitating QA/E2E testing
  • Making variables available in the UI

This includes creating a new Type/Resolver/Finder so that the workspaces_variables data can be queried via graphQL.

There are the DB fields available

id, workspace_id, variable_type, created_at, updated_at, key, encrypted_value, encrypted_value_iv, project_id

Technical Requirements

GraphQL Changes

  • Type.workspaceVariable

    name type
    field id GlobalIDType[::RemoteDevelopment::WorkspaceVariable]
    field variableType WorkspaceVariableType
    field key String
    field value String
    field createdAt TimeType
    field updatedAt TimeType
  • Type.workspace

    name type
    field workspaceVariables [WorkspaceVariable!]
  1. Only return user_provided variables through the API
  2. Ask graphQL team about policy around deprecating a type. If its possible then deprecate WorkspaceVariableInputType and replace with WorkspaceVariableType which can be used in both the WorkspaceVariableInput and the new WorkspaceVariable
  3. Introduce the new graphQL changes marked as alpha

Acceptance Criteria

  • Add new type WorkspaceVariable
  • Add new field workspace_variables to WorkspaceType
  • Add new Finder/Resolver for workspace_variables
  • Mark new graphQL changes (fields/arguments) as alpha
  • Add migration to introduce new boolean field user_provided in the workspace_variables table & backfill
  • Delegate policy to workspaces authorization rules
  • Add new WorkspaceVariableType to replace WorkspaceVariableInput
  • Deprecate WorkspaceVariableInput if possible
  • Add unit tests for the Finder
  • Add relevant request specs to the ee/spec/requests/api/graphql/remote_development/workspace folder
  • Update tests.yml and scripts/verify-tff-mapping
Edited by Daniyal Arshad