Skip to content

Commit 8bd01af

Browse files
author
Matt Seccafien
committed
FInal little tweaks
1 parent 2c4d2da commit 8bd01af

6 files changed

Lines changed: 20 additions & 27 deletions

File tree

examples/graphql-server/index.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
<link rel="icon" type="image/svg+xml" href="/favicon.ico" />
77
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
88
<title>Hydrogen App</title>
9-
<link rel="stylesheet" href="/src/index.css" />
109
</head>
1110
<body>
1211
<div id="root"></div>

examples/graphql-server/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
},
1717
"dependencies": {
1818
"@shopify/hydrogen": "latest",
19+
"cross-env": "^7.0.3",
1920
"graphql": "^14.6.0",
2021
"react": "0.0.0-experimental-2bf7c02f0-20220314",
21-
"react-dom": "0.0.0-experimental-2bf7c02f0-20220314",
22-
"urql": "^2.2.0"
22+
"react-dom": "0.0.0-experimental-2bf7c02f0-20220314"
2323
}
2424
}

examples/graphql-server/src/components/Examples.client.jsx

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import {fetchSync} from '@shopify/hydrogen/client';
2+
3+
function Greeting() {
4+
const {data} = fetchSync('http://localhost:3000/api/graphql', {
5+
method: 'POST',
6+
body: JSON.stringify({query: `{hello}`}),
7+
}).json();
8+
9+
return <div>{data.hello}</div>;
10+
}
11+
12+
export default Greeting;

examples/graphql-server/src/index.css

Whitespace-only changes.
Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,11 @@
1-
import {useQuery} from '@shopify/hydrogen';
2-
import Examplesclient from '../components/Examples.client';
1+
import {Suspense} from 'react';
32

4-
export default function Page() {
5-
const {
6-
data: {data},
7-
} = useQuery(['home', 'hello-world'], async () => {
8-
const response = await fetch('http://localhost:3000/api/graphql', {
9-
method: 'POST',
10-
body: JSON.stringify({query: `{hello}`}),
11-
});
12-
13-
return await response.json();
14-
});
15-
16-
console.log(data);
3+
import Greeting from '../components/Greeting.client';
174

5+
export default function Page() {
186
return (
19-
<p>
20-
{data.hello}
21-
<Examplesclient />
22-
</p>
7+
<Suspense fallback="loading...">
8+
<Greeting />
9+
</Suspense>
2310
);
2411
}

0 commit comments

Comments
 (0)