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

Support for "expression:" on "object"? #28

Closed cgendreau closed 6 years ago

cgendreau commented 6 years ago

I have the following query (only the Repository section is included) that I tested against the GitHub GraphQL API to get the content of a file as text:

...
nodes {
        name
        object(expression: "master:LICENSE") {
          ... on Blob {
            text
          }
        }
      }
...

I was wondering how to translate the object(expression: "master:LICENSE") for githubql ? I tried the following (without success):

Object struct {
     Blob struct {
       Text githubql.String
     }`graphql:"... on Blob"`
 }`graphql:"expression:\"master:LICENSE\""`   

->Error: Parse error on "master:LICENSE" (STRING) Please note that I'm a total newbie to Go and I have very limited experience with GraphQL so do not hesitate to point me to the doc if I missed something :)

dmitshur commented 6 years ago

I tried the following (without success)

The GraphQL query has object(expression: "master:LICENSE"). You should include the whole thing in the graphql tag, not just the part inside parenthesis:

Object struct {
    ...
} `graphql:"object(expression: \"master:LICENSE\")"`
cgendreau commented 6 years ago

Thanks for the help @shurcooL

kounelisagis commented 5 years ago

Helped a lot @dmitshur