-
Notifications
You must be signed in to change notification settings - Fork 68
add auth header #127
add auth header #127
Conversation
Deploy preview for dgraph-docs-repo ready! Built with commit 0a98409 |
{{% 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 |
There was a problem hiding this comment.
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 } }) => |
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{{% 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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
hello @verneleem, could you review Aaron's comments? thanks! (also there's a merge conflict for |
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. |
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.
Closing in favor of #205 |
* 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>
* 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>
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>
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.