Skip to content

Add info object type #20

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

Merged
merged 2 commits into from
May 26, 2021
Merged

Add info object type #20

merged 2 commits into from
May 26, 2021

Conversation

vardhanapoorv
Copy link
Contributor

@vardhanapoorv vardhanapoorv commented May 21, 2021

This PR adds support for passing info object and fixes the error code returned for webhook.

Example -

async function authorsByName({ args, dql, info }) {
    const results = await dql.query(
        `query queryAuthor($name: string, $numLikes: int) {
              queryAuthor(func: type(Author)) @filter(eq(Author.name, $name)) {
                  name: Author.name
                  dob: Author.dob
                  reputation: Author.reputation
                  posts: Author.posts @filter(eq(Post.numLikes,$numLikes)) { 
                     title: Post.title
                  }
              }
    }`,
        {
            $name: args.name,
            $numLikes: info.field.selectionSet[3].arguments.filter.numLikes.eq,
        },
    );
    return results.data.queryAuthor;
}

Use-case: https://discuss.dgraph.io/t/13179
Related Dgraph PR: hypermodeinc/dgraph#7718

Copy link
Contributor

@abhimanyusinghgaur abhimanyusinghgaur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, CI seems to have some issues.

Co-authored-by: Abhimanyu Singh Gaur <12651351+abhimanyusinghgaur@users.noreply.github.com>
@vardhanapoorv vardhanapoorv merged commit 13919e4 into master May 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants