A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/jlengstorf/gatsby-with-unstructured-data below:

jlengstorf/gatsby-with-unstructured-data: A simple example of creating pages dynamically in Gatsby without using GraphQL.

Can you use Gatsby without GraphQL?

Yes!

This is a small example that loads data from the PokéAPI’s REST endpoints, then creates pages (and nested pages) using Gatsby’s createPages API.

The upsides of using REST: The downsides of using REST: What would this look like querying from a GraphQL API?

Great question! There’s not a stable Pokémon GraphQL API that I’ve seen, but if there was, the query might look like this:

const data = await graphql(`
  {
    Pokemon {
      edges {
        node {
          name
          abilities {
            name
            effect
          }
        }
      }
    }
  }
`);

// Use createPage to turn the data into pages, just like the REST version.

This one query accomplishes the same thing as the three different REST calls, and it shows more clearly how the data is related (e.g. each Pokémon has abilities).

What would this look like using Gatsby's GraphQL integration layer?

For quick and easy comparison, the using-gatsby-data-layer branch illustrates how you can accomplish this using Gatsby's integration layer, rather than using the unstructured data approach.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4