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

fix(docs): fix errors from authorization examples given in docs. #6522

Merged
merged 1 commit into from
Sep 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions wiki/content/graphql/authorization/directive.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,17 @@ type Todo @auth(
){
id: ID!
text: String! @search(by: [term])
owner: String!
owner: String! @search(by: [hash])
}
```

In addition to it, details of the authentication provider should be given in the last line of the schema, as discussed in section [authorization-overview](/graphql/authorization/authorization-overview).

Here we define a type `Todo`, that's got an `id`, the `text` of the todo and the username of the `owner` of the todo. What todos can a user query? Any `Todo` that the `query` rule would also return.

The `query` rule in this case expects the JWT to contain a claim `"USER": "..."` giving the username of the logged in user, and says: you can query any todo that has your username as the owner.

In this example we use the `queryTodo` query that will be auto generated after uploading this schema. When using a query in a rule, you can only use the `queryTypeName` query. Where `TypeName` matches the name of where the `@auth` directive is attached. In other words, we could not have used the `getTodo` query in our rule above to query by id only.
In this example we use the `queryTodo` query that will be auto generated after uploading this schema. When using a query in a rule, you can only use the `queryTypeName` query. Where `TypeName` matches the name of the type, where the `@auth` directive is attached. In other words, we could not have used the `getTodo` query in our rule above to query by id only.

This rule is applied automatically at query time. For example, the query

Expand Down
5 changes: 2 additions & 3 deletions wiki/content/graphql/authorization/mutations.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,11 @@ type Todo @auth(
}
}"""
}
){{
){
id: ID!
text: String!
owner: User
}

type User {
username: String! @id
todos: [Todo]
Expand Down Expand Up @@ -58,7 +57,7 @@ type Todo @auth(
},
{ rule: "{$ROLE: { eq: \"ADMIN\" } }"}
]}
){{
){
id: ID!
text: String! @search(by: [term])
owner: User
Expand Down