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

[research] Data Layer: how next.js connects to backends #18

Closed
3 tasks done
rufuspollock opened this issue Jun 14, 2020 · 2 comments
Closed
3 tasks done

[research] Data Layer: how next.js connects to backends #18

rufuspollock opened this issue Jun 14, 2020 · 2 comments
Assignees
Projects

Comments

@rufuspollock
Copy link
Member

rufuspollock commented Jun 14, 2020

How should we get (meta)data / content? What is the "data layer" for this system?

The content fetching divides into two parts:

graph LR

remote[Remote e.g. CKAN API] --fetchers--> localdb[Local DB Cache]
localdb --common api--> render[Renderer]
  • Want a common API / structure for local DB so that renderers have a simple interface and the complexity of fetchers is hidden from them. Options:
    • redux
    • graphql based
  • SUMMARY: atm we are strongly inclining to graphql based approach. (see below for reasoning)
  • fetchers will always be somewhat bespoke

Tasks

Analysis (in progress)

Next.js data fetching can be done in two ways:

  • getStaticProps - fetches data at build time
  • getServersideProps - fetches data at runtime

We want to use the getServersideProps method for our use case. There's a repo with helpful examples to see how data fetching works in Next. https://github.com/vercel/next.js/blob/canary/examples

What we want ...

fetch could use graphql, raw queries it doesn't matter ...

graph TD

external[External Data Source e.g. CKAN or Wordpress]
react[React Component]
page[Rendered Page]

external --fetch--> react
external --fetch --> redux
external --fetch --> store[Store - non redux]
redux--> react
store --graphql--> react

react --render--> page

gatsby ...

graph TD

external[External] --> source[Source plugin]
source --> store[Internal Store - nodes]
store --graphql--> component[Component]
component --render--> page

Inbox (misc)

Inbox on Graphql approach

Summary

Excellent critique of next.js SSR approach: https://en.paqmind.com/blog/ssr-is-not-the-future and recommendations on how to approach (jan 20 2020)

This section of gatsby doc is useful https://www.gatsbyjs.org/docs/graphql-concepts/#why-is-graphql-so-cool

For a more in-depth look, read why Gatsby uses GraphQL.

  • Eliminate frontend data boilerplate — no need to worry about requesting & waiting for data. Just ask for the data you need with a GraphQL query and it’ll show up when you need it
  • Push frontend complexity into queries — many data transformations can be done at build-time within your GraphQL queries
  • It’s the perfect data querying language for the often complex/nested data dependencies of modern applications
  • Improve performance by removing data bloat — GraphQL enables you to select only the data you need, not whatever an API returns
@rufuspollock rufuspollock self-assigned this Jun 14, 2020
@anuveyatsu anuveyatsu added this to the Sprint - 26 Jun 2020 milestone Jun 15, 2020
@anuveyatsu anuveyatsu added this to Prioritized in v1 Overview via automation Jun 15, 2020
@anuveyatsu
Copy link
Member

Hi @rufuspollock should we wait for this to complete before we can start wiring up CKAN API with, e.g., Apollo?

@anuveyatsu
Copy link
Member

Closing this since we've implemented #29

v1 Overview automation moved this from In progress to Done Jul 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
v1 Overview
  
Done
Development

No branches or pull requests

2 participants