Use a GraphQL API to fetch environments data
Objective
Discuss possible adoption of GraphQL for Environments & Pods
Problem to solve
In %12.6 the APM team will improve the way we list environments by:
- searching them (#34021 (closed)) in both the metrics and logs page
- and listing its nodes in different ways (#35581 (closed)) (#35570 (closed)).
These improvements will result in integration efforts between backend and frontend. We could find a better way evolve the APIs related to our environments
.
Intended users
APM frontend team and GitLab community at large.
Further details
Currently, the environments endpoints returns are lot of data that is discarded, as in the case of the "Environments" page:
- Request URL: http://10.183.227.111:3001/root/autodevops-deploy/environments.json?scope=available&page=1
Or too little, in the "search.json" endpoint:
- Request URL: http://10.183.227.111:3001/root/autodevops-deploy/environments/search.json?query=prod
- Response:
["production"]
Proposal
Add GraphQL to fetch and search environments information.
Motivation
- Depending the view, we require more or less detail of a given
environment
. Sometimes it links to other pages providing that have more detailed information. Each of this views requires different backend APIs to be created. - An "environment" is a nested object which is composed of "pods", this can be represented by the edges to other objects.
- Search and pagination is already build-in.
- We extend and dogfood the public GitLab API, as the GraphQL is used in the frontend and a public API.
Permissions and Security
TODO
Challenges
- Some data of the environments doesn't exist in the database and most be sync'd from the kubernetes cluster.
Documentation
- WIP GitLab's GraphQL developer guide !19010 (merged)
- Schema explorer runs in GDK, e.g. http://localhost:3001/-/graphql-explorer
MVC
A possible MVC, could be done by having the list of environments searchable by name for #34021 (closed) with some of the environment properties that are already in the database.
Edited by Miguel Rincon