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

docs/node-apis #40

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
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
22 changes: 11 additions & 11 deletions docs/docs/node-apis.md
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
---
title: Gatsby Node APIs
description: Documentation on Node APIs used in Gatsby build process for common uses like creating pages
title: API di Node in Gatsby
description: Documentazione della API di Node usate nel processo di compilazione per utenti comuni come creare pagine
jsdoc: ["src/utils/api-node-docs.ts"]
apiCalls: NodeAPI
---

Gatsby gives plugins and site builders many APIs for controlling your site's data in the GraphQL data layer.
Gatsby fornisce ai plugin e compilatori di sito molte API per controllare i dati del tuo sito nel livello dati di GraphQL.

## Async plugins
## Plugin asincroni

If your plugin performs async operations (disk I/O, database access, calling remote APIs, etc.) you must either return a promise (explicitly using `Promise` API or implicitly using `async`/`await` syntax) or use the callback passed to the 3rd argument. Gatsby needs to know when plugins are finished as some APIs, to work correctly, require previous APIs to be complete first. See [Debugging Async Lifecycles](/docs/debugging-async-lifecycles/) for more info.
Se i tuoi plugin effettuano operazioni asincrone (I/O su disco, accesso a database, chiamare API remote, ecc.), devi ritornare una Promise (usando esplicitamente l'API `Promise` o implicitamente usando la sintassi `async`/`await`) o usando la callback passata al terzo argomento. Gatsby necessita di sapere quando i plugin hanno concluso l'operazione, come alcune APIs, per funzionare correttamente, necessitano prima che altre APIs usate precedentemente siano concluse. Vedi [Debuggare cicli asincroni](/docs/debugging-async-lifecycles/) per maggiori informazioni.
albertopasqualetto marked this conversation as resolved.
Show resolved Hide resolved

```javascript
// Async/await
exports.createPages = async () => {
// do async work
// fai qualcosa di asincrono
const result = await fetchExternalData()
}

// Promise API
exports.createPages = () => {
return new Promise((resolve, reject) => {
// do async work
// fai qualcosa di asincrono
})
}

// Callback API
exports.createPages = (_, pluginOptions, cb) => {
// do async work
// fai qualcosa di asincrono
cb()
}
```

If your plugin does not do async work, you can just return directly.
Se il tuo plugin non esegue alcuna operazione asincorna, puoi ritornare direttamente.

## Usage
## Uso

Implement any of these APIs by exporting them from a file named `gatsby-node.js` in the root of your project.
Implementa una qualsiasi di queste APIs esportandole da una file chiamato `gatsby-node.js` nella radice del tuo progetto.
albertopasqualetto marked this conversation as resolved.
Show resolved Hide resolved