shurcooL / graphql

Package graphql provides a GraphQL client implementation.
MIT License
704 stars 280 forks source link

"Variable \\\"$evar\\\" is never used. #65

Closed sushruthajirnis closed 3 years ago

sushruthajirnis commented 3 years ago

Am i doing something wrong or the substitution of the variable is not accurate? I get following error , my initialization below

"{\"errors\":[{\"message\":\"Variable \\\"$evar\\\" is never used.\",\"locations\":[{\"line\":1,\"column\":7}],\"extensions\":{\"code\":\"GRAPHQL_VALIDATION_FAILED\"}}],\"data\":null}"

var query struct {
    GetBusinessUnits []struct {
        Name graphql.String
    } `graphql:getBusinessUnits(env:$evar)"`
}
var _ = gauge.Step("Send CLS to rum backend", func() {
    client := graphql.NewClient("https://localhost:8080/query", nil)
    variables := map[string]interface{}{
        "evar":   graphql.String("e2e"),
    }
    err := client.Query(context.Background(), &query, variables)
    if err != nil {
        fmt.Println(err)
    }
    fmt.Println(query.GetBusinessUnits[0].Name)
})
dmitshur commented 3 years ago

It looks like your graphql struct tag is missing a double quote:

-`graphql:getBusinessUnits(env:$evar)"`
+`graphql:"getBusinessUnits(env:$evar)"`
sushruthajirnis commented 3 years ago

yep that was it