57
apps/console/src/pages/HomePage.tsx
Normal file
57
apps/console/src/pages/HomePage.tsx
Normal file
@@ -0,0 +1,57 @@
|
||||
import { Suspense, useEffect } from "react";
|
||||
import {
|
||||
graphql,
|
||||
PreloadedQuery,
|
||||
usePreloadedQuery,
|
||||
useQueryLoader,
|
||||
} from "react-relay";
|
||||
import { Link } from "react-router";
|
||||
import type { HomePageQuery as HomePageQueryType } from "./__generated__/HomePageQuery.graphql";
|
||||
|
||||
export const HomePageQuery = graphql`
|
||||
query HomePageQuery {
|
||||
node(id: "AZSfP_xAcAC5IAAAAAAltA") {
|
||||
id
|
||||
... on Organization {
|
||||
name
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export default function HomePage() {
|
||||
const [queryRef, loadQuery] =
|
||||
useQueryLoader<HomePageQueryType>(HomePageQuery);
|
||||
|
||||
useEffect(() => loadQuery({}), [loadQuery]);
|
||||
|
||||
if (!queryRef) {
|
||||
return <HomePageFallback />;
|
||||
}
|
||||
|
||||
return (
|
||||
<Suspense fallback={<HomePageFallback />}>
|
||||
<HomePageContent queryRef={queryRef} />
|
||||
</Suspense>
|
||||
);
|
||||
}
|
||||
|
||||
function HomePageFallback() {
|
||||
return <div>Loading...</div>;
|
||||
}
|
||||
|
||||
function HomePageContent({
|
||||
queryRef,
|
||||
}: {
|
||||
queryRef: PreloadedQuery<HomePageQueryType>;
|
||||
}) {
|
||||
const data = usePreloadedQuery(HomePageQuery, queryRef);
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h1>User</h1>
|
||||
<pre>{JSON.stringify(data, null, 2)}</pre>
|
||||
<Link to="/foobar">Go to FooPage</Link>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
10
apps/console/src/pages/NotFoundPage.tsx
Normal file
10
apps/console/src/pages/NotFoundPage.tsx
Normal file
@@ -0,0 +1,10 @@
|
||||
import { Link } from "react-router";
|
||||
|
||||
export default function NotFoundPage() {
|
||||
return (
|
||||
<div>
|
||||
<p>The page might have been moved, deleted, or never existed.</p>
|
||||
<Link to="/">Return to Home</Link>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
118
apps/console/src/pages/__generated__/HomePageQuery.graphql.ts
generated
Normal file
118
apps/console/src/pages/__generated__/HomePageQuery.graphql.ts
generated
Normal file
@@ -0,0 +1,118 @@
|
||||
/**
|
||||
* @generated SignedSource<<269bb5911dc11e2bda71f8c506e1d7e7>>
|
||||
* @lightSyntaxTransform
|
||||
* @nogrep
|
||||
*/
|
||||
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @ts-nocheck
|
||||
|
||||
import { ConcreteRequest } from 'relay-runtime';
|
||||
export type HomePageQuery$variables = Record<PropertyKey, never>;
|
||||
export type HomePageQuery$data = {
|
||||
readonly node: {
|
||||
readonly id: string;
|
||||
readonly name?: string;
|
||||
};
|
||||
};
|
||||
export type HomePageQuery = {
|
||||
response: HomePageQuery$data;
|
||||
variables: HomePageQuery$variables;
|
||||
};
|
||||
|
||||
const node: ConcreteRequest = (function(){
|
||||
var v0 = [
|
||||
{
|
||||
"kind": "Literal",
|
||||
"name": "id",
|
||||
"value": "AZSfP_xAcAC5IAAAAAAltA"
|
||||
}
|
||||
],
|
||||
v1 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "id",
|
||||
"storageKey": null
|
||||
},
|
||||
v2 = {
|
||||
"kind": "InlineFragment",
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "name",
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"type": "Organization",
|
||||
"abstractKey": null
|
||||
};
|
||||
return {
|
||||
"fragment": {
|
||||
"argumentDefinitions": [],
|
||||
"kind": "Fragment",
|
||||
"metadata": null,
|
||||
"name": "HomePageQuery",
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": (v0/*: any*/),
|
||||
"concreteType": null,
|
||||
"kind": "LinkedField",
|
||||
"name": "node",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v1/*: any*/),
|
||||
(v2/*: any*/)
|
||||
],
|
||||
"storageKey": "node(id:\"AZSfP_xAcAC5IAAAAAAltA\")"
|
||||
}
|
||||
],
|
||||
"type": "Query",
|
||||
"abstractKey": null
|
||||
},
|
||||
"kind": "Request",
|
||||
"operation": {
|
||||
"argumentDefinitions": [],
|
||||
"kind": "Operation",
|
||||
"name": "HomePageQuery",
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": (v0/*: any*/),
|
||||
"concreteType": null,
|
||||
"kind": "LinkedField",
|
||||
"name": "node",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "__typename",
|
||||
"storageKey": null
|
||||
},
|
||||
(v1/*: any*/),
|
||||
(v2/*: any*/)
|
||||
],
|
||||
"storageKey": "node(id:\"AZSfP_xAcAC5IAAAAAAltA\")"
|
||||
}
|
||||
]
|
||||
},
|
||||
"params": {
|
||||
"cacheID": "5d18865912a8a8c16bc28f5506766d82",
|
||||
"id": null,
|
||||
"metadata": {},
|
||||
"name": "HomePageQuery",
|
||||
"operationKind": "query",
|
||||
"text": "query HomePageQuery {\n node(id: \"AZSfP_xAcAC5IAAAAAAltA\") {\n __typename\n id\n ... on Organization {\n name\n }\n }\n}\n"
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
(node as any).hash = "0da7306fdc31722644ce24a893020fae";
|
||||
|
||||
export default node;
|
||||
Reference in New Issue
Block a user