Skip to content

Support for Resource relations in schema generation #254

@nexus49

Description

@nexus49

Context

It would be very helpful to leverage the power of graphql to be able to traverse relationships in queries and subscriptions.

Tasks/Requirements

  • Adjust generator and gateway for relationships
  • Add the ability to the gateway to open multiple watches in case of a watch for a singe resource that has relationships.
    • the gateway needs to watch the requested resource plus each resource it has a relationship to.
    • the gateway should only open such watches if the fields were requested
  • Relations should only be expanded if the fields are requested by the query
  • Add Convention that resources have to follow so that the gateway supports the relationship (TBD convention needs to be decided upon, but lets assume below convention to start the work)
<kind>Ref:
  kind: <abc>  # kind is optional, should be provided if kind conflicts are possible, otherwise inferred from the `<kind>Ref` patttern
  apiGroup: <abc> # apiGroup is optional, should be provided if kind conflicts are possible
  name: <abc>
  namespace: <abc>
  • The resulting action is that the listener adjusts the schema generation and adds a property linking to the referenced type.
  • The resulting action is that the gateway retrieves the additional kubernetes objects and constructs the response object

Example Query that should be possible after the change:

{ 
  rbac_authorization_k8s_io {
    ClusterRoleBindings {
      roleRef {
        apiGroup
        name
        kind
        role {
          rules {
          verbs
        }
      }
    }
  }
}

Out of scope

  • Only Queries no support for Subscriptions
  • Only one level of Releation a-b-c relations are not supported for now
  • Only single item Queries, not supported for lists for now

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions