Skip to content
This repository was archived by the owner on Mar 29, 2025. It is now read-only.

Conversation

ghost
Copy link

@ghost ghost commented Mar 17, 2021

fix formatting and prettify for pages being updated.
add authHeader examples and documentation to lambda overview and field.

Note: I had to revert changes to commit the formatting and prettify changes separately from the doc content changes. I will remember to prettify and format and commit before changing content to see the content that was changed easier to review.

@ghost ghost requested review from aaroncarey, bucanero and danielmai as code owners March 17, 2021 18:29
@netlify
Copy link

netlify bot commented Mar 17, 2021

Deploy preview for dgraph-docs-repo ready!

Built with commit 0a98409

https://deploy-preview-127--dgraph-docs-repo.netlify.app

@ghost ghost assigned aaroncarey and bucanero Apr 27, 2021
{{% notice "tip" %}}
This example uses `parent` for the resolver function. You can find additional resolver examples using `dql` in the [Lambda queries article]({{< relref "query.md" >}}), and using `graphql` in the [Lambda mutations article]({{< relref "mutation.md" >}}).
{{% /notice %}}
{{% notice "tip" %}} This example uses `parent` for the resolver function. You
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for trimming the line lengths! But, note that you can't break markdown links across lines... so in the case of links, it is fine for the line to exceed 80 or 100 characters (as long as necessary to avoid link breaks).

Please fix this on lines 58 and 59

const characterBio = ({parent: {name}}) => `My name is ${name}.`
const humanBio = ({parent: {name, totalCredits}}) => `My name is ${name}. I have ${totalCredits} credits.`
const droidBio = ({parent: {name, primaryFunction}}) => `My name is ${name}. My primary function is ${primaryFunction}.`
const authorBio = ({ parent: { name, dob } }) =>
Copy link
Contributor

Choose a reason for hiding this comment

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

It's also fine to ignore line length guidelines for syntax snippets :)

```

Another example, adding a resolver for `rank` using a `graphql` call:
An example, adding a resolver for `rank` using a `graphql` call:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
An example, adding a resolver for `rank` using a `graphql` call:
For example, you can add a resolver for `rank` using a `graphql` call, as follows:

});
```

An example of using the client provided JWT to return true if the custom claim
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
An example of using the client provided JWT to return true if the custom claim
The following example demonstrates using the client-provided JWT to return true if the custom claim

```

An example of using the client provided JWT to return true if the custom claim
for `USER` from the JWT matches the Author's id.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
for `USER` from the JWT matches the Author's id.
for `USER` from the JWT matches the Author's `id`:

If you're using [Slash GraphQL](https://dgraph.io/slash-graphql), the final compiled script file must be under 500Kb
{{% /notice %}}
{{% notice "note" %}} If you're using
[Slash GraphQL](https://dgraph.io/slash-graphql), the final compiled script file
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
[Slash GraphQL](https://dgraph.io/slash-graphql), the final compiled script file
[Dgraph Cloud](https://dgraph.io/cloud), the final compiled script file


## Declaring lambda in a GraphQL schema

There are three places where you can use the `@lambda` directive and thus tell Dgraph where to apply custom JavaScript logic.
There are three places where you can use the `@lambda` directive and thus tell
Copy link
Contributor

Choose a reason for hiding this comment

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

and thus tell -> to tell

{{% notice "tip" %}}
Functions `self.addGraphQLResolvers` and `self.addMultiParentGraphQLResolvers` can be called multiple times in your resolver code.
{{% /notice %}}
{{% notice "tip" %}} Functions `self.addGraphQLResolvers` and
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
{{% notice "tip" %}} Functions `self.addGraphQLResolvers` and
{{% notice "tip" %}} The functions `self.addGraphQLResolvers` and


Each resolver function should return data in the exact format as the return type of GraphQL field, query, or mutation for which it is being registered.
Each resolver function should return data in the exact format as the return type
of GraphQL field, query, or mutation for which it is being registered.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
of GraphQL field, query, or mutation for which it is being registered.
of the GraphQL field, query, or mutation for which it is being registered.

```

### addMultiParentGraphQLResolvers

The `self.addMultiParentGraphQLResolvers` is useful in scenarios where you want to perform computations involving all the parents returned from Dgraph for a lambda field. This is useful in two scenarios:
The `self.addMultiParentGraphQLResolvers` is useful in scenarios where you want
to perform computations involving all the parents returned from Dgraph for a
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
to perform computations involving all the parents returned from Dgraph for a
to perform computations involving all of the parents returned from Dgraph for a

@bucanero
Copy link
Contributor

bucanero commented May 7, 2021

hello @verneleem, could you review Aaron's comments? thanks!

(also there's a merge conflict for overview.md)

@ghost
Copy link
Author

ghost commented May 10, 2021

It appears I deleted this branch from my forked repo so I cannot push any new changes. Leave this open for just a little bit as I create a new branch in this repo and apply these changes fresh considering the comments and change requests above.

ghost pushed a commit that referenced this pull request May 10, 2021
reword line 79 per @aaroncarey  on related PR #127
fix wording from 'lambda query' to 'GraphQL query'
Convert all indents to two spaces instead of tabs.
@ghost
Copy link
Author

ghost commented May 10, 2021

Closing in favor of #205

@ghost ghost closed this May 10, 2021
bucanero pushed a commit that referenced this pull request May 11, 2021
* fix indentation

* add authHeader example for returning Boolean Author.isMe

reword line 79 per @aaroncarey  on related PR #127
fix wording from 'lambda query' to 'GraphQL query'
Convert all indents to two spaces instead of tabs.

* normalize indentation to two spaces

* add authHeader definitions

* define authHeader types with typescript

add example to call graphql with custom jwt.
fix typescript syntax removing commas from end of lines in types
update typescript definitions to add better variables for clarification in docs

* Minor edits (#206)

Co-authored-by: aaroncarey <31550444+aaroncarey@users.noreply.github.com>
MichelDiz pushed a commit that referenced this pull request Dec 15, 2022
* fix indentation

* add authHeader example for returning Boolean Author.isMe

reword line 79 per @aaroncarey  on related PR #127
fix wording from 'lambda query' to 'GraphQL query'
Convert all indents to two spaces instead of tabs.

* normalize indentation to two spaces

* add authHeader definitions

* define authHeader types with typescript

add example to call graphql with custom jwt.
fix typescript syntax removing commas from end of lines in types
update typescript definitions to add better variables for clarification in docs

* Minor edits (#206)

Co-authored-by: aaroncarey <31550444+aaroncarey@users.noreply.github.com>
rderbier added a commit that referenced this pull request Apr 20, 2023
Repairing PR from #127 since that original branch was deleted from a
forked repo and could no longer modify it.

- add authHeader example for returning Boolean `Author.isMe`
- normalize indentation of files changed
- add `authHeader` definition including TS definitions in lambda
overview
- add example for calling `graphql` function in lambda with custom
authHeader (JWT)
- fixed TS syntax
- clarified some of the TS variables using longer names such as
replacing `s` with `query` where the string is a query string and there
is no need for smaller verbosity in documentation.

Co-authored-by: verneleem <73715956+verneleem@users.noreply.github.com>
Co-authored-by: aaroncarey <31550444+aaroncarey@users.noreply.github.com>
Co-authored-by: rderbier <rderbier@gmail.com>
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants