dgraph icon indicating copy to clipboard operation
dgraph copied to clipboard

fix(graphql): Checkpwd func and val inside eq func now work in custom dql

Open Schartey opened this issue 3 years ago • 1 comments

The checkpwd func does not work in custom dql queries since #7775 . The query rewriter for custom dql did not handle the checkpwd function. Also it did not allow to use val inside of the eq function.

Example:

type Query {
    authenticate(username: String, email: String, password: String!): [User] @custom(dql: """
	query q($username: string, $email: string, $password: string) {
          var(func: type(User)) @filter(eq(User.username, $username) OR eq(User.email, $email)) {
              check as checkpwd(User.password, $password)
          }
              
          authenticate(func: eq(val(check), 1)) {
              id: uid
              username: User.username
              email: User.email
          }
      }
    """
    )
}

This query uses checkpwd in the first query, which would be rewritten to

check as User.password)

and it uses func: eq(val(check), 1) in the second query, which would result in

func: eq(check, "1")

I added handling for both of these issues. The issue has also been documented in discuss

Please let me know if I missed something. I would be glad if this could make it into the next release, as it is a minor change.


This change is Reviewable

Schartey avatar Dec 01 '21 16:12 Schartey

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

CLAassistant avatar Apr 29 '22 07:04 CLAassistant

@Schartey Master doesn't exist anymore. Can you open a new PR pointing to Main? Closing and waiting a New PR.

Thank you.

MichelDiz avatar Nov 22 '22 21:11 MichelDiz