Skip to content

Commit

Permalink
(Examples) update Grafbase example (#54705)
Browse files Browse the repository at this point in the history
Co-authored-by: Balázs Orbán <18369201+balazsorban44@users.noreply.github.com>
  • Loading branch information
vinaykulk621 and balazsorban44 committed Sep 30, 2023
1 parent f0f8762 commit 638cc93
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 18 deletions.
17 changes: 8 additions & 9 deletions examples/with-grafbase/app/layout.tsx
@@ -1,14 +1,14 @@
import './globals.css'

import Link from 'next/link'

import { graphql } from '../gql'
import { grafbase } from '../lib/grafbase'
import type { Metadata } from 'next'

export const revalidate = 0

export const metadata = {
export const metadata: Metadata = {
title: 'Grafbase + Next.js',
description: 'Grafbase + Next.js',
}

const GetAllPostsDocument = graphql(/* GraphQL */ `
Expand All @@ -25,16 +25,17 @@ const GetAllPostsDocument = graphql(/* GraphQL */ `
}
`)

const RootLayout = async ({ children }: { children: React.ReactNode }) => {
export default async function RootLayout({
children,
}: {
children: React.ReactNode
}) {
const { postCollection } = await grafbase.request(GetAllPostsDocument, {
first: 50,
})

return (
<html lang="en">
<head>
<title>Grafbase + Next.js 13</title>
</head>
<body>
<div className="flex">
<nav className="w-[350px] flex flex-col justify-between h-screen overflow-y-auto bg-gray-100">
Expand Down Expand Up @@ -82,5 +83,3 @@ const RootLayout = async ({ children }: { children: React.ReactNode }) => {
</html>
)
}

export default RootLayout
4 changes: 1 addition & 3 deletions examples/with-grafbase/app/page.tsx
@@ -1,4 +1,4 @@
const Page = async () => {
export default function Page() {
return (
<>
<h1>Next.js 13 + Grafbase</h1>
Expand All @@ -9,5 +9,3 @@ const Page = async () => {
</>
)
}

export default Page
4 changes: 1 addition & 3 deletions examples/with-grafbase/app/posts/[slug]/page.tsx
Expand Up @@ -11,7 +11,7 @@ const GetPostBySlugDocument = graphql(/* GraphQL */ `
}
`)

const Page = async ({ params }: { params: { slug: string } }) => {
export default async function Page({ params }: { params: { slug: string } }) {
const { post } = await grafbase.request(GetPostBySlugDocument, {
slug: params.slug,
})
Expand All @@ -28,5 +28,3 @@ const Page = async ({ params }: { params: { slug: string } }) => {
</>
)
}

export default Page
3 changes: 0 additions & 3 deletions examples/with-grafbase/next.config.js
@@ -1,9 +1,6 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
experimental: {
runtime: 'experimental-edge',
},
}

module.exports = nextConfig

0 comments on commit 638cc93

Please sign in to comment.