Skip to content
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

Show where parsing error occurred #109

Closed
isubasinghe opened this issue Jul 6, 2020 · 2 comments
Closed

Show where parsing error occurred #109

isubasinghe opened this issue Jul 6, 2020 · 2 comments

Comments

@isubasinghe
Copy link

isubasinghe commented Jul 6, 2020

I am trying to convert the following code into golang, we have an existing firebase app but we are attempting to convert it into faunadb. I have more complex authentication requirements and therefore cannot use faunadb's built-in system. My solution is to write a go Lamba function that can handle login/sign up functionality.

Create(
  Tokens(), {
    instance: Select("ref", Get(Match(Index('users_by_email'), "alice@site.example")))
  }
)
func loginUser(email string) {
	expr := fauna.Create(fauna.Tokens(), fauna.Select("ref",
		fauna.Get(
			fauna.MatchTerm(fauna.Index("users_by_email"), email),
		),
	))
	value, err := client.Query(expr)
	if err != nil {
		fmt.Println(err)
	} else {
		fmt.Println(value)
	}
}

I'm very new to faunadb, I get this error when running the above code snippet.
Response error 400. Errors: [params](invalid argument): Object expected, Ref provided.

This isn't the best to help debug, what would be more helpful is to return a FQL string with the error section highlighted in red.
Would this be a feature you can implement?

P.S.

Would appreciate any help with the above issue

@trevorsibanda
Copy link

Hi @isubasinghe
You seem to have missed the object. Try changing it to:

expr := fauna.Create(fauna.Tokens(), fauna.Obj{"instance: fauna.Select("ref",
		fauna.Get(
			fauna.MatchTerm(fauna.Index("users_by_email"), email),
		),
	)})

On showing the position of errors occured, we have a ticket on this (DRV-96) and will be rolling this out with other related features/fixes.

@isubasinghe
Copy link
Author

Cool thanks for that :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants