Closed ideate closed 7 years ago
ran into issues
What were the issues?
I think this is just how GraphQL works:
https://facebook.github.io/graphql/#sec-Language.Variables
A variable needs to provide an entire value. There is no support for doing string concatenation.
You'll need to do this instead:
graphql:"search(query: $query, type: REPOSITORY, first: $pageSize)"
query := fmt.Sprintf("language: %s", "PowerShell")
variables := map[string]interface{}{
"query": githubql.String(query),
"pageSize": githubql.Int(100),
}
err := client.Query(context.Background(), &query, variables)
Let me know if you find something in the GraphQL spec that says variables are expected to work in the way you suggested.
awesome! that makes sense! it looks like i assumed that the behavior was similar to JS template literals
ran into issues running variables with inline fragments within a github query string
graphql:"search(query: \"language:$language\", type: REPOSITORY, first:$pageSize)"
however, this version works correctly with variables:
graphql:"search(query: \"language:PowerShell\", type: REPOSITORY, first:$pageSize)"