Skip to content
This repository was archived by the owner on Jan 20, 2025. It is now read-only.
Merged
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
28 changes: 14 additions & 14 deletions docs/docs/sourcing-from-private-apis.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
---
title: Sourcing from Private APIs
title: プライベート API からデータを取得する
---

Gatsby allows you to pull data from headless CMSs, databases, SaaS services, public API, and your private APIs.
Gatsby は、ヘッドレス CMS、データベース、SaaS サービス、パブリック API、プライベート API からデータを取得できます。

From the Gatsby perspective, there is no difference between sourcing from a public or private API. The only difference is the availability of the API to Gatsby to query the data.
Gatsby の視点からすると、パブリック API とプライベート API のどちらからの取得にも違いはありません。Gatsby がその API へアクセスできる事こそが重要です。

There are 3 approaches that you can use to source data from your private API:
プライベート API からデータを取得するために使用できる 3 つの方法があります:

1. If your private API is a GraphQL API, you can use [`gatsby-source-graphql`](/packages/gatsby-source-graphql/).
2. If your private API is not a GraphQL API and you are new to GraphQL, treat the data as unstructured data and fetch it during build time, as described by the guide "[Using Gatsby without GraphQL](/docs/using-gatsby-without-graphql/)". However, as highlighted in the guide, this approach comes with some tradeoffs.
3. Create a source plugin, as described in the tutorial "[Source plugin tutorial](/docs/pixabay-source-plugin-tutorial/)".
1. プライベート API GraphQL API である場合、 [`gatsby-source-graphql`](/packages/gatsby-source-graphql/) が利用できます。
2. プライベート API GraphQL API ではなく、また GraphQL を利用するのが初めてであれば、ガイド「[GraphQL 外から Gatsby を使用する](/docs/using-gatsby-without-graphql/)」で説明されているように、データを非構造化データとして扱い、ビルドする際に取得します。ただし、ガイドでも強調されているように、この方法にはいくつかのトレードオフが伴います。
3. チュートリアル「[ソースプラグインチュートリアル](/docs/pixabay-source-plugin-tutorial/)」にしたがって、ソースプラグインを作成します。

## Other considerations
## その他の考慮事項

1. If the data of your private API is updated very frequently or the expectation of the site is to be updated in real-time, it may make more sense to query the data directly during runtime.
1. プライベート API のデータがとても頻繁に更新される場合や、サイトがリアルタイムで更新されると期待する場合、実行時にデータを直接クエリーする方が理にかなっている場合があります。

2. If you can source the data through a plugin, consider that as an alternative to sourcing via the API. For instance, if you have access to the MongoDB database that stores the data, [`gatsby-source-mongodb`](/packages/gatsby-source-mongodb/) will be handy. Browse the [Gatsby Plugin Library](/plugins/) to see what plugins that you could utilize.
2. もしプラグインを介してデータを取得できる場合は、API を介した取得の代替として考えてください。 例えば、データを保管する MongoDB データベースにアクセスできる場合は、[`gatsby-source-mongodb`](/packages/gatsby-source-mongodb/) が便利です。[Gatsby プラグインライブラリー](/plugins/) を参照して、使用できるプラグインを確認してください。

3. Depending on your build process and the availability of your private API, you may need to make other adjustments accordingly.
3. ビルドプロセスやプライベート API の状況に応じて、他の調整が必要になる場合があります。

- If your private API is only available within your company network, then you would need to expose the private API to your CI server that runs the build, else you would need to run the gatsby build in your own computer.
- You may also need to configure the endpoints of the API differently for development or production. Refer the [environment variables](/docs/environment-variables/) guide to learn how to do that.
- もしプライベート API が社内ネットワーク内でのみ使用可能な場合、ビルドを実行する CI サーバーにプライベート API を公開する必要があります。そうでなければ、あなたのコンピューターで Gatsby ビルドを実行する必要があります。
- 開発環境と本番環境に別々の API エンドポイントの構成が必要な場合もあります。方法については [環境変数](/docs/environment-variables/) ガイドを参照してください。

4. To ensure your site does not show outdated data, you may want to setup an automated process to trigger the process to rebuild your site whenever the data is updated. For instance, if you host your site in Netlify, you can [make a request for its webhook to trigger a new build](https://www.netlify.com/docs/webhooks/).
4. サイトに古いデータが表示されないようにするには、データが更新される度にサイトを再ビルドするプロセスをトリガーする自動プロセスをセットアップできます。例えば、サイトを Netlify でホストしている場合、[webhook にリクエストを作成して新しいビルドをトリガー](https://www.netlify.com/docs/webhooks/)できます。