Skip to content

Convert release view to GraphQL - #8288

Closed
jakeatoms wants to merge 2 commits into
cli:trunkfrom
jakeatoms:graphql-for-release-view
Closed

jakeatoms wants to merge 2 commits into
cli:trunkfrom
jakeatoms:graphql-for-release-view

Conversation

@jakeatoms

Copy link
Copy Markdown

Fixes #4572 (Part 1).

Before adding the --json support to release list, it was requested that release view be moved to GraphQL to begin standardizing the release command on a single API. This PR represents the first step to that effect. A follow up PR will add --json to the list command and move that to this shared model.

This PR is not yet in a ready state as I have to update tests and I have some questions about behavior.

  • Address JSON filtering. Currently, all fields are returned, regardless of command input
  • Determine why Target.commitResourcePath fails when executing the query, but the query works in the Explorer.
  • Update tests and add any where necessary.

Comment thread api/queries_release.go

Target struct {
OID string
// commitResourcePath string

@jakeatoms jakeatoms Nov 3, 2023 •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When uncommented, this fails with struct field for "commitResourcePath" doesn't exist in any of 1 places to unmarshal. However, copying the generated query to the GH Explorer and executing works without issue. Is there a versioning issue at play, perhaps?

The query generated by the graphql Client:

query RepositoryReleaseByTag($name: String!, $owner: String!, $tagName: String!) {
  repository(owner: $owner, name: $name) {
    release(tagName: $tagName) {
      databaseId
      id
      tagName
      name
      description
      isDraft
      isPrerelease
      createdAt
      publishedAt
      url
      resourcePath
      author {
        id
        name
        login
      }
      releaseAssets(first: 100) {
        totalCount
        nodes {
          id
          name
          size
          url
          createdAt
          updatedAt
          downloadCount
          contentType
          downloadUrl
          uploadedBy {
            id
            name
            login
          }
        }
      }
      tag {
        id
        name
        target {
          oid
          commitResourcePath
        }
      }
      tagCommit {
        id
        tarballUrl
        zipballUrl
      }
    }
  }
}

Comment thread api/queries_release.go

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm also looking for feedback on which fields should be supported and which should also be the default


cmd.Flags().BoolVarP(&opts.WebMode, "web", "w", false, "Open the release in the browser")
cmdutil.AddJSONFlags(cmd, &opts.Exporter, shared.ReleaseFields)
cmdutil.AddJSONFlags(cmd, &opts.Exporter, api.ReleaseFields)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The biggest issue I'm encountering right now is that regardless of the fields that I pass to --json, the output is the entire release object. I noticed that the pr command manually constructs the graphql query via strings and filtering on the provided fields. However, that didn't feel like the preferred way to go, but I'm unsure how to modify the query to limit the fields. Any pointers would be appreciated!

@jakeatoms

Copy link
Copy Markdown
Author

After further discussion, we're going to standardize on the REST API rather than GraphQL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extend gh release list to add --json flag

1 participant