Skip to content

Commit 9125d49

Browse files
Add stub examples/nextjs-import-airbyte-github-export-seafowl/
1 parent e9dc906 commit 9125d49

7 files changed

Lines changed: 155 additions & 1 deletion

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.next
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# End-to-End Example: Use `airbyte-github` to import GitHub repository into Splitgraph, then export it to Seafowl, via Next.js API routes
2+
3+
This is a full end-to-end example demonstrating importing data to Splitgraph
4+
(using the `airbyte-github` plugin), exporting it to Seafowl (using the
5+
`export-to-seafowl` plugin), and then querying it (with `DbSeafowl` and React
6+
hooks from `@madatdata/react`). The importers and exporting of data is triggered
7+
by backend API routes (e.g. the Vecel runtime), which execute in an environment
8+
with secrets (an `API_SECRET` for Splitgraph, and a GitHub access token for
9+
`airbyte-github`). The client side queries Seafowl directly by sending raw SQL
10+
queries in HTP requests, which is what Seafowl is ultimately designed for.
11+
12+
## Try Now
13+
14+
### Preview Immediately
15+
16+
_No signup required, just click the button!_
17+
18+
[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/splitgraph/madatdata/tree/main/examples/nextjs-import-airbyte-github-export-seafowl?file=pages/index.tsx)
19+
20+
[![Open with CodeSandbox](https://assets.codesandbox.io/github/button-edit-lime.svg)](https://codesandbox.io/p/sandbox/github/splitgraph/madatdata/main/examples/nextjs-import-airbyte-github-export-seafowl?file=pages/index.tsx&hardReloadOnChange=true&startScript=dev&node=16&port=3000)
21+
22+
### Or, deploy to Vercel (signup required)
23+
24+
_Signup, fork the repo, and import it_
25+
26+
[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/git/external?repository-url=https://github.com/splitgraph/madatdata/tree/main/examples/nextjs-import-airbyte-github-export-seafowl&project-name=madatdata-basic-hooks&repository-name=madatdata-nextjs-basic-hooks)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/// <reference types="next" />
2+
/// <reference types="next/image-types/global" />
3+
4+
// NOTE: This file should not be edited
5+
// see https://nextjs.org/docs/basic-features/typescript for more information.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"private": true,
3+
"scripts": {
4+
"dev": "yarn next",
5+
"build": "yarn next build",
6+
"start": "yarn next start"
7+
},
8+
"dependencies": {
9+
"@madatdata/core": "latest",
10+
"@madatdata/react": "latest",
11+
"next": "latest",
12+
"react": "18.2.0",
13+
"react-dom": "18.2.0"
14+
},
15+
"devDependencies": {
16+
"@types/node": "^18.0.0",
17+
"@types/react": "^18.0.14",
18+
"typescript": "^4.7.4"
19+
}
20+
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import {
2+
SqlProvider,
3+
useSql,
4+
makeSplitgraphHTTPContext,
5+
} from "@madatdata/react";
6+
import { useMemo } from "react";
7+
8+
const ExampleComponentUsingSQL = () => {
9+
const { loading, error, response } = useSql<{
10+
origin_airport: string;
11+
destination_airport: string;
12+
origin_city: string;
13+
destination_city: string;
14+
passengers: number;
15+
seats: number;
16+
flights: number;
17+
distance: number;
18+
fly_month: string;
19+
origin_pop: number;
20+
destination_pop: number;
21+
id: number;
22+
}>(
23+
`SELECT
24+
"origin_airport",
25+
"destination_airport",
26+
"origin_city",
27+
"destination_city",
28+
"passengers",
29+
"seats",
30+
"flights",
31+
"distance",
32+
"fly_month",
33+
"origin_pop",
34+
"destination_pop",
35+
"id"
36+
FROM
37+
"splitgraph/domestic_us_flights:latest"."flights"
38+
LIMIT 100;`
39+
);
40+
41+
return (
42+
<pre
43+
style={{ minWidth: "100%", minHeight: 500 }}
44+
data-testid={`result-pre-${
45+
loading ? "loading" : response ? "pass" : error ? "fail" : "unknown"
46+
}`}
47+
>
48+
{JSON.stringify({ loading, error, response }, null, 2)}
49+
</pre>
50+
);
51+
};
52+
53+
const SplitgraphSampleQuery = () => {
54+
const splitgraphDataContext = useMemo(
55+
() => makeSplitgraphHTTPContext({ credential: null }),
56+
[]
57+
);
58+
59+
// Uses splitgraph.com by default (anon access supported for public data)
60+
return (
61+
<SqlProvider dataContext={splitgraphDataContext}>
62+
<ExampleComponentUsingSQL />
63+
</SqlProvider>
64+
);
65+
};
66+
67+
export default SplitgraphSampleQuery;
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"compilerOptions": {
3+
"target": "es5",
4+
"lib": ["dom", "dom.iterable", "esnext"],
5+
"allowJs": true,
6+
"skipLibCheck": true,
7+
"strict": false,
8+
"forceConsistentCasingInFileNames": true,
9+
"noEmit": true,
10+
"incremental": true,
11+
"esModuleInterop": true,
12+
"module": "esnext",
13+
"resolveJsonModule": true,
14+
"moduleResolution": "Node",
15+
"isolatedModules": true,
16+
"jsx": "preserve"
17+
},
18+
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
19+
"exclude": ["node_modules"]
20+
}

examples/yarn.lock

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ __metadata:
533533
languageName: node
534534
linkType: hard
535535

536-
"@madatdata/core@npm:0.0.11":
536+
"@madatdata/core@npm:0.0.11, @madatdata/core@npm:latest":
537537
version: 0.0.11
538538
resolution: "@madatdata/core@npm:0.0.11"
539539
dependencies:
@@ -1894,6 +1894,21 @@ __metadata:
18941894
languageName: node
18951895
linkType: hard
18961896

1897+
"nextjs-import-airbyte-github-export-seafowl-acabed@workspace:nextjs-import-airbyte-github-export-seafowl":
1898+
version: 0.0.0-use.local
1899+
resolution: "nextjs-import-airbyte-github-export-seafowl-acabed@workspace:nextjs-import-airbyte-github-export-seafowl"
1900+
dependencies:
1901+
"@madatdata/core": latest
1902+
"@madatdata/react": latest
1903+
"@types/node": ^18.0.0
1904+
"@types/react": ^18.0.14
1905+
next: latest
1906+
react: 18.2.0
1907+
react-dom: 18.2.0
1908+
typescript: ^4.7.4
1909+
languageName: unknown
1910+
linkType: soft
1911+
18971912
"node-fetch@npm:2.6.7":
18981913
version: 2.6.7
18991914
resolution: "node-fetch@npm:2.6.7"

0 commit comments

Comments
 (0)