docs: update copy to use "deny-list" (fix #5115) (#5116)

This commit is contained in:
sezgi 2020-06-17 08:40:11 -07:00 committed by GitHub
parent df8a0b7924
commit d13e26db46
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -282,17 +282,17 @@ If the validation requires complex custom business logic and/or needs informatio
from external sources, you can use :ref:`Actions <actions>` to perform your from external sources, you can use :ref:`Actions <actions>` to perform your
validation. validation.
**Example:** Check with an external service that an author's name is not black-listed **Example:** Check with an external service that an author's name is not deny-listed
before inserting them. before inserting them.
Let's assume we have an external service that stores and manages black-listed authors. Let's assume we have an external service that stores and manages deny-listed authors.
Before inserting an author we need to check with this service if they are black-listed Before inserting an author we need to check with this service if they are deny-listed
or not. or not.
The validation process looks as follows: The validation process looks as follows:
.. thumbnail:: /img/graphql/manual/schema/diagram-actions-data-validation.png .. thumbnail:: /img/graphql/manual/schema/diagram-actions-data-validation.png
:alt: validation using actions: article not blacklisted :alt: validation using actions: article not deny-listed
:width: 60% :width: 60%
@ -311,26 +311,26 @@ The following is a sample code that could be added to the event handler to imple
.. code-block:: javascript .. code-block:: javascript
function getBlacklistedAuthorsFromApi() { function getDenylistedAuthorsFromApi() {
// make external api call & return black-listed authors list // make external api call & return deny-listed authors list
} }
function insertAuthorViaHasura() { function insertAuthorViaHasura() {
// run insert_author mutation & return response // run insert_author mutation & return response
} }
const blacklistedAuthors = getBlacklistedAuthorsFromApi(); const denylistedAuthors = getDenylistedAuthorsFromApi();
if (blacklistedAuthors.includes(author.name)) { if (denylistedAuthors.includes(author.name)) {
return res.status(400).json({ message: "Author is blacklisted" }); return res.status(400).json({ message: "Author is deny-listed" });
} else { } else {
const insertAuthorResponse = insertAuthorViaHasura(); const insertAuthorResponse = insertAuthorViaHasura();
return res.json(insertAuthorResponse); return res.json(insertAuthorResponse);
} }
When we now insert an author, our action handler will be called and it will check if the author is black-listed. When we now insert an author, our action handler will be called and it will check if the author is deny-listed.
If it's not, the author will be inserted and the ``id`` will be returned. If the author is black-listed, If it's not, the author will be inserted and the ``id`` will be returned. If the author is deny-listed,
we get the following error message: we get the following error message:
.. graphiql:: .. graphiql::
@ -349,7 +349,7 @@ we get the following error message:
"path": "$", "path": "$",
"code": "unexpected" "code": "unexpected"
}, },
"message": "Author is blacklisted" "message": "Author is deny-listed"
} }
] ]
} }