0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Gatsby と GraphQL

Last updated at Posted at 2022-02-26

Why Gatsby Uses GraphQL より -何で静的pageジェネレーター GatsbyはわざわざGraphQLを採用したのか?

  • プログラムによりページをビルドする場合 createPages NodeAPIを使ってページを作成する必要がある
    • → ブラウザサイドでJavascriptによりページ内容を描画するのではない。URLによるアクセスで最初に表示されるページを動的に生成する
    • プログラムにハードコードできない場合に..
      • JSON (third-party API, local Markdown, or JSON fileでデータを取得する)
        • gatsby-node.js の exports.cratePages の中でjsonから取得したデータを forEachで回してcreatePageでページを生成する
      • JSONではイメージを渡すことができない(imageフォルダに置いたイメージに対してその相対パスを渡すことになる)
      • GraphQLを使うとイメージのインポートも適切できる模様? (graphql 関数の中で色々と指定できるみたい)
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?