Skip to content

Help with Filtering Users #93

Answered by dthisner
dthisner asked this question in Q&A
Discussion options

You must be logged in to vote

Got it to work, needed to make sure that I was specifying the String as graphql.String, otherwise it thought it was ID
Final code:

func GetUserByUsername(username string, c *http.Client) (string, error) {
	client := graphql.NewClient(tools.GetGraphqlUrl(), c)
	err := client.Query(context.Background(), &models.GetUserByUsernameResponse, map[string]interface{}{"iLike": graphql.String(username)})
	if err != nil {
		return "", logging.Problem(section, "problem getting user", err)
	}

	userId := models.GetUserByUsernameResponse.Users.Nodes[0].User_id
	if len(userId) < 6 {
		return "", fmt.Errorf("user id is to short, got: %s", userId)
	}

	log.Printf("\"%s\" user id is: \"%s\"\n", username, us…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by dthisner
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant