Skip to content

Add `is_forked` field to project GraphQL type

Peter Hegman requested to merge add-is-forked-field-to-project-graphql-type into master

What does this MR do and why?

Related to #421441 (closed)

The grouptenant scale team is starting to build out an Organization MVC. For more information about what an "Organization" will be see https://docs.gitlab.com/ee/architecture/blueprints/organization/

In !141429 (merged) we are swapping mock data for a the real GraphQL API. The API is missing the isForked attribute that is needed by the frontend. This MR adds that attribute to the project GraphQL type so it is available to the frontend.

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

How to set up and validate locally

  1. Fork a project, make note of project path
  2. Find an unforked project, make note of project path
  3. Go to http://127.0.0.1:3000/-/graphql-explorer
  4. Enter:
query {
  projects(fullPaths: [<array of paths from step 1 and 2>]) {
    nodes {
      isForked
    }
  }
}
  1. Open dev tools network tab
  2. Run the query
  3. Inspect the HTTP request and find the X-Request-Id header. Copy the value
  4. Go to http://127.0.0.1:3000/. In the upper right corner of performance bar click the + sign, enter request ID from previous step, hit Enter
  5. From the dropdown in the performance bar select the request you just entered. Inspect the SQL queries

Database review

Raw SQL

SELECT
    "fork_network_members"."id" AS t0_r0,
    "fork_network_members"."fork_network_id" AS t0_r1,
    "fork_network_members"."project_id" AS t0_r2,
    "fork_network_members"."forked_from_project_id" AS t0_r3,
    "fork_networks"."id" AS t1_r0,
    "fork_networks"."root_project_id" AS t1_r1,
    "fork_networks"."deleted_root_project_name" AS t1_r2
FROM
    "fork_network_members"
    INNER JOIN "fork_networks" ON "fork_networks"."id" = "fork_network_members"."fork_network_id"
WHERE
    "fork_network_members"."project_id" IN (278964, 41372369)
ORDER BY
    "fork_network_members"."id" ASC
LIMIT 1000

Query plan

https://console.postgres.ai/gitlab/gitlab-production-tunnel-pg12/sessions/25204/commands/80086

Queries https://gitlab.com/gitlab-org/gitlab and https://gitlab.com/gitlab-community/gitlab

 Limit  (cost=12.49..12.49 rows=2 width=62) (actual time=28.013..28.017 rows=2 loops=1)
   Buffers: shared hit=15 read=7
   I/O Timings: read=27.784 write=0.000
   ->  Sort  (cost=12.49..12.49 rows=2 width=62) (actual time=28.012..28.014 rows=2 loops=1)
         Sort Key: fork_network_members.id
         Sort Method: quicksort  Memory: 25kB
         Buffers: shared hit=15 read=7
         I/O Timings: read=27.784 write=0.000
         ->  Nested Loop  (cost=0.85..12.48 rows=2 width=62) (actual time=13.390..27.978 rows=2 loops=1)
               Buffers: shared hit=12 read=7
               I/O Timings: read=27.784 write=0.000
               ->  Index Scan using index_fork_network_members_on_project_id on public.fork_network_members  (cost=0.43..5.59 rows=2 width=16) (actual time=7.972..22.532 rows=2 loops=1)
                     Index Cond: (fork_network_members.project_id = ANY ('{278964,41372369}'::integer[]))
                     Buffers: shared hit=6 read=5
                     I/O Timings: read=22.413 write=0.000
               ->  Index Scan using fork_networks_pkey on public.fork_networks  (cost=0.42..3.44 rows=1 width=46) (actual time=2.711..2.711 rows=1 loops=2)
                     Index Cond: (fork_networks.id = fork_network_members.fork_network_id)
                     Buffers: shared hit=6 read=2
                     I/O Timings: read=5.371 write=0.000
Edited by Peter Hegman

Merge request reports