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

Relay example with Next.js v13 #241

Merged
merged 9 commits into from
Dec 5, 2022
Merged
Show file tree
Hide file tree
Changes from 6 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
13 changes: 13 additions & 0 deletions issue-tracker-next-v13/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"next/core-web-vitals",
"plugin:relay/recommended"
],
"rules": {
"relay/generated-flow-types": "off"
},
"plugins": ["relay"]
}
1 change: 1 addition & 0 deletions issue-tracker-next-v13/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.graphql.ts auto eol=lf
36 changes: 36 additions & 0 deletions issue-tracker-next-v13/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*

# local env files
.env*.local

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts
4 changes: 4 additions & 0 deletions issue-tracker-next-v13/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Ignore artifacts:
__generated__
.next

1 change: 1 addition & 0 deletions issue-tracker-next-v13/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions issue-tracker-next-v13/.watchmanconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
26 changes: 26 additions & 0 deletions issue-tracker-next-v13/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Simple Issue Tracker Example (with Next.js 13)

## Overview

This is a simplified example of the [Issue Tracker Example](https://github.com/relayjs/relay-examples/tree/main/issue-tracker). But with few updates:

- Uses the React Server Components (Next.js v13) as entry points for [fetching](https://beta.nextjs.org/docs/data-fetching/fetching) root queries.

- `loadSerializableQuery` reference implementation of the data-fetching method that can be used in the RSC
- `useSerializablePreloadedQuery` an example hook that can convert serialized query results into preloaded query.

- Has TypesScript Setup.

## Workflow

The query fetching is happening in the `page.tsx` async server component that is calling `loadSerializableQuery`. Then, preloaded results are passed to the root client component (`MainViewClientComponent`, for example). These preloaded results are converted into Relay's `PreloadedQuery` object, which is passed to the root Relay component that renders the query with the `usePreloadedQuery` hook.

```mermaid
flowchart LR;
RSC(Root React Server Component)--Serialized Query Results-->RCC(Root Client Component);
RCC(Root Client Component)--Preloaded Query-->RRC(Root Relay Component);
```

## Installation

For installation instructions, please follow [this steps](https://github.com/relayjs/relay-examples/tree/main/issue-tracker#setup) from the `issue-tracker` example.
225 changes: 225 additions & 0 deletions issue-tracker-next-v13/__generated__/IssueQuery.graphql.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading