Skip to content

Commit

Permalink
boilerplate for a graphql server
Browse files Browse the repository at this point in the history
  • Loading branch information
setsun committed Jul 12, 2023
1 parent b9b5fc2 commit 9577f0b
Show file tree
Hide file tree
Showing 6 changed files with 214 additions and 24 deletions.
2 changes: 1 addition & 1 deletion apps/portfolio/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"classnames": "^2.3.2",
"database": "workspace:*",
"graphql": "^16.7.1",
"graphql-request": "^6.1.0",
"graphql-yoga": "^4.0.3",
"lodash.clamp": "^4.0.3",
"next": "^13.4.9",
"react": "^18.2.0",
Expand Down
1 change: 1 addition & 0 deletions apps/portfolio/src/app/api/graphql/resolvers/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { };
26 changes: 26 additions & 0 deletions apps/portfolio/src/app/api/graphql/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { NextResponse } from "next/server";
import { createYoga, createSchema } from "graphql-yoga";

const { handleRequest } = createYoga({
schema: createSchema({
typeDefs: /* GraphQL */ `
type Query {
greetings: String
}
`,
resolvers: {
Query: {
greetings: () =>
"This is the `greetings` field of the root `Query` type",
},
},
}),

// While using Next.js file convention for routing, we need to configure Yoga to use the correct endpoint
graphqlEndpoint: "/api/graphql",

// Yoga needs to know how to create a valid Next response
fetchAPI: { Response: NextResponse },
});

export { handleRequest as GET, handleRequest as POST };
1 change: 1 addition & 0 deletions apps/portfolio/src/app/api/graphql/schema/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { };
5 changes: 1 addition & 4 deletions packages/scripts/src/generate-previews.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ async function generatePreviews() {
// Set screen size
await page.setViewport({ width: 1200, height: 700 });

// Configure the navigation timeout
await page.setDefaultNavigationTimeout(0);

for (let pageNumber of PAGE_NUMBERS) {
await page.goto(`https://setsun.xyz/visualizers/${pageNumber}`, {
waitUntil: "networkidle0",
Expand All @@ -56,4 +53,4 @@ async function generatePreviews() {
// run logic
(async () => {
await generatePreviews();
})();
})();
203 changes: 184 additions & 19 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9577f0b

Please sign in to comment.