Skip to content

Commit 0a22f23

Browse files
committed
feat(graphql): integrate graphql - remove old models
https://github.com/martis-git/learn-frontend/issues/279
1 parent 34f6793 commit 0a22f23

File tree

5 files changed

+7
-36
lines changed

5 files changed

+7
-36
lines changed

examples/graphql/src/models.d.ts

-30
This file was deleted.

examples/graphql/src/pages/task-details/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ type Props = RouteComponentProps<{
1010

1111
const TaskDetails = (props: Props) => {
1212
const { id } = props.match.params;
13-
const { data, loading, error } = useFetch<Task>(`todos/${id}`);
13+
const { data, loading, error } = useFetch<any>(`todos/${id}`);
1414

1515
if (loading) return <Spin />;
1616
if (error) return <Alert message={error.message || String(error)} type="error" showIcon />;
+2-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
/// <reference types="react-scripts" />
2-
/// <reference types="./models" />
2+
// FIXME: import model.ts with global declaring?
3+
// /// <reference types="./models" />

examples/graphql/src/shared/components/task-card/index.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { UserOutlined, HomeOutlined } from "@ant-design/icons";
55
import { useFetch } from "shared/hooks";
66
import "./index.scss";
77

8-
type Props = Task;
8+
type Props = import("models").Todo;
99

1010
const ICON_STYLE = { color: '#08c' };
1111

@@ -16,8 +16,8 @@ const getTaskStatus = (completed: boolean) => {
1616

1717
// TODO: as feature
1818
const TaskCard = (props: Props) => {
19-
const { completed, id, title, userId } = props;
20-
const { data: author } = useFetch<User>(`users/${userId}`);
19+
const { completed, title, user } = props;
20+
const { data: author } = useFetch<import("models").User>(`users/${user?.id}`);
2121

2222
return (
2323
<Card

examples/graphql/src/shared/components/task-item/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ type Props = import("models").Todo;
1010
// TODO: as feature
1111
const TaskItem = (props: Props) => {
1212
const { completed, title, user, id } = props;
13-
const { data: author } = useFetch<User>(`users/${user?.id}`);
13+
const { data: author } = useFetch<import("models").User>(`users/${user?.id}`);
1414

1515
return (
1616
<Card className={cn("task-item", { completed })}>

0 commit comments

Comments
 (0)