-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: Apollo server * feat: start of an Apollo server * Adds a hello world endpoint at /api/graphql * Adds an Explorer sandbox at /graphql
- Loading branch information
Showing
10 changed files
with
679 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -124,6 +124,6 @@ | |
] | ||
}, | ||
"wrapPagesWithGlobalContexts": true, | ||
"cliVersion": "0.1.330", | ||
"$schema": "https://unpkg.com/@plasmicapp/[email protected].330/dist/plasmic.schema.json" | ||
"cliVersion": "0.1.331", | ||
"$schema": "https://unpkg.com/@plasmicapp/[email protected].331/dist/plasmic.schema.json" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { ApolloServer } from "@apollo/server"; | ||
import { startServerAndCreateNextHandler } from "@as-integrations/next"; | ||
import { NextRequest } from "next/server"; | ||
import { gql } from "graphql-tag"; | ||
|
||
const resolvers = { | ||
Query: { | ||
hello: () => "world", | ||
}, | ||
}; | ||
|
||
const typeDefs = gql` | ||
type Query { | ||
hello: String | ||
} | ||
`; | ||
|
||
const server = new ApolloServer({ | ||
resolvers, | ||
typeDefs, | ||
introspection: true, | ||
}); | ||
|
||
const handler = startServerAndCreateNextHandler<NextRequest>(server, { | ||
context: async (req) => ({ req }), | ||
}); | ||
|
||
export { handler as GET, handler as POST }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
@tailwind base; | ||
@tailwind components; | ||
@tailwind utilities; | ||
@tailwind utilities; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
.embed { | ||
display: block; /* iframes are inline by default */ | ||
height: 100vh; /* Set height to 100% of the viewport height */ | ||
width: 100vw; /* Set width to 100% of the viewport width */ | ||
border: none; /* Remove default border */ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { EmbeddedSandbox } from "../../components/widgets/apollo-sandbox"; | ||
import styles from "./graphql.module.css"; | ||
|
||
export const dynamic = "force-static"; | ||
export const revalidate = false; // 3600 = 1 hour | ||
|
||
export default function ApolloSandboxPage() { | ||
return ( | ||
<div style={{ minHeight: "100vh" }}> | ||
<EmbeddedSandbox className={styles.embed} /> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
"use client"; | ||
|
||
import { ApolloSandbox } from "@apollo/sandbox/react"; | ||
import { DOMAIN } from "../../lib/config"; | ||
|
||
const API_PROTOCOL = "https://"; | ||
const API_BASE = API_PROTOCOL + DOMAIN; | ||
const API_PATH = "/api/graphql"; | ||
const API_URL = new URL(API_PATH, API_BASE); | ||
|
||
type EmbeddedSandboxProps = { | ||
className?: string; | ||
}; | ||
|
||
function EmbeddedSandbox(props: EmbeddedSandboxProps) { | ||
return ( | ||
<ApolloSandbox | ||
className={props.className} | ||
initialEndpoint={API_URL.toString()} | ||
/> | ||
); | ||
} | ||
export { EmbeddedSandbox }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.