Skip to content

QueryString with Search creating issue #87

Description

@sumitnagal

I have my code for fetching the information from repo based on programming language

func generateDataGithub(githubToken string, githubURL string, org string, language string, count int) {
src := oauth2.StaticTokenSource(
		&oauth2.Token{AccessToken: githubToken},
	)
	httpClient := oauth2.NewClient(context.Background(), src)

	client := githubv4.NewEnterpriseClient(githubURL, httpClient)
var query struct {
		Search struct {
			RepositoryCount githubv4.Int
			Edges []struct {
				Node struct {
					Repository struct {
						Name          githubv4.String
						NameWithOwner githubv4.String
						Owner         struct {
							Login githubv4.String
						}
						PrimaryLanguage struct {
							Name githubv4.String
						}
						DefaultBranchRef struct {
							Name githubv4.String
						}
					} `graphql:"... on Repository"`
				}
			}
		}`graphql:"search(first: $count, query: $searchQuery, type: REPOSITORY)"`
	}
variables := map[string]interface{}{
		"searchQuery": githubv4.String(fmt.Sprintf(`user:%s language:%s`,githubv4.String(org),githubv4.String(language))),
		"count":    githubv4.Int(count),
	}

Executing them but not getting any result back

err := client.Query(context.Background(), &query, variables)
	if err != nil {
		Error.Println(err)
	}

See Below

{
        "Search": {
                "RepositoryCount": 0,
                "Edges": []
        }
}

While from Graphql

{
  search(query: "user:<your org> language:java", type: REPOSITORY, first: 2) {
    repositoryCount
    edges {
      node {
        ... on Repository {
          owner {
            login
          }
          name
          nameWithOwner
          owner {
            login
          }
          primaryLanguage {
            name
          }
          defaultBranchRef {
            name
          }
        }
      }
    }
  }
}

I am getting this

{
  "data": {
    "search": {
      "repositoryCount": 10,
      "edges": [
        {
          "node": {
            "owner": {
              "login": "***"
            },
            "name": "mule",
            "nameWithOwner": "***/**",
            "primaryLanguage": {
              "name": "Java"
            },
            "defaultBranchRef": {
              "name": "master"
            }
          }
        }
      ]
    }
  }
}

Any help, as I have seen most of the closed tickets, and implemented what has been suggested.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    WaitingForInfoIssue is not actionable because of missing required information, which needs to be provided.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions