shurcooL / githubv4

Package githubv4 is a client library for accessing GitHub GraphQL API v4 (https://docs.github.com/en/graphql).
MIT License
1.11k stars 89 forks source link

BodyHTML doesn't exist on type Issue #50

Closed ycjcl868 closed 4 years ago

ycjcl868 commented 4 years ago
var q struct {
  Repository struct {
    Issue struct {
      Number github.Int `json:"id"`
      Title      github.String `json:"title"`
      URL github.URI `json:"url"`
      CreatedAt  github.DateTime `json:"createdAt"`
      BodyHTML github.String `json:"bodyHTML"`
    } `graphql:"issue(number:31)"`
  } `graphql:"repository(owner: \"\", name: \"\")"`
}

error message: [{%!d(string=Field 'bodyHtml' doesn't exist on type 'Issue') [{1 107}]}]data {{{0 %!d(githubv4.String=) {0} {{0 0 0}} %!d(githubv4.String=)}}}%

but I use https://developer.github.com/v4/explorer/ can output the result:

image

dmitshur commented 4 years ago
BodyHTML github.String `json:"bodyHTML"`

You should use "graphql" tag, not "json", to specify the name of the GraphQL field:

BodyHTML github.String `graphql:"bodyHTML"`