-
Notifications
You must be signed in to change notification settings - Fork 92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How can i make omit empty in grpahql query struct #49
Comments
What error do you get? Can you paste it here?
You'll need to use GraphQL syntax for this, not JSON. GraphQL has a directive called "include": https://graphql.github.io/graphql-spec/June2018/#sec--include So you can do something like: Topics *RepositoryTopics `graphql:"repositoryTopics(first: 20) @include(if: $includeTopics)"` Then set the variables := map[string]interface{}{
"repositoryName": githubv4.String(RepoName),
"orgName": githubv4.String(GithubOrg),
"includeTopics": githubv4.Boolean(false),
} Is that what you're looking to do? |
Thanks for the reply this is what exactly I needed. One query reg
If I change the structure as below. That is changing
struct to pointer
And then calling the graphql as above i get the below error slice doesn't exist in any of 1 places to unmarshal |
I have one more scenario where I need to find the codeowner existence in a repo. According to Github the codeowners can be found in three different locations.. Is there a way can I combine a struct group and assign it to the repository struct
|
Thanks. I'll need a complete runnable snippet that can reproduce this problem to investigate further. Do you mind putting one together?
Yes. Instead of doing: Name githubv4.String
Description githubv4.String
CodeOwners *GetCodeOwners // This doesn't work You need to do something like: Name githubv4.String
Description githubv4.String
*GetCodeOwners // Embed this struct. Or: Name githubv4.String
Description githubv4.String
CodeOwner CodeOwnerLocation `graphql:"object(expression: \"HEAD:CODEOWNERS\")"`
GithubCodeOwner CodeOwnerLocation `graphql:"object(expression: \"HEAD:.github/CODEOWNERS\")"`
DocsCodeOwner CodeOwnerLocation `graphql:"object(expression: \"HEAD:docs/CODEOWNERS\")"` When you do {
codeOwners {
docsCodeOwner: object(expression: "HEAD:docs/CODEOWNERS" {
... on Blob {
text
}
}
githubCodeOwner: object(expression: "HEAD:.github/CODEOWNERS" {
// ...
}
// ...
}
} Which isn't valid, because of "codeOwners". Embedding that struct means its contents are directly inserted, which is what you want. In general, I suggest coming up with the GraphQL query that does what you want first, testing it via GitHub GraphQL API Explorer at https://developer.github.com/v4/explorer/, and then converting it to Go code that executes the GraphQL query. |
Is it possible to pass a dynamic variable to a struct tag? In the below struct, I want to pass the
The problem here is that I have the topicsCount variable in the config and need to fetch it from there. Could you assist me with this? |
I got it. This is mentioned in the documentation of passing the variable. https://github.com/shurcooL/githubv4#arguments-and-variables |
Is there a way we can concatenate the
Here in some cases expression has a head but in some cases, it has some other head sha Can this be made in a dynamic way
I can do it by
Where my I am thinking a way of using it as common so it can be used for |
I have the following struct in which the
Topics
in the field tag can be optional so I made it as a pointer. Now while try calling the graphql it is resulting in errorI tried calling the graphql
I am getting the
topics
field always. How can i make it as optionalI tried two ways
The text was updated successfully, but these errors were encountered: